Skip to content

Commit

Permalink
Issue #52: checkstyle-sonar-plugin does not work with sonar 4.5.2 and…
Browse files Browse the repository at this point in the history
… 4.5.4 require upgrade to 5.6.4
  • Loading branch information
romani committed Dec 27, 2016
1 parent 5a15fe3 commit 1ea4266
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 15 deletions.
41 changes: 36 additions & 5 deletions checkstyle-sonar-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<dependencies>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api</artifactId>
<scope>provided</scope>
<version>${sonar.version}</version>
Expand All @@ -34,12 +34,42 @@
<type>sonar-plugin</type>
<version>${sonar-java.version}</version>
<scope>provided</scope>
<!-- to avoid 4.5.1 api pickup -->
<exclusions>
<exclusion>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-plugin-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- required to load external descriptiona, see CheckstyleRulesDefinition -->
<dependency>
<groupId>org.sonarsource.sslr-squid-bridge</groupId>
<artifactId>sslr-squid-bridge</artifactId>
<version>2.6.1</version>
<!-- to avoid 4.5.1 api pickup -->
<exclusions>
<exclusion>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-plugin-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-colorizer</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<!-- required during runtime, by sonar 5.6.4 -->
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<!-- required during runtime, by sonar 5.6.4 -->
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
Expand All @@ -55,7 +85,7 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>${sonar.version}</version>
<type>test-jar</type>
Expand All @@ -80,7 +110,7 @@
</dependency>

<dependency>
<groupId>org.codehaus.sonar</groupId>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-testing-harness</artifactId>
<scope>test</scope>
<version>${sonar.version}</version>
Expand All @@ -96,7 +126,8 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.22</version>
<!-- 1.5.6(old) version is requied due to sonar 5.6.4 dependency tree -->
<version>1.5.6</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -298,7 +329,7 @@
</regex>
<regex>
<pattern>org.sonar.plugins.checkstyle.CheckstyleProfileExporter</pattern>
<branchRate>88</branchRate>
<branchRate>86</branchRate>
<lineRate>97</lineRate>
</regex>
<regex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ private void appendTreeWalker(Writer writer, ListMultimap<String, ActiveRule> ac

private boolean isSuppressWarningsEnabled() {
String filtersXml = settings.getString(CheckstyleConstants.FILTERS_KEY);
return filtersXml.contains("<module name=\"SuppressWarningsFilter\" />");
boolean result = false;
if (filtersXml != null) {
result = filtersXml.contains("<module name=\"SuppressWarningsFilter\" />");
}
return result;
}

private static void appendXmlFooter(Writer writer) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public class CheckstyleAuditListenerTest {
new AuditEvent(this, file.getAbsolutePath(), new LocalizedMessage(42, "", "", null, "", CheckstyleAuditListenerTest.class, "msg"));
private DefaultFileSystem fs = new DefaultFileSystem(new File(""));
private RuleFinder ruleFinder = mock(RuleFinder.class);
private DefaultInputFile inputFile = new DefaultInputFile(file.getPath());
private DefaultInputFile inputFile = new DefaultInputFile("", file.getPath());
private ResourcePerspectives perspectives = mock(ResourcePerspectives.class);

@Before
public void before() {
inputFile.setAbsolutePath(file.getAbsolutePath());
//inputFile.setAbsolutePath(file.getAbsolutePath());
fs.add(inputFile);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ public class CheckstyleConfigurationTest {
@Before
public void beforeClass() {
fileSystem = new DefaultFileSystem(new File(""));
DefaultInputFile inputFile = new DefaultInputFile("mainFile");
inputFile.setAbsolutePath("mainFile");
fileSystem.setWorkDir(new File(""));
DefaultInputFile inputFile = new DefaultInputFile("", "mainFile");
inputFile.setLanguage("java");
inputFile.setType(InputFile.Type.MAIN);
fileSystem.add(inputFile);
DefaultInputFile testFile = new DefaultInputFile("testFile");
testFile.setAbsolutePath("testFile");
DefaultInputFile testFile = new DefaultInputFile("", "testFile");
testFile.setLanguage("java");
testFile.setType(InputFile.Type.TEST);
fileSystem.add(testFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public void testToString() {

private void addOneJavaFile() {
File file = new File("MyClass.java");
fileSystem.add(new DefaultInputFile(
file.getName()).setAbsolutePath(file.getAbsolutePath()).setLanguage("java").setType(Type.MAIN));
fileSystem.add(new DefaultInputFile("", file.getName())
.setLanguage("java").setType(Type.MAIN));
}

private void addOneActiveRule() {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

<properties>
<checkstyle.version>7.3</checkstyle.version>
<sonar.version>4.5.4</sonar.version>
<sonar.version>5.6.4</sonar.version>
<sonar-java.version>3.7</sonar-java.version>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down

0 comments on commit 1ea4266

Please sign in to comment.