@Override protected int getValue(final ICounter counter) { return counter.getTotalCount(); } };
@Override public boolean equals(final Object obj) { if (obj instanceof ICounter) { final ICounter that = (ICounter) obj; return this.missed == that.getMissedCount() && this.covered == that.getCoveredCount(); } else { return false; } }
/** * Returns a tooltip for the branch coverage data. * * @param cov * branch coverage data * @return Tooltip if branch coverage data exists for the given line, * otherwise <code>null</code> */ private String getTooltip(ICounter cov) { switch (cov.getStatus()) { case ICounter.FULLY_COVERED: return "All " + cov.getTotalCount() + " branches covered."; case ICounter.PARTLY_COVERED: return cov.getMissedCount() + " of " + cov.getTotalCount() + " branches missed."; case ICounter.NOT_COVERED: return "All " + cov.getTotalCount() + " branches missed."; default: return null; } }
@Override public void increment(final ICounter instructions, final ICounter branches, final int line) { super.increment(instructions, branches, line); // Additionally increment complexity counter: if (branches.getTotalCount() > 1) { final int c = Math.max(0, branches.getCoveredCount() - 1); final int m = Math.max(0, branches.getTotalCount() - c - 1); this.complexityCounter = this.complexityCounter.increment(m, c); } }
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 HTMLElement span(final HTMLElement parent, final String id, final String style1, final String style2, final String title, final ICounter branches) throws IOException { final HTMLElement span = parent.span(style1 + " " + style2, id); final Integer missed = Integer.valueOf(branches.getMissedCount()); final Integer total = Integer.valueOf(branches.getTotalCount()); span.attr("title", String.format(locale, title, missed, total)); return span; }
private void cell(final HTMLElement td, final ICoverageNode node) throws IOException { final ICounter counter = node.getCounter(entity); final int total = counter.getTotalCount(); if (total == 0) { td.text("n/a"); } else { td.text(format(counter.getCoveredRatio())); } }
@Override protected int getValue(final ICounter counter) { return counter.getCoveredCount(); } };
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; }
@Override protected int getValue(final ICounter counter) { return counter.getMissedCount(); } };
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 void incrementLine(final ICounter instructions, final ICounter branches, final int line) { ensureCapacity(line, line); final LineImpl l = getLine(line); final int oldTotal = l.getInstructionCounter().getTotalCount(); final int oldCovered = l.getInstructionCounter().getCoveredCount(); lines[line - offset] = l.increment(instructions, branches); // Increment line counter: if (instructions.getTotalCount() > 0) { if (instructions.getCoveredCount() == 0) { if (oldTotal == 0) { lineCounter = lineCounter .increment(CounterImpl.COUNTER_1_0); } } else { if (oldTotal == 0) { lineCounter = lineCounter .increment(CounterImpl.COUNTER_0_1); } else { if (oldCovered == 0) { lineCounter = lineCounter.increment(-1, +1); } } } } }
public void footer(final HTMLElement td, final ICoverageNode total, final Resources resources, final ReportOutputFolder base) throws IOException { final ICounter counter = total.getCounter(entity); td.text(integerFormat.format(counter.getMissedCount())); td.text(" of "); td.text(integerFormat.format(counter.getTotalCount())); }
switch (branches.getStatus()) { case ICounter.NOT_COVERED: return span(pre, lineId, style, Styles.BRANCH_NOT_COVERED,
String check(final ICoverageNode node) { final double d = node.getCounter(entity).getValue(value); if (Double.isNaN(d)) { return null; } final BigDecimal bd = BigDecimal.valueOf(d); if (minimum != null && minimum.compareTo(bd) > 0) { return message("minimum", bd, minimum, RoundingMode.FLOOR); } if (maximum != null && maximum.compareTo(bd) < 0) { return message("maximum", bd, maximum, RoundingMode.CEILING); } return null; }
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; }
/** * Factory method to retrieve a clone of the given counter. * * @param counter * counter to copy * @return counter instance */ public static CounterImpl getInstance(final ICounter counter) { return getInstance(counter.getMissedCount(), counter.getCoveredCount()); }
private String total(final ICounter counter) { return String.valueOf(counter.getTotalCount()); }
final Integer missed = Integer.valueOf(counter.getMissedCount()); final Integer total = Integer.valueOf(counter.getTotalCount());