@Override protected int getValue(final ICounter counter) { return counter.getTotalCount(); } };
private String total(final ICounter counter) { return String.valueOf(counter.getTotalCount()); }
/** * 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; } }
public boolean containsCode() { return getInstructionCounter().getTotalCount() != 0; }
@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 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; }
public boolean init(final List<? extends ITableItem> items, final ICoverageNode total) { this.max = 0; for (final ITableItem item : items) { final int count = item.getNode().getCounter(entity).getTotalCount(); if (count > this.max) { this.max = count; } } return true; }
public boolean init(final List<? extends ITableItem> items, final ICoverageNode total) { for (final ITableItem i : items) { if (i.getNode().getCounter(entity).getTotalCount() > 0) { return true; } } return false; }
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())); }
/** * Writes all non-zero counters of the given node. * * @param node * node to retrieve counters from * @param parent * container for the counter elements * @throws IOException * if XML can't be written to the underlying output */ public static void writeCounters(final ICoverageNode node, final ReportElement parent) throws IOException { for (final CounterEntity counterEntity : CounterEntity.values()) { final ICounter counter = node.getCounter(counterEntity); if (counter.getTotalCount() > 0) { parent.counter(counterEntity, counter); } } }
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())); } }
private void writeReports(final IBundleCoverage bundle, final ExecFileLoader loader, final PrintWriter out) throws IOException { out.printf("[INFO] Analyzing %s classes.%n", Integer.valueOf(bundle.getClassCounter().getTotalCount())); final IReportVisitor visitor = createReportVisitor(); visitor.visitInfo(loader.getSessionInfoStore().getInfos(), loader.getExecutionDataStore().getContents()); visitor.visitBundle(bundle, getSourceLocator()); visitor.visitEnd(); }
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); } } } } }
final Integer total = Integer.valueOf(counter.getTotalCount());
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 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; }
int conditions = branchCounter.getTotalCount(); if (conditions > 0) { int coveredConditions = branchCounter.getCoveredCount();
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); } } } }
@Override protected void content(HTMLElement body) throws IOException { if (getNode().isNoMatch()) { body.p().text( "A different version of class was executed at runtime."); } if (getNode().getLineCounter().getTotalCount() == 0) { body.p().text( "Class files must be compiled with debug information to show line coverage."); } final String sourceFileName = getNode().getSourceFileName(); if (sourceFileName == null) { body.p().text( "Class files must be compiled with debug information to link with source files."); } else if (sourcePage == null) { final String sourcePath; if (getNode().getPackageName().length() != 0) { sourcePath = getNode().getPackageName() + "/" + sourceFileName; } else { sourcePath = sourceFileName; } body.p().text("Source file \"" + sourcePath + "\" was not found during generation of report."); } super.content(body); }