From 62e193a5fa76af62bfc2f491f05a729981e3c9fd Mon Sep 17 00:00:00 2001 From: Steffen Wilke Date: Wed, 6 Mar 2019 13:53:53 +0100 Subject: [PATCH 1/4] Allow rule override with an external config file. With this change, it's possible to specify an environment variable (SONAR_PLUGIN_INSPECTCODE_OVERRIDEFILE) that defines where the plugin can find the configuration: "sonarqube-rule-overrides.xml". As fallback, the plugin searches withing the application root directory. --- README.md | 4 ++++ .../clt/rules/BaseRulesDefinition.java | 24 ++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 020626a..0e68c8c 100644 --- a/README.md +++ b/README.md @@ -33,5 +33,9 @@ A more in-depth guide on how to analyze projects that are built using MSBuild ca 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`. + ## License This project is licensed under the Apache License 2.0 - see the [LICENSE](./LICENSE) file for details. diff --git a/src/main/java/com/soloplan/oss/sonarqube/plugin/resharper/clt/rules/BaseRulesDefinition.java b/src/main/java/com/soloplan/oss/sonarqube/plugin/resharper/clt/rules/BaseRulesDefinition.java index 0814a54..11840e1 100644 --- a/src/main/java/com/soloplan/oss/sonarqube/plugin/resharper/clt/rules/BaseRulesDefinition.java +++ b/src/main/java/com/soloplan/oss/sonarqube/plugin/resharper/clt/rules/BaseRulesDefinition.java @@ -38,9 +38,7 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.util.Collection; import java.util.Collections; import java.util.Map; @@ -227,8 +225,13 @@ private Collection parseInspectCodeIssueDefinition * @return A {@link Collection} of {@link SonarQubeRuleDefinitionOverrideModel} instances parsed from the XML resource file. */ private Collection parseSonarQubeRuleDefinitionOverrides() { - // TODO: Replace this with something more configurable - final String resourceName = "/com/jetbrains/resharper/inspectcode/sonarqube_rule_overrides.xml"; + final String overrideFileName = "sonarqube_rule_overrides.xml"; + + // the override file is either located directly in the application folder or at a path that is specified as environment variable + // SONAR_PLUGIN_INSPECTCODE_OVERRIDEFILE + String envPath = System.getenv("SONAR_PLUGIN_INSPECTCODE_OVERRIDEFILE"); + final String localOverrideFile = envPath != null ? envPath : overrideFileName; + final String resourceName = "/com/jetbrains/resharper/inspectcode/" + overrideFileName; // Initialize the resulting variable so it won't be null Collection sonarQubeRuleDefinitionOverrides = Collections.emptyList(); @@ -237,9 +240,14 @@ private Collection parseSonarQubeRuleDefin InputStream inputStream = null; //noinspection TryFinallyCanBeTryWithResources (See comment line above) try { - // Retrieve the XML file resource to parse - inputStream = this.getClass().getResourceAsStream(resourceName); - + // if a local override file exists: use it, otherwise use the default one from the plugin + final File overrideFile = new File(localOverrideFile); + if(overrideFile.exists()){ + inputStream = new FileInputStream(overrideFile.getAbsolutePath()); + }else { + // Retrieve the XML file resource to parse + inputStream = this.getClass().getResourceAsStream(resourceName); + } if (inputStream == null) { this.logger.error("Could not find resource '%s'.", resourceName); } else { From 39ceaa85b591c08c34ea25dc6eeae08dab9f7c02 Mon Sep 17 00:00:00 2001 From: Steffen Wilke Date: Wed, 6 Mar 2019 13:56:50 +0100 Subject: [PATCH 2/4] Update inspectcode rules to 2018.3.4 Update default rule overrides to better reflect the actual severity of certain rules. --- pom.xml | 8 + .../inspectcode_issue_definitions.xml | 4185 +++++++++-------- .../inspectcode/sonarqube_rule_overrides.xml | 17 +- 3 files changed, 2143 insertions(+), 2067 deletions(-) diff --git a/pom.xml b/pom.xml index a9e2b64..f06f30c 100644 --- a/pom.xml +++ b/pom.xml @@ -52,6 +52,14 @@ Soloplan GmbH https://www.soloplan.com + + steffen-wilke + Steffen Wilke + https://www.github.com/steffen-wilke + mail@steffen.wilke.com + Soloplan GmbH + https://www.soloplan.com + scm:git:git@github.com:Soloplan/resharper-clt-plugin.git diff --git a/src/main/resources/com/jetbrains/resharper/inspectcode/inspectcode_issue_definitions.xml b/src/main/resources/com/jetbrains/resharper/inspectcode/inspectcode_issue_definitions.xml index f62df7c..cde285c 100644 --- a/src/main/resources/com/jetbrains/resharper/inspectcode/inspectcode_issue_definitions.xml +++ b/src/main/resources/com/jetbrains/resharper/inspectcode/inspectcode_issue_definitions.xml @@ -1,2064 +1,2123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/com/jetbrains/resharper/inspectcode/sonarqube_rule_overrides.xml b/src/main/resources/com/jetbrains/resharper/inspectcode/sonarqube_rule_overrides.xml index ee719d9..dcdbb5b 100644 --- a/src/main/resources/com/jetbrains/resharper/inspectcode/sonarqube_rule_overrides.xml +++ b/src/main/resources/com/jetbrains/resharper/inspectcode/sonarqube_rule_overrides.xml @@ -14,9 +14,18 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - + + + + + + + + + + + + + \ No newline at end of file From aabeadac55e116ceae52609ac8261703488209e7 Mon Sep 17 00:00:00 2001 From: Soloplan Build <47182057+solobuild@users.noreply.github.com> Date: Wed, 6 Mar 2019 11:17:13 +0100 Subject: [PATCH 3/4] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f06f30c..44f0a1e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.soloplan.oss.sonarqube.plugin.resharper.clt resharper-clt-plugin sonar-plugin - 1.0.0-RC3 + 1.0.0-RC1 ReSharper command line tools plugin for SonarQube 6.7.x LTS Enables the use of ReSharper command line tools with rules on C# and VB.NET code. From bd16ea29a9aaac9c77aa4ff6aea1b216a01778dc Mon Sep 17 00:00:00 2001 From: Steffen Wilke Date: Wed, 6 Mar 2019 13:58:42 +0100 Subject: [PATCH 4/4] Bump version to 1.0.0-RC3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 44f0a1e..f06f30c 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.soloplan.oss.sonarqube.plugin.resharper.clt resharper-clt-plugin sonar-plugin - 1.0.0-RC1 + 1.0.0-RC3 ReSharper command line tools plugin for SonarQube 6.7.x LTS Enables the use of ReSharper command line tools with rules on C# and VB.NET code.