Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sonar 9 #300

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion commons/pom.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>backelite-swift</artifactId>
<groupId>com.backelite.sonarqube</groupId>
<version>0.4.7-SNAPSHOT</version>
<version>0.4.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -95,6 +95,12 @@
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.sonarsource.java</groupId>
<artifactId>sonar-java-plugin</artifactId>
<version>${sonar-java.version}</version>
<scope>compile</scope>
</dependency>

</dependencies>

Expand Down
33 changes: 3 additions & 30 deletions commons/src/main/java/com/backelite/sonarqube/commons/surefire/SurefireReportParser.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,11 @@
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.measure.Metric;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.component.ResourcePerspectives;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Metric;
import org.sonar.api.test.MutableTestPlan;
import org.sonar.api.test.TestCase;
import org.sonar.squidbridge.api.AnalysisException;

import javax.annotation.CheckForNull;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.stream.XMLStreamException;
import java.io.File;
import java.io.IOException;
Expand All @@ -46,21 +41,13 @@

public class SurefireReportParser {
private static final Logger LOGGER = LoggerFactory.getLogger(SurefireReportParser.class);
private static final String TESTSUITE = "testsuite";
private static final String TESTCASE = "testcase";

protected final SensorContext context;
private final DocumentBuilderFactory dbfactory;
private final UnitTestIndex index;
private final ResourcePerspectives perspectives;
private final FileSystem fileSystem;

protected SurefireReportParser(FileSystem fileSystem, ResourcePerspectives perspectives, SensorContext context) {
protected SurefireReportParser(FileSystem fileSystem, SensorContext context) {
this.fileSystem = fileSystem;
this.context = context;
this.perspectives = perspectives;
this.dbfactory = DocumentBuilderFactory.newInstance();
this.index = new UnitTestIndex();
}

public void collect(File reportsDir) {
Expand Down Expand Up @@ -91,7 +78,7 @@ private static void parseFiles(List<File> reports, UnitTestIndex index) {
try {
parser.parse(report);
} catch (XMLStreamException e) {
throw new AnalysisException("Fail to parse the Surefire report: " + report, e);
throw new RuntimeException("Fail to parse the Surefire report: " + report, e);
}
}
}
Expand Down Expand Up @@ -133,20 +120,6 @@ private void save(UnitTestClassReport report, InputFile inputFile, SensorContext
saveMeasure(context, inputFile, CoreMetrics.TEST_ERRORS, report.getErrors());
saveMeasure(context, inputFile, CoreMetrics.TEST_FAILURES, report.getFailures());
saveMeasure(context, inputFile, CoreMetrics.TEST_EXECUTION_TIME, report.getDurationMilliseconds());
saveResults(inputFile, report);
}

protected void saveResults(InputFile testFile, UnitTestClassReport report) {
for (UnitTestResult unitTestResult : report.getResults()) {
MutableTestPlan testPlan = perspectives.as(MutableTestPlan.class, testFile);
if (testPlan != null) {
testPlan.addTestCase(unitTestResult.getName())
.setDurationInMs(Math.max(unitTestResult.getDurationMilliseconds(), 0))
.setStatus(TestCase.Status.of(unitTestResult.getStatus()))
.setMessage(unitTestResult.getMessage())
.setStackTrace(unitTestResult.getStackTrace());
}
}
}

@CheckForNull
Expand Down
11 changes: 2 additions & 9 deletions commons/src/main/java/com/backelite/sonarqube/commons/surefire/SurefireSensor.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,19 @@
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.api.component.ResourcePerspectives;

import java.io.File;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;

public class SurefireSensor implements Sensor {
private static final Logger LOGGER = LoggerFactory.getLogger(SurefireSensor.class);
public static final String REPORT_PATH_KEY = Constants.PROPERTY_PREFIX + ".surefire.junit.reportsPath";
public static final String DEFAULT_REPORT_PATH = "sonar-reports/";

private final SensorContext context;
private final ResourcePerspectives perspectives;
private final FileSystem fileSystem;

public SurefireSensor(FileSystem fileSystem, ResourcePerspectives perspectives, SensorContext context) {
public SurefireSensor(FileSystem fileSystem, SensorContext context) {
this.fileSystem = fileSystem;
this.perspectives = perspectives;
this.context = context;
}

Expand All @@ -62,7 +55,7 @@ public void describe(SensorDescriptor descriptor) {

@Override
public void execute(SensorContext context) {
SurefireReportParser surefireParser = new SurefireReportParser(fileSystem, perspectives, context);
SurefireReportParser surefireParser = new SurefireReportParser(fileSystem, context);
String reportFileName = context.fileSystem().baseDir().getAbsolutePath() + "/"+ reportPath();
File reportsDir = new File(reportFileName);

Expand Down
13 changes: 11 additions & 2 deletions objclang/pom.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>backelite-swift</artifactId>
<groupId>com.backelite.sonarqube</groupId>
<version>0.4.7-SNAPSHOT</version>
<version>0.4.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -37,7 +37,7 @@
<dependency>
<groupId>com.backelite.sonarqube</groupId>
<artifactId>commons</artifactId>
<version>0.4.7-SNAPSHOT</version>
<version>0.4.8</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -99,10 +99,19 @@
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api</artifactId>
</dependency>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api-impl</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.sonarsource.sonarlint.core</groupId>
<artifactId>sonarlint-core</artifactId>
<scope>compile</scope>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public void define(final Context context) {
} catch (IOException e) {
LOGGER.error("Failed to load FauxPas rules", e);
}
SqaleXmlLoader.load(repository, "/com/sonar/sqale/fauxpas-model.xml");
repository.done();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
import org.apache.tools.ant.DirectoryScanner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.api.component.ResourcePerspectives;
import org.sonar.api.config.Settings;

import java.io.File;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void define(Context context) {
} catch (IOException e) {
LOGGER.error("Failed to load OCLint rules", e);
}
SqaleXmlLoader.load(repository, "/com/sonar/sqale/oclint-model.xml");

repository.done();
}

Expand Down

This file was deleted.

16 changes: 14 additions & 2 deletions pom.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

<groupId>com.backelite.sonarqube</groupId>
<artifactId>backelite-swift</artifactId>
<version>0.4.7-SNAPSHOT</version>
<version>0.4.8</version>

<packaging>pom</packaging>

Expand Down Expand Up @@ -96,12 +96,14 @@
<logback.version>1.0.13</logback.version>
<mockito.version>1.9.0</mockito.version>
<slf4j.version>1.7.21</slf4j.version>
<sonar.version>6.7</sonar.version>
<sonar.version>9.1.0.47736</sonar.version>
<sonar-orchestrator.version>3.22.0.1791</sonar-orchestrator.version>
<sonarlint.version>4.0.0.2052</sonarlint.version>
<sslr.version>1.23</sslr.version>
<sslr-squid-bridge.version>2.6.1</sslr-squid-bridge.version>
<ant.version>1.6</ant.version>
<sonar-java.version>6.15.1.26025</sonar-java.version>
<codehaus.version>2.0.1</codehaus.version>

</properties>

Expand Down Expand Up @@ -167,6 +169,16 @@
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api-impl</artifactId>
<version>${sonar.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.staxmate</groupId>
<artifactId>staxmate</artifactId>
<version>${codehaus.version}</version>
</dependency>

<!-- Test dependencies -->
<dependency>
Expand Down
8 changes: 4 additions & 4 deletions sonar-swift-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
<parent>
<groupId>com.backelite.sonarqube</groupId>
<artifactId>backelite-swift</artifactId>
<version>0.4.7-SNAPSHOT</version>
<version>0.4.8</version>
</parent>

<groupId>com.backelite.sonarqube</groupId>
<artifactId>backelite-sonar-swift-plugin</artifactId>
<version>0.4.7-SNAPSHOT</version>
<version>0.4.8</version>

<packaging>sonar-plugin</packaging>

Expand All @@ -40,12 +40,12 @@
<dependency>
<groupId>com.backelite.sonarqube</groupId>
<artifactId>swift-lang</artifactId>
<version>0.4.7-SNAPSHOT</version>
<version>0.4.8</version>
</dependency>
<dependency>
<groupId>com.backelite.sonarqube</groupId>
<artifactId>objc-lang</artifactId>
<version>0.4.7-SNAPSHOT</version>
<version>0.4.8</version>
</dependency>

<dependency>
Expand Down
Loading