Search in sources :

Example 6 with NewCoverage

use of org.sonar.api.batch.sensor.coverage.NewCoverage in project sonarqube by SonarSource.

the class InMemorySensorStorage method store.

@Override
public void store(NewCoverage coverage) {
    DefaultCoverage defaultCoverage = (DefaultCoverage) coverage;
    String fileKey = defaultCoverage.inputFile().key();
    coverageByComponent.computeIfAbsent(fileKey, x -> new ArrayList<>()).add(defaultCoverage);
}
Also used : NewSymbolTable(org.sonar.api.batch.sensor.symbol.NewSymbolTable) Collection(java.util.Collection) DefaultSignificantCode(org.sonar.api.batch.sensor.code.internal.DefaultSignificantCode) Measure(org.sonar.api.batch.sensor.measure.Measure) HashMap(java.util.HashMap) Issue(org.sonar.api.batch.sensor.issue.Issue) ExternalIssue(org.sonar.api.batch.sensor.issue.ExternalIssue) ArrayList(java.util.ArrayList) NewSignificantCode(org.sonar.api.batch.sensor.code.NewSignificantCode) AnalysisError(org.sonar.api.batch.sensor.error.AnalysisError) DefaultCoverage(org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage) List(java.util.List) NewHighlighting(org.sonar.api.batch.sensor.highlighting.NewHighlighting) Preconditions.checkArgument(org.sonar.api.utils.Preconditions.checkArgument) DefaultSymbolTable(org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable) NewCpdTokens(org.sonar.api.batch.sensor.cpd.NewCpdTokens) AdHocRule(org.sonar.api.batch.sensor.rule.AdHocRule) Map(java.util.Map) NewCoverage(org.sonar.api.batch.sensor.coverage.NewCoverage) DefaultHighlighting(org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting) Collections(java.util.Collections) DefaultCpdTokens(org.sonar.api.batch.sensor.cpd.internal.DefaultCpdTokens) ArrayList(java.util.ArrayList) DefaultCoverage(org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage)

Example 7 with NewCoverage

use of org.sonar.api.batch.sensor.coverage.NewCoverage in project sonarqube by SonarSource.

the class ZeroCoverageSensor method storeZeroCoverageForEachExecutableLine.

private static void storeZeroCoverageForEachExecutableLine(final SensorContext context, InputFile f, Set<Integer> executableLines) {
    NewCoverage newCoverage = context.newCoverage().onFile(f);
    for (Integer lineIdx : executableLines) {
        if (lineIdx <= f.lines()) {
            newCoverage.lineHits(lineIdx, 0);
        }
    }
    newCoverage.save();
}
Also used : NewCoverage(org.sonar.api.batch.sensor.coverage.NewCoverage)

Aggregations

NewCoverage (org.sonar.api.batch.sensor.coverage.NewCoverage)7 InputFile (org.sonar.api.batch.fs.InputFile)4 Map (java.util.Map)3 File (java.io.File)2 HashMap (java.util.HashMap)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 SMInputCursor (org.codehaus.staxmate.in.SMInputCursor)1 CoverageBuilder (org.jacoco.core.analysis.CoverageBuilder)1 ISourceFileCoverage (org.jacoco.core.analysis.ISourceFileCoverage)1 FileSystem (org.sonar.api.batch.fs.FileSystem)1 NewSignificantCode (org.sonar.api.batch.sensor.code.NewSignificantCode)1 DefaultSignificantCode (org.sonar.api.batch.sensor.code.internal.DefaultSignificantCode)1 DefaultCoverage (org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage)1 NewCpdTokens (org.sonar.api.batch.sensor.cpd.NewCpdTokens)1 DefaultCpdTokens (org.sonar.api.batch.sensor.cpd.internal.DefaultCpdTokens)1 AnalysisError (org.sonar.api.batch.sensor.error.AnalysisError)1