/** * Check the counters and report violations. * * @param aCounter the method counters to check * @param aAst to report errors against. */ private void checkCounters(MethodCounter aCounter, DetailAST aAst) { checkMax(mMaxPrivate, aCounter.value(Scope.PRIVATE), "too.many.privateMethods", aAst); checkMax(mMaxPackage, aCounter.value(Scope.PACKAGE), "too.many.packageMethods", aAst); checkMax(mMaxProtected, aCounter.value(Scope.PROTECTED), "too.many.protectedMethods", aAst); checkMax(mMaxPublic, aCounter.value(Scope.PUBLIC), "too.many.publicMethods", aAst); checkMax(mMaxTotal, aCounter.getTotal(), "too.many.methods", aAst); }
/** * Determine the visibility modifier and raise the corresponding counter. * * @param aMethod The method-subtree from the AbstractSyntaxTree. */ private void raiseCounter(DetailAST aMethod) { final MethodCounter actualCounter = mCounters.peek(); final DetailAST temp = aMethod.findFirstToken(TokenTypes.MODIFIERS); final Scope scope = ScopeUtils.getScopeFromMods(temp); actualCounter.increment(scope); }