Search in sources :

Example 1 with Builder

use of org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.Builder in project sonarqube by SonarSource.

the class CoveragePublisher method publish.

@Override
public void publish(ScannerReportWriter writer) {
    for (final DefaultInputFile inputFile : componentStore.allFilesToPublish()) {
        Map<Integer, LineCoverage.Builder> coveragePerLine = new LinkedHashMap<>();
        int lineCount = inputFile.lines();
        applyLineMeasure(inputFile.key(), lineCount, CoreMetrics.COVERAGE_LINE_HITS_DATA_KEY, coveragePerLine, (value, builder) -> builder.setHits(Integer.parseInt(value) > 0));
        applyLineMeasure(inputFile.key(), lineCount, CoreMetrics.CONDITIONS_BY_LINE_KEY, coveragePerLine, (value, builder) -> builder.setConditions(Integer.parseInt(value)));
        applyLineMeasure(inputFile.key(), lineCount, CoreMetrics.COVERED_CONDITIONS_BY_LINE_KEY, coveragePerLine, (value, builder) -> builder.setCoveredConditions(Integer.parseInt(value)));
        writer.writeComponentCoverage(inputFile.batchId(), Iterables.transform(coveragePerLine.values(), BuildCoverage.INSTANCE));
    }
}
Also used : DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) Builder(org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.Builder) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)1 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)1 Builder (org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.Builder)1