@Override protected int getValue(final ICounter counter) { return counter.getCoveredCount(); } };
@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; } }
/** * 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()); }
/** * Returns a counter with values incremented by the numbers of the given * counter. It is up to the implementation whether this counter instance is * modified or a new instance is returned. * * @param counter * number of additional total and covered items * @return counter instance with incremented values */ public CounterImpl increment(final ICounter counter) { return increment(counter.getMissedCount(), counter.getCoveredCount()); }
@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 void counterAttributes(final XMLElement element, final String missedattr, final String coveredattr, final ICounter counter) throws IOException { element.attr(missedattr, counter.getMissedCount()); element.attr(coveredattr, counter.getCoveredCount()); }
public void item(final HTMLElement td, final ITableItem item, final Resources resources, final ReportOutputFolder base) throws IOException { if (max > 0) { final ICounter counter = item.getNode().getCounter(entity); final int missed = counter.getMissedCount(); bar(td, missed, Resources.REDBAR, resources, base); final int covered = counter.getCoveredCount(); bar(td, covered, Resources.GREENBAR, resources, base); } }
ratio.accumulatePP(bundleCoverage.getClassCounter().getMissedCount(), bundleCoverage.getClassCounter().getCoveredCount()); ratios.put(CoverageElement.Type.CLASS, ratio); ratio.accumulatePP(bundleCoverage.getBranchCounter().getMissedCount(), bundleCoverage.getBranchCounter().getCoveredCount()); ratios.put(CoverageElement.Type.BRANCH, ratio); ratio.accumulatePP(bundleCoverage.getInstructionCounter().getMissedCount(), bundleCoverage.getInstructionCounter().getCoveredCount()); ratios.put(CoverageElement.Type.INSTRUCTION, ratio); ratio.accumulatePP(bundleCoverage.getMethodCounter().getMissedCount(), bundleCoverage.getMethodCounter().getCoveredCount()); ratios.put(CoverageElement.Type.METHOD, ratio); ratio.accumulatePP(bundleCoverage.getComplexityCounter().getMissedCount(), bundleCoverage.getComplexityCounter().getCoveredCount()); ratios.put(CoverageElement.Type.COMPLEXITY, ratio); ratio.accumulatePP(bundleCoverage.getLineCounter().getMissedCount(), bundleCoverage.getLineCounter().getCoveredCount()); ratios.put(CoverageElement.Type.LINE, ratio);
protected <ReportLevel extends AggregatedReport<?,?,?> > void setAllCovTypes( ReportLevel reportToSet, ICoverageNode covReport) { Coverage tempCov = new Coverage(); tempCov.accumulate(covReport.getClassCounter().getMissedCount(), covReport.getClassCounter().getCoveredCount()); reportToSet.clazz = tempCov; tempCov = new Coverage(); tempCov.accumulate(covReport.getBranchCounter().getMissedCount(), covReport.getBranchCounter().getCoveredCount()); reportToSet.branch = tempCov; tempCov = new Coverage(); tempCov.accumulate(covReport.getLineCounter().getMissedCount(), covReport.getLineCounter().getCoveredCount()); reportToSet.line = tempCov; tempCov = new Coverage(); tempCov.accumulate(covReport.getInstructionCounter().getMissedCount(), covReport.getInstructionCounter().getCoveredCount()); reportToSet.instruction = tempCov; tempCov = new Coverage(); tempCov.accumulate(covReport.getMethodCounter().getMissedCount(), covReport.getMethodCounter().getCoveredCount()); reportToSet.method = tempCov; tempCov = new Coverage(); tempCov.accumulate(covReport.getComplexityCounter().getMissedCount(), covReport.getComplexityCounter().getCoveredCount()); reportToSet.complexity = tempCov; }
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); } } } } }
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(); newCoverage.conditions(lineId, conditions, coveredConditions);
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); } } } }
/** * Writes the class summary information as a row. * * @param groupName * name of the group * @param packageName * vm name of the package * @param node * class coverage data * @throws IOException * in case of problems with the writer */ public void writeRow(final String groupName, final String packageName, final IClassCoverage node) throws IOException { writer.write(groupName); writer.write(languageNames.getPackageName(packageName)); final String className = languageNames.getClassName(node.getName(), node.getSignature(), node.getSuperName(), node.getInterfaceNames()); writer.write(className); for (final CounterEntity entity : COUNTERS) { final ICounter counter = node.getCounter(entity); writer.write(counter.getMissedCount()); writer.write(counter.getCoveredCount()); } writer.nextLine(); }