2

We using SonarQube 5.2, the Rule

Redundant modifiers should be removed

does not working correctly.

The class is defined in multiple files, therefore it be has declared as partial, but SonarQube mark this as bug.

Has anyone an idea to fix this?

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
  • What language is the code in? – G. Ann - SonarSource Team Jan 05 '16 at 19:47
  • C# .net framework 4.5 – Omar Teodoro Oropeza Jan 05 '16 at 20:30
  • Please provide some code on how to reproduce this false positive – Dinesh Bolkensteyn Jan 06 '16 at 12:11
  • *public partial class DerivativesOperatorModel* this class is declared en many files e.g: ClearingPartnerAsignaConciliationModel.cs, ClearingPartnerDifferentialCommissionsMaintenanceModel.cs, learingPartnerExcerciceOptionsMaintenanceModel.cs,ClearingPartnerOptionsExerciseModel.cs, etc. I´m just analazyng this code, I do not wrote this code. – Omar Teodoro Oropeza Jan 07 '16 at 19:08
  • Omar, please edit question instead of adding comments (example: add code to question) – agabrys Jan 07 '16 at 20:37
  • 1
    If you are using the *sonar-runner* directly then it might be because the analysis is performed post-build one file at a time. See [this blog[(http://blogs.msdn.com/b/visualstudioalm/archive/2016/01/04/sonarqube-scanner-for-msbuild-v1-1-released-static-analysis-now-executed-during-the-build-x.aspx) for more information on the issue and how it is fixed in builds using the *SonarQube Scanner for MSBuild* v1.1 with C# plugin v4.4. As as test, add a second empty *public partial class DerivativesOperatorModel* declaration in a file containing a "real" declaration and see if the issue disappears. – duncanp Jan 11 '16 at 10:19
  • That´s right, I'm using MSBuild 14.0, I updated SonarRunner from 1.0.1 to 1.1, and also updated C# plugin from 4.3 to 4.4. Now the analisys did not show false positive. Thank you duncanpMS – Omar Teodoro Oropeza Jan 13 '16 at 17:38

1 Answers1

0

try putting //NOSONAR
For example : public partial class MyClass //NOSONAR

Similar thing to skip the rule is here too

Community
  • 1
  • 1