/resharper-clt-plugin

SonarQube plugin for ReSharper command line tools.

Primary LanguageJavaApache License 2.0Apache-2.0

Build Status

SonarQube ReSharper CLT Plugin

A SonarQube plugin for the ReSharper Command Line Tools.

Description

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.

Properties declared/used by this plugin

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)

How to use

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.

  1. Install the ReSharper Command Line Tools plugin (see Installing a Plugin - SonarQube Documentation - Doc SonarQube for more details)
  2. Enable at least one of the rules provided by the plugin in your quality profile (see Quality Profiles for more details)
  3. Open a command prompt, preferably the Developer Command prompt for Visual Studio
  4. Navigate to the root folder of the project/solution you want to build
  5. Execute the following steps:
    1. 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%"
    2. Build the project
      msbuild.exe "%SOLUTION_FILE"
    3. Run ReSharper Command Line Tool InspectCode.exe
      inspectcode.exe /output="resharper.xml" "%SOLUTION_FILE%"
    4. End the SonarQube analysis, which will upload the issues to the server
      SonarScanner.MSBuild.exe end /d:sonar.login=%SONAR_LOGIN_TOKEN%

Configuration

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.

Updating the plugin for a new ReSharper version

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.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.