How to add custom rules using fxcop on sonarqube? (6.7.7)

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Sonarqube 6.7.7
    MSBuild for sonar scanner 4.6.2
    oracle server 11g

  • what are you trying to achieve
    I want to analyze my source using fxcop custom rules on my sonarqube server.

  • what have you tried so far to achieve this
    First, I confirmed open source(fxcop custom rule) on the GitHub.( And then I checked this rules works well at Visual Studio 2017.(Attached image no.1)

Second, I added custom rule’s assembly file(OpenGI.CodingStandards.dll) to \Static Analysis Tools\FxCop\Rules

Third, Run ‘VS2017 developer cmd’ as Administrator, I changed path to where I have to analyze the source. then I entered the command below.

SonarQube.Scanner.MSBuild.exe begin /n:“MyProject” /v:“0.2” /k:“MyProject_Key” /d:“sonar.cs.fxcop.slnFile=D:\Sonarqube\04_TargetProject\MySampleProject\MySampleProject.sln” /d:“sonar.cs.fxcop.fxCopCmdPath=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe” /d:“\debug”

MSBuild.exe D:\Sonarqube\04_TargetProject\MySampleProject /t:Rebuild

SonarScanner.MSBuild.exe end

All processes are succeed. but I couldn’t find the custom rule assembly what I put on ‘\Static Analysis Tools\FxCop\Rules’ at the success log. so the custom rules didn’t applied. (Attached image no.2,3)**

I tried to apply the custom rule on the sonarqube server, but I don’t know where can I put on the custom rule assembly. What do I missed?


Welcome to the community!

You’ll need to write your rules with Roslyn, rather than FxCop, to have their issues show up in SonarQube.