Skip to content

Commit

Permalink
Append coverage data of all modules to one file (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janos Gyerik committed Mar 22, 2017
1 parent a32f8bb commit 096f5a9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 30 deletions.
2 changes: 1 addition & 1 deletion build.ps1
Expand Up @@ -62,7 +62,7 @@ if ($env:GITHUB_BRANCH -eq 'master' -and $env:IS_PULLREQUEST -eq "false")
set_maven_build_version $env:BUILD_NUMBER

$env:MAVEN_OPTS="-Xmx1536m -Xms128m"

mvn org.jacoco:jacoco-maven-plugin:prepare-agent deploy sonar:sonar `
"-Pcoverage-per-test,deploy-sonarsource,release,sonaranalyzer" `
"-Dmaven.test.redirectTestOutputToFile=false" `
Expand Down
22 changes: 14 additions & 8 deletions pom.xml
Expand Up @@ -78,15 +78,21 @@
<gitRepositoryName>sonar-csharp</gitRepositoryName>
<!-- Release: enable publication to Bintray -->
<artifactsToPublish>${project.groupId}:${project.artifactId}:jar</artifactsToPublish>
<sonar.jacoco.reportPaths>../target/jacoco.exec</sonar.jacoco.reportPaths>
</properties>

<profiles>
<profile>
<id>sonaranalyzer</id>
<modules>
<module>sonaranalyzer-dotnet</module>
</modules>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<configuration>
<append>true</append>
<destFile>../target/jacoco.exec</destFile>
</configuration>
</plugin>
</plugins>
</build>

</project>
Expand Up @@ -19,14 +19,10 @@
*/
package org.sonarsource.dotnet.shared.plugins;

import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Map;
import java.util.function.Predicate;
import java.util.stream.StreamSupport;

import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
Expand Down Expand Up @@ -72,7 +68,6 @@ protected static Path toolInput(FileSystem fs) {
}

public void importResults(SensorContext context, Path protobufReportsDirectory, boolean importIssues) {

Predicate<InputFile> inputFileFilter;
if (!config.isReportsComingFromMSBuild()) {
// Filter was not executed during FS indexing because protobuf reports were not present (MSBuild 12 or old scanner)
Expand Down Expand Up @@ -102,22 +97,6 @@ private static void parseProtobuf(RawProtobufImporter<?> importer, Path workDire
}
}

public static boolean areProtobufAnalysisFilesPresent(Path analyzerOutputDir) {
if (!Files.exists(analyzerOutputDir)) {
LOG.info("Analyzer working directory does not exist");
return true;
}

try (DirectoryStream<Path> files = Files.newDirectoryStream(analyzerOutputDir, p -> p.toAbsolutePath().toString().toLowerCase().endsWith(".pb"))) {
long count = StreamSupport.stream(files.spliterator(), false).count();
LOG.info("Analyzer working directory contains " + count + " .pb file(s)");
return count == 0;
} catch (IOException e) {
LOG.warn("Could not check for .pb files in " + analyzerOutputDir.toAbsolutePath().toString(), e);
return true;
}
}

protected static final class SarifParserCallbackImplementation implements SarifParserCallback {
private final SensorContext context;
private final Map<String, String> repositoryKeyByRoslynRuleKey;
Expand Down

0 comments on commit 096f5a9

Please sign in to comment.