/** * Creates a new visitor to process the configured checks. * * @param output * call-back to report violations to * @return visitor to emit the report data to */ public IReportVisitor createVisitor(final IViolationsOutput output) { final BundleChecker bundleChecker = new BundleChecker(rules, languageNames, output); return new IReportVisitor() { public IReportGroupVisitor visitGroup(final String name) throws IOException { return this; } public void visitBundle(final IBundleCoverage bundle, final ISourceFileLocator locator) throws IOException { bundleChecker.checkBundle(bundle); } public void visitInfo(final List<SessionInfo> sessionInfos, final Collection<ExecutionData> executionData) throws IOException { } public void visitEnd() throws IOException { } }; }
public void checkBundle(final IBundleCoverage bundleCoverage) { final String name = bundleCoverage.getName(); checkRules(bundleCoverage, bundleRules, "bundle", name); if (traversePackages) { for (final IPackageCoverage p : bundleCoverage.getPackages()) { check(p); } } }
public void visitBundle(final IBundleCoverage bundle, final ISourceFileLocator locator) throws IOException { bundleChecker.checkBundle(bundle); }
private void check(final ISourceFileCoverage sourceFile) { final String name = sourceFile.getPackageName() + "/" + sourceFile.getName(); checkRules(sourceFile, sourceFileRules, "source file", name); }
private void checkRules(final ICoverageNode node, final Collection<Rule> rules, final String typename, final String elementname) { for (final Rule rule : rules) { if (rule.matches(elementname)) { for (final Limit limit : rule.getLimits()) { checkLimit(node, typename, elementname, rule, limit); } } } }
private void check(final IMethodCoverage method, final String className) { final String name = names.getQualifiedMethodName(className, method.getName(), method.getDesc(), method.getSignature()); checkRules(method, methodRules, "method", name); }
private void check(final IPackageCoverage packageCoverage) { final String name = names.getPackageName(packageCoverage.getName()); checkRules(packageCoverage, packageRules, "package", name); if (traverseClasses) { for (final IClassCoverage c : packageCoverage.getClasses()) { check(c); } } if (traverseSourceFiles) { for (final ISourceFileCoverage s : packageCoverage.getSourceFiles()) { check(s); } } }
private void check(final IClassCoverage classCoverage) { final String name = names .getQualifiedClassName(classCoverage.getName()); checkRules(classCoverage, classRules, "class", name); if (traverseMethods) { for (final IMethodCoverage m : classCoverage.getMethods()) { check(m, classCoverage.getName()); } } }