SonarQube Plugins
  1. SonarQube Plugins
  2. SONARPLUGINS-3406

Rule keys are incorrectly formatted (can't include colons)

    Details

    • Number of attachments :
      0

      Description

      see http://sonarqube.15.x6.nabble.com/sonar-dev-VOTE-Release-sonar-dotnet-resharper-v1-0-td5020132.html#a5020929

      Rule keys with embedded semicolons cannot be parsed by the Issues Report plugin – or more specifically, the sonar v3.6+ org.sonar.api.rule.RuleKey's parse() method.

      There are many rules in the R# ruleset that include colons. These will need to be changed to remove the colons, keeping the following in mind:

      • rules are generated from the DefaultRules.ReSharper resource file. This file is generated from the R# tool itself (with one additional rule added) and for maintainability with future R# releases, should continue to have the raw output (ie: including the colons)
      • the ReSharperRuleRepository class consumes the DefaultRules file to populate the plugin's rules in SonarQube (see createRules() method).
      • the ReSharperProfileImporter class parses "exported" profile files, and is used by the ReSharperSonarWayProfile class to parse the DefaultRule file and populate the SonarWay profile.
      • the ReSharperProfileExporter class exports the profile (for consumption by ProfileRuleImporter)
      • users can provide their own rules (for use with custom R# plugins) using the "sonar.resharper.customRules.definition" property key (exposed via the settings web UI). This is consumed in the ReSharperRuleRepository.createRules() method
      • the ReSharperResultsParser (which parses the inspectcode output) must be able to map the R# keys in the file to the colon-free versions in the SonarQube rules. These are used in the inner class MissingIssueTypeHelper.setIssueTypes
      • The values logged from ReSharperResultParser.logMissingIssues() are intended to be copy/pasted into the "sonar.resharper.customRules.definition" property, so should include the R# rule key (with colons).

      There is a helper class ReSharperRule which may be the best place to do the colon escaping/mapping. It isn't used everywhere currently, so additional refactorings would be needed.

      When parsing the results file, you may find this guide helpful: http://www.wrightfully.com/parsing-resharper-inspectcode-results/

      Specifically, when parsing the IssueTypes block, the rule key is in the attribute "Id". When parsing the Issues block, the rule key is in the "TypeId" attribute.

        Activity

        Hide
        John Wright added a comment -

        Resolved by community member Peter Stevens.

        https://github.com/SonarCommunity/sonar-dotnet-resharper/commit/2a5235ba5fde3bb83da9ae354fbd24994e1bab1b

        NOTE: Has implications for existing users!
        Rule keys for all rules using "::" will change, so new rules will need to be enabled in quality profiles and any customizations will be lost.

        Show
        John Wright added a comment - Resolved by community member Peter Stevens. https://github.com/SonarCommunity/sonar-dotnet-resharper/commit/2a5235ba5fde3bb83da9ae354fbd24994e1bab1b NOTE: Has implications for existing users! Rule keys for all rules using "::" will change, so new rules will need to be enabled in quality profiles and any customizations will be lost.

          People

          • Assignee:
            John Wright
            Reporter:
            John Wright
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: