From 1ea4266358d9520466d0ea5afdc3dd4469af8601 Mon Sep 17 00:00:00 2001 From: Roman Ivanov Date: Tue, 27 Dec 2016 15:16:20 -0800 Subject: [PATCH] Issue #52: checkstyle-sonar-plugin does not work with sonar 4.5.2 and 4.5.4 require upgrade to 5.6.4 --- checkstyle-sonar-plugin/pom.xml | 41 ++++++++++++++++--- .../checkstyle/CheckstyleProfileExporter.java | 6 ++- .../CheckstyleAuditListenerTest.java | 4 +- .../CheckstyleConfigurationTest.java | 7 ++-- .../checkstyle/CheckstyleSensorTest.java | 4 +- pom.xml | 2 +- 6 files changed, 49 insertions(+), 15 deletions(-) diff --git a/checkstyle-sonar-plugin/pom.xml b/checkstyle-sonar-plugin/pom.xml index 511ab40e..c5a7f395 100644 --- a/checkstyle-sonar-plugin/pom.xml +++ b/checkstyle-sonar-plugin/pom.xml @@ -22,7 +22,7 @@ - org.codehaus.sonar + org.sonarsource.sonarqube sonar-plugin-api provided ${sonar.version} @@ -34,12 +34,42 @@ sonar-plugin ${sonar-java.version} provided + + + + org.codehaus.sonar + sonar-plugin-api + + org.sonarsource.sslr-squid-bridge sslr-squid-bridge 2.6.1 + + + + org.codehaus.sonar + sonar-plugin-api + + + org.codehaus.sonar + sonar-colorizer + + + + + + commons-io + commons-io + 2.5 + + + + commons-lang + commons-lang + 2.6 ${project.groupId} @@ -55,7 +85,7 @@ - org.codehaus.sonar + org.sonarsource.sonarqube sonar-plugin-api ${sonar.version} test-jar @@ -80,7 +110,7 @@ - org.codehaus.sonar + org.sonarsource.sonarqube sonar-testing-harness test ${sonar.version} @@ -96,7 +126,8 @@ org.slf4j slf4j-nop - 1.7.22 + + 1.5.6 test @@ -298,7 +329,7 @@ org.sonar.plugins.checkstyle.CheckstyleProfileExporter - 88 + 86 97 diff --git a/checkstyle-sonar-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporter.java b/checkstyle-sonar-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporter.java index b02d0de3..97e43671 100644 --- a/checkstyle-sonar-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporter.java +++ b/checkstyle-sonar-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporter.java @@ -116,7 +116,11 @@ private void appendTreeWalker(Writer writer, ListMultimap ac private boolean isSuppressWarningsEnabled() { String filtersXml = settings.getString(CheckstyleConstants.FILTERS_KEY); - return filtersXml.contains(""); + boolean result = false; + if (filtersXml != null) { + result = filtersXml.contains(""); + } + return result; } private static void appendXmlFooter(Writer writer) throws IOException { diff --git a/checkstyle-sonar-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleAuditListenerTest.java b/checkstyle-sonar-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleAuditListenerTest.java index 65e355cc..7f37e940 100644 --- a/checkstyle-sonar-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleAuditListenerTest.java +++ b/checkstyle-sonar-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleAuditListenerTest.java @@ -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); } diff --git a/checkstyle-sonar-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java b/checkstyle-sonar-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java index 2fca8d33..ce19ae40 100644 --- a/checkstyle-sonar-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java +++ b/checkstyle-sonar-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java @@ -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); diff --git a/checkstyle-sonar-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleSensorTest.java b/checkstyle-sonar-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleSensorTest.java index 6c476a0d..85fc0fd8 100644 --- a/checkstyle-sonar-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleSensorTest.java +++ b/checkstyle-sonar-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleSensorTest.java @@ -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() { diff --git a/pom.xml b/pom.xml index b62f8240..3a512866 100644 --- a/pom.xml +++ b/pom.xml @@ -86,7 +86,7 @@ 7.3 - 4.5.4 + 5.6.4 3.7 1.8 UTF-8