Search in sources :

Example 1 with CoverageMeasures

use of org.sonar.cxx.sensors.coverage.CoverageMeasures in project sonar-cxx by SonarOpenCommunity.

the class VisualStudioParser method collectSourceFileMeasures.

private static void collectSourceFileMeasures(SMInputCursor sourceFiles, Map<String, CoverageMeasures> coverageData) throws XMLStreamException {
    SMInputCursor sourceFile = sourceFiles.childElementCursor("source_file");
    while (sourceFile.getNext() != null) {
        String id = sourceFile.getAttrValue("id");
        CoverageMeasures builder = coverageData.remove(id);
        if (builder == null) {
            builder = CoverageMeasures.create();
        }
        // replace id with path
        coverageData.put(sourceFile.getAttrValue("path"), builder);
    }
}
Also used : CoverageMeasures(org.sonar.cxx.sensors.coverage.CoverageMeasures) SMInputCursor(org.codehaus.staxmate.in.SMInputCursor)

Example 2 with CoverageMeasures

use of org.sonar.cxx.sensors.coverage.CoverageMeasures in project sonar-cxx by SonarOpenCommunity.

the class VisualStudioParser method collectRangeMeasures.

private static void collectRangeMeasures(SMInputCursor function, Map<String, CoverageMeasures> coverageData) throws XMLStreamException {
    SMInputCursor range = function.childElementCursor("ranges").advance().childElementCursor("range");
    CoverageMeasures builder = null;
    var lastSourceId = "";
    while (range.getNext() != null) {
        String sourceId = range.getAttrValue("source_id");
        var startLine = Integer.parseInt(range.getAttrValue("start_line"));
        var endLine = Integer.parseInt(range.getAttrValue("end_line"));
        // value: yes/no/partial
        int covered = !"no".equalsIgnoreCase(range.getAttrValue("covered")) ? 1 : 0;
        if (!sourceId.equals(lastSourceId) || builder == null) {
            builder = coverageData.get(sourceId);
            if (builder == null) {
                builder = CoverageMeasures.create();
                coverageData.put(sourceId, builder);
            }
            lastSourceId = sourceId;
        }
        while (startLine <= endLine) {
            builder.setHits(startLine, covered);
            startLine++;
        }
    }
}
Also used : CoverageMeasures(org.sonar.cxx.sensors.coverage.CoverageMeasures) SMInputCursor(org.codehaus.staxmate.in.SMInputCursor)

Example 3 with CoverageMeasures

use of org.sonar.cxx.sensors.coverage.CoverageMeasures in project sonar-cxx by SonarOpenCommunity.

the class CoberturaParser method collectFileMeasures.

private void collectFileMeasures(SMInputCursor clazz, Map<String, CoverageMeasures> coverageData) throws XMLStreamException {
    while (clazz.getNext() != null) {
        String normalPath = join(baseDir, Paths.get(clazz.getAttrValue("filename")));
        if (!normalPath.isEmpty()) {
            CoverageMeasures builder = coverageData.get(normalPath);
            if (builder == null) {
                builder = CoverageMeasures.create();
                coverageData.put(normalPath, builder);
            }
            collectFileData(clazz, builder);
        }
    }
}
Also used : CoverageMeasures(org.sonar.cxx.sensors.coverage.CoverageMeasures)

Aggregations

CoverageMeasures (org.sonar.cxx.sensors.coverage.CoverageMeasures)3 SMInputCursor (org.codehaus.staxmate.in.SMInputCursor)2