A SonarQube plugin for the ReSharper Command Line Tools.
This plugin enables the analysis of C# and VisualBasic.NET source files contained in .NET projects using the output of the InspectCode JetBrains ReSharper Command Line Tool.
- Supports the most recent version of the JetBrains ReSharper Command Line Tools (at least version 2020.1.3)
- Compatible with SonarQube 7.9.x (LTS)
- Compatible with the SonarC# Plugin in version 7.5
- Compatible with the SonarVB Plugin (Visual Basic .NET) in version 5.2
Property | Description |
---|---|
resharper.clt.solutionFile |
The path to the Visual Studio solution file (.sln ) parsed by the InspectCode command line tool. |
resharper.clt.cs.reportPath |
Used when analyzing C# projects. Defines the path to the XML report file generated by the InspectCode command line tool to be parsed by the plugin. |
resharper.clt.vbnet.reportPath |
Used when analyzing VisualBasic.NET projects. Defines the path to the XML report file generated by the InspectCode command line tool to be parsed by the plugin. |
resharper.clt.xsd.validation |
Enables XML Schema validation of the XML report file generated by the InspectCode command line tool. (not yet working) |
A more in-depth guide on how to analyze projects that are built using MSBuild can be found in article Analyzing with SonarScanner for MSBuild of the official SonarQube documentation.
- Install the ReSharper Command Line Tools plugin (see Installing a Plugin - SonarQube Documentation - Doc SonarQube for more details)
- Enable at least one of the rules provided by the plugin in your quality profile (see Quality Profiles for more details)
- Open a command prompt, preferably the Developer Command prompt for Visual Studio
- Navigate to the root folder of the project/solution you want to build
- Execute the following steps:
- Begin the SonarQube analysis and provide the values for the required properties
SonarScanner.MSBuild.exe begin /k:"sonarqube_project_key" /n:"sonarqube_project_name" /d:sonar.login="%SONAR_LOGIN_TOKEN%" /d:resharper.clt.cs.reportPath="inspectcode_result.xml" /d:resharper.clt.solutionFile="%SOLUTION_FILE%"
- Build the project
msbuild.exe "%SOLUTION_FILE"
- Run ReSharper Command Line Tool
InspectCode.exe
inspectcode.exe /output="resharper.xml" "%SOLUTION_FILE%"
- End the SonarQube analysis, which will upload the issues to the server
SonarScanner.MSBuild.exe end /d:sonar.login=%SONAR_LOGIN_TOKEN%
- Begin the SonarQube analysis and provide the values for the required properties
It's possible to override the SonarSeverity for particular rules by providing a custom sonarqube_rule_overrides.xml
. This can be either located in the base folder of the application or at a
location specified with the environment variable: SONAR_PLUGIN_INSPECTCODE_OVERRIDEFILE=C:\config\my-sonar-inspectcode-rule-override.xml
.
The following command can be used to dump the rules into an XML file that is used by this plugin.
inspectcode.exe --dumpIssuesTypes --output="inspectcode_issue_definitions.xml" --no-buildin-settings
After dumping the new ruleset, it is mandatory to check all the new rules and adjust the sonarqube_rule_overrides.xml
accordingly, to account for any rules that should be categorized differently by default.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.