SonarQube Reporting Issues on final Local Variables and Single Quotes in Imports

In my Flutter project, local variables are intentionally marked as final to ensure immutability, and single quotes are used for package imports according to our coding standards. However, SonarQube is flagging these as issues:

  1. Local Variables Should Not Be final: SonarQube raises unnecessary issues on local variables marked as final, which is crucial to our project structure.
  2. Single Quotes in Imports: It flags single quotes in imports, although they are consistent with our project style.

Questions:

  • Can these rules be disabled or ignored in SonarQube while maintaining other linting checks?
  • What is the best way to update our analysis_options.yaml or SonarQube configuration to prevent these false positives without altering our project structure?

Impact:

These rules generate numerous false positives, making it harder to focus on genuine issues.

HI @Uzair_Ghulam,
I think it’s a very good approach to have internal coding standards adapted to your context.

Sonarqube provides a default set of rules for each langaguee, a ‘quality profile’ in which some rules are enabled and others disabled.

I recommend that you customise this set of rules by defining your own quality profile.

For example, you can run a test with all the rules enabled and decide which ones make the most sense to you, and even adapt the severity or certain rule parameters.

Some informations could be found in the documentation Quality profiles

1 Like