@Override public boolean equals(final Object obj) { if (obj instanceof ILine) { final ILine that = (ILine) obj; return this.instructions.equals(that.getInstructionCounter()) && this.branches.equals(that.getBranchCounter()); } return false; }
private void printLine(final ILine line, final int nr, final String indent) { if (line.getStatus() != ICounter.EMPTY) { out.printf("%6s %6s %s +- line %s%n", total(line.getInstructionCounter()), total(line.getBranchCounter()), indent, Integer.valueOf(nr)); } }
public void printHighlightedSrcFile(ISourceNode cov, Writer output) { try { StringBuilder buf = new StringBuilder(); List<String> sourceLines; try { sourceLines = readLines(); } catch (IOException e) { e.printStackTrace(); output.write("ERROR: Error while reading the sourcefile!"); return; } output.write("<code style=\"white-space:pre;\">"); for (int i = 1; i <= sourceLines.size(); ++i) { buf.setLength(0); ILine line = cov.getLine(i); ICounter branches = line.getBranchCounter(); int status = line.getStatus(); if (status != ICounter.EMPTY) { printHighlightedLine(buf, i, branches, sourceLines.get(i - 1), status); } else { buf.append(i).append(": ").append(sourceLines.get(i - 1)).append("<br>"); } output.write(buf.toString()); } output.write("</code>"); //logger.log(Level.INFO, "lines: " + buf); } catch (IOException e) { throw new RuntimeException(e); } }
private static List<Integer> coveredLines(ISourceFileCoverage coverage) { List<Integer> coveredLines = new ArrayList<>(); for (int lineId = coverage.getFirstLine(); lineId <= coverage.getLastLine(); lineId++) { ILine line = coverage.getLine(lineId); switch (line.getInstructionCounter().getStatus()) { case ICounter.FULLY_COVERED: case ICounter.PARTLY_COVERED: coveredLines.add(lineId); break; case ICounter.NOT_COVERED: break; default: continue; } } return coveredLines; }
private static void writeLines(final ISourceNode source, final ReportElement parent) throws IOException { final int last = source.getLastLine(); for (int nr = source.getFirstLine(); nr <= last; nr++) { final ILine line = source.getLine(nr); if (line.getStatus() != ICounter.EMPTY) { parent.line(nr, line); } } }
HTMLElement highlight(final HTMLElement pre, final ILine line, final int lineNr) throws IOException { final String style; switch (line.getStatus()) { case ICounter.NOT_COVERED: style = Styles.NOT_COVERED; final ICounter branches = line.getBranchCounter(); switch (branches.getStatus()) { case ICounter.NOT_COVERED:
/** * Creates a 'line' element. * * @param nr * line number * @param line * line object to write out * * @throws IOException * in case of problems with the underlying output */ public void line(final int nr, final ILine line) throws IOException { final ReportElement element = element("line"); element.attr("nr", nr); counterAttributes(element, "mi", "ci", line.getInstructionCounter()); counterAttributes(element, "mb", "cb", line.getBranchCounter()); }
private static CoverageMeasuresBuilder analyzeFile(Resource resource, ISourceFileCoverage coverage) { CoverageMeasuresBuilder builder = CoverageMeasuresBuilder.create(); for (int lineId = coverage.getFirstLine(); lineId <= coverage.getLastLine(); lineId++) { final int hits; ILine line = coverage.getLine(lineId); switch (line.getInstructionCounter().getStatus()) { case ICounter.FULLY_COVERED: case ICounter.PARTLY_COVERED: hits = 1; break; case ICounter.NOT_COVERED: hits = 0; break; case ICounter.EMPTY: continue; default: JaCoCoScalaExtensions.LOG.warn("Unknown status for line {} in {}", lineId, resource); continue; } builder.setHits(lineId, hits); ICounter branchCounter = line.getBranchCounter(); int conditions = branchCounter.getTotalCount(); if (conditions > 0) { int coveredConditions = branchCounter.getCoveredCount(); builder.setConditions(lineId, conditions, coveredConditions); } } return builder; }
private CoverageMeasuresBuilder analyzeFile(Resource resource, ISourceFileCoverage coverage) { CoverageMeasuresBuilder builder = CoverageMeasuresBuilder.create(); for (int lineId = coverage.getFirstLine(); lineId <= coverage.getLastLine(); lineId++) { final int hits; ILine line = coverage.getLine(lineId); switch (line.getInstructionCounter().getStatus()) { case ICounter.FULLY_COVERED: case ICounter.PARTLY_COVERED: hits = 1; break; case ICounter.NOT_COVERED: hits = 0; break; case ICounter.EMPTY: continue; default: JaCoCoUtils.LOG.warn("Unknown status for line {} in {}", lineId, resource); continue; } builder.setHits(lineId, hits); ICounter branchCounter = line.getBranchCounter(); int conditions = branchCounter.getTotalCount(); if (conditions > 0) { int coveredConditions = branchCounter.getCoveredCount(); builder.setConditions(lineId, conditions, coveredConditions); } } return builder; }
private CoverageMeasuresBuilder analyzeFile(Resource resource, ISourceFileCoverage coverage) { CoverageMeasuresBuilder builder = CoverageMeasuresBuilder.create(); for (int lineId = coverage.getFirstLine(); lineId <= coverage.getLastLine(); lineId++) { final int hits; ILine line = coverage.getLine(lineId); switch (line.getInstructionCounter().getStatus()) { case ICounter.FULLY_COVERED: case ICounter.PARTLY_COVERED: hits = 1; break; case ICounter.NOT_COVERED: hits = 0; break; case ICounter.EMPTY: continue; default: JaCoCoExtensions.LOG.warn("Unknown status for line {} in {}", lineId, resource); continue; } builder.setHits(lineId, hits); ICounter branchCounter = line.getBranchCounter(); int conditions = branchCounter.getTotalCount(); if (conditions > 0) { int coveredConditions = branchCounter.getCoveredCount(); builder.setConditions(lineId, conditions, coveredConditions); } } return builder; }
private static void analyzeFile(NewCoverage newCoverage, InputFile resource, ISourceFileCoverage coverage) { for (int lineId = coverage.getFirstLine(); lineId <= coverage.getLastLine(); lineId++) { final int hits; ILine line = coverage.getLine(lineId); switch (line.getInstructionCounter().getStatus()) { case ICounter.FULLY_COVERED: case ICounter.PARTLY_COVERED: hits = 1; break; case ICounter.NOT_COVERED: hits = 0; break; case ICounter.EMPTY: continue; default: JaCoCoExtensions.LOG.warn("Unknown status for line {} in {}", lineId, resource); continue; } newCoverage.lineHits(lineId, hits); ICounter branchCounter = line.getBranchCounter(); int conditions = branchCounter.getTotalCount(); if (conditions > 0) { int coveredConditions = branchCounter.getCoveredCount(); newCoverage.conditions(lineId, conditions, coveredConditions); } } } }
ILine line = coverage.getLine(lineId); boolean ignore = false; switch (line.getInstructionCounter().getStatus()) { case ICounter.FULLY_COVERED: case ICounter.PARTLY_COVERED: ICounter branchCounter = line.getBranchCounter(); int conditions = branchCounter.getTotalCount(); if (conditions > 0) {
/** * Increments all counters by the values of the given child. When * incrementing the line counter it is assumed that the child refers to the * same source file. * * @param child * child node to add */ public void increment(final ISourceNode child) { instructionCounter = instructionCounter.increment(child .getInstructionCounter()); branchCounter = branchCounter.increment(child.getBranchCounter()); complexityCounter = complexityCounter.increment(child .getComplexityCounter()); methodCounter = methodCounter.increment(child.getMethodCounter()); classCounter = classCounter.increment(child.getClassCounter()); final int firstLine = child.getFirstLine(); if (firstLine != UNKNOWN_LINE) { final int lastLine = child.getLastLine(); ensureCapacity(firstLine, lastLine); for (int i = firstLine; i <= lastLine; i++) { final ILine line = child.getLine(i); incrementLine(line.getInstructionCounter(), line.getBranchCounter(), i); } } }