Can SonarQube check the design patterns

  1. We are interested to see how design patterns can be checked in SonarQube.
  2. Regarding the cross-modular checks – unfortunately I was not able to find any link or document that explains it in more detail, so I will try myself - it is somewhat technical :blush:. Let us assume the following example:

i.e. we have two source files that share a common header file, which defines a data structure (struct x) with a conditional item (int b). Those two files are separately compiled and linked into a single executable image. If both source files define B_INCLUDED, which controls the conditional part of the data structure, everything will work correctly. But if the first source file defines B_INCLUDED, while the second does not, things will not work as expected. The problem is that: 1) seen from the compiler’s perspective, there is no issue, 2) linker does not perform this type of check, 3) static analysis at the level of source files will not reveal the issue. That department is using PC-Lint (Gimpel Software) is capable of this cross-modular checks which focus exactly on these issues – basically it supplements the functionality that is (by design, perhaps from historical reasons) missing in the linker.

Hi @Avinash2223

Sorry for the long delay in replying.

  1. We do not check design patterns. There is no intention to do it for now but I note the interest.
  2. We do not have this specific check. Implementing it would open a new class of checks that would require significant developments. We might consider this if we discover more checks of this class. For now, there is no plan to implement this feature.

I hope it helps.