0
votes

When I ran sonar analysis for C# project, sonar reported few issues: one of the issue was from fxcop rule named CA1704: Identifiers should be spelled correctly. Since I did not wish sonar to report issues under rule CA1704, I created a CustomDictionary.xml and followed the instructions provided under "How to fix violations" for fxcop rule CA1704.

P.S: As per the instructions provided to fix violations for rule CA1704, we can place CustomDictionary.xml at any 3 places namely -

  • Place the dictionary in the installation directory of the tool
  • The project directory
  • The directory that is associated with the tool under the profile of the user (%USERPROFILE%\Application Data...)

I chose 2nd option (above), placed CustomDictionary.xml inside C# project directory and ran sonar analysis in debug mode. After analyzing the log of sonar, when fxcop starts with its analysis on C# project - following log can be seen.

Executing command: C:/Program Files (x86)/Microsoft Visual Studio 12.0/Team Tools/Static Analysis Tools/FxCop/FxCopCmd.exe /file:D:\Installers\Example_Projects\sonar-examples-master\projects\languages\csharp\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe /ruleset:=D:\Installers\Example_Projects\sonar-examples-master\projects\languages\csharp.sonar\Sample_Test_Framework_ConsoleApplication1\fxcop-sonarqube.ruleset /out:D:\Installers\Example_Projects\sonar-examples-master\projects\languages\csharp.sonar\Sample_Test_Framework_ConsoleApplication1\fxcop-report.xml /outxsl:none /forceoutput /searchgac

Even though I've placed CustomDictionary.xml inside C# project directory. Sonar is unable to avoid the violations reported by rule CA1704; even if CustomDictionary.xml present under project directory. By default (referring to above log), fxcop sonar analysis takes the default CustomDictionary.xml which is present at the installation directory of FxCop (here in this case C:/Program Files (x86)/Microsoft Visual Studio 12.0/Team Tools/Static Analysis Tools/FxCop/).

I have ran analysis on C# project with both sonar-runner 2.3 & 2.4 versions.

Is there any possibility how we can change the default dictionary path to another path where CustomDictionary.xml is present?

Would it be possible if there is a room for implementing a new sonar argument which takes custom path where CustomDictionary.xml is present?

Thank you, Dhruva

1

1 Answers

1
votes

You can add the following to your .csproj to tell FxCop which dictionary to use:

<ItemGroup> <CodeAnalysisDictionary Include="MyCustomDictionary.xml" /> </ItemGroup>