Skip to content

Commit

Permalink
Merge pull request #4 from Soloplan/development
Browse files Browse the repository at this point in the history
 Update inspectcode rules to 2018.3.4
  • Loading branch information
steffen-wilke authored Mar 6, 2019
2 parents d868026 + bd16ea2 commit 1846c45
Show file tree
Hide file tree
Showing 5 changed files with 2,163 additions and 2,075 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@
<organization>Soloplan GmbH</organization>
<organizationUrl>https://www.soloplan.com</organizationUrl>
</developer>
<developer>
<id>steffen-wilke</id>
<name>Steffen Wilke</name>
<url>https://www.github.com/steffen-wilke</url>
<email>mail@steffen.wilke.com</email>
<organization>Soloplan GmbH</organization>
<organizationUrl>https://www.soloplan.com</organizationUrl>
</developer>
</developers>
<scm>
<connection>scm:git:git@github.com:Soloplan/resharper-clt-plugin.git</connection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -227,8 +225,13 @@ private Collection<SonarQubeRuleDefinitionModel> parseInspectCodeIssueDefinition
* @return A {@link Collection} of {@link SonarQubeRuleDefinitionOverrideModel} instances parsed from the XML resource file.
*/
private Collection<SonarQubeRuleDefinitionOverrideModel> 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<SonarQubeRuleDefinitionOverrideModel> sonarQubeRuleDefinitionOverrides = Collections.emptyList();
Expand All @@ -237,9 +240,14 @@ private Collection<SonarQubeRuleDefinitionOverrideModel> 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 {
Expand Down
Loading

0 comments on commit 1846c45

Please sign in to comment.