简体   繁体   中英

SonarQube FxCop Analysis (rule: CA1704) throws issues even though we define CustomDictionary.xml under C# Project

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 .

PS: 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

您可以在.csproj中添加以下内容,以告诉FxCop使用哪个词典:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM