Zero Issues despite obvious problems

Template for a good bug report, formatted with Markdown:

  • versions used (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarLint 5.2 With Clion 2021.2
  • error observed (wrap logs/code around triple quote ``` for proper formatting)
    0 Errors reported despite having this code:
int main() {
    printf("Hello, World!\n");
    if(1)
        printf("haha");
    //printf("test")
    return 0;
}

  • steps to reproduce
  • potential workaround
    The code above should prode a couple of errors. First there is an if without braces and then there is a commented line. However I get 0 errors. Why is that?

Hello @JSStabl,

There are two reasons why you don’t see the issues you expected to see:

  • Not all rules are enabled by default. For instance, the one about braces is not (this is stylistic, and many people don’t want to follow this style). You can enable a rule (and see what is enabled) by going to Settings > Tools > SonarLint > Rules.
    Please note also that if you work in connected mode, the list of active rules will be synchronized between SonarLint and SonarQube/SonarCloud.
  • For the commented code, there is another issue. It’s very difficult to decide is a comment is just a comment or is commented code. We need to rely on heuristics, and it can never be perfect. The code you currently have is not going to be considered as commented code. The same with a semicolon at the end would be.

Hope this helps!

1 Like