From 3fec4a92e39afc5b68b03c5fd023cb8d13408385 Mon Sep 17 00:00:00 2001 From: alexkravin Date: Sun, 11 Jan 2015 14:11:09 +0400 Subject: [PATCH] Prefixes, sizes, #512 --- .../checks/sizes/AnonInnerLengthCheck.java | 18 +-- .../sizes/ExecutableStatementCountCheck.java | 90 +++++------ .../checks/sizes/FileLengthCheck.java | 14 +- .../checks/sizes/LineLengthCheck.java | 28 ++-- .../checks/sizes/MethodCountCheck.java | 152 +++++++++--------- .../checks/sizes/MethodLengthCheck.java | 28 ++-- .../checks/sizes/OuterTypeNumberCheck.java | 38 ++--- .../checks/sizes/ParameterNumberCheck.java | 36 ++--- 8 files changed, 202 insertions(+), 202 deletions(-) diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/AnonInnerLengthCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/AnonInnerLengthCheck.java index 0f42cb020..0bd9600f9 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/AnonInnerLengthCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/AnonInnerLengthCheck.java @@ -61,7 +61,7 @@ public class AnonInnerLengthCheck extends Check private static final int DEFAULT_MAX = 20; /** maximum number of lines */ - private int mMax = DEFAULT_MAX; + private int max = DEFAULT_MAX; @Override public int[] getDefaultTokens() @@ -70,27 +70,27 @@ public class AnonInnerLengthCheck extends Check } @Override - public void visitToken(DetailAST aAST) + public void visitToken(DetailAST ast) { - final DetailAST openingBrace = aAST.findFirstToken(TokenTypes.OBJBLOCK); + final DetailAST openingBrace = ast.findFirstToken(TokenTypes.OBJBLOCK); if (openingBrace != null) { final DetailAST closingBrace = openingBrace.findFirstToken(TokenTypes.RCURLY); final int length = closingBrace.getLineNo() - openingBrace.getLineNo() + 1; - if (length > mMax) { - log(aAST.getLineNo(), aAST.getColumnNo(), "maxLen.anonInner", - length, mMax); + if (length > max) { + log(ast.getLineNo(), ast.getColumnNo(), "maxLen.anonInner", + length, max); } } } /** - * @param aLength the maximum length of an anonymous inner class. + * @param length the maximum length of an anonymous inner class. */ - public void setMax(int aLength) + public void setMax(int length) { - mMax = aLength; + max = length; } } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheck.java index 560b28c10..65d4a1d60 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheck.java @@ -35,13 +35,13 @@ public final class ExecutableStatementCountCheck private static final int DEFAULT_MAX = 30; /** threshold to report error for */ - private int mMax; + private int max; /** Stack of method contexts. */ - private final FastStack mContextStack = FastStack.newInstance(); + private final FastStack contextStack = FastStack.newInstance(); /** Current method context. */ - private Context mContext; + private Context context; /** Constructs a ExecutableStatementCountCheck. */ public ExecutableStatementCountCheck() @@ -73,97 +73,97 @@ public final class ExecutableStatementCountCheck */ public int getMax() { - return mMax; + return max; } /** * Sets the maximum threshold. - * @param aMax the maximum threshold. + * @param max the maximum threshold. */ - public void setMax(int aMax) + public void setMax(int max) { - mMax = aMax; + this.max = max; } @Override - public void beginTree(DetailAST aRootAST) + public void beginTree(DetailAST rootAST) { - mContext = null; - mContextStack.clear(); + context = null; + contextStack.clear(); } @Override - public void visitToken(DetailAST aAST) + public void visitToken(DetailAST ast) { - switch (aAST.getType()) { + switch (ast.getType()) { case TokenTypes.CTOR_DEF: case TokenTypes.METHOD_DEF: case TokenTypes.INSTANCE_INIT: case TokenTypes.STATIC_INIT: - visitMemberDef(aAST); + visitMemberDef(ast); break; case TokenTypes.SLIST: - visitSlist(aAST); + visitSlist(ast); break; default: - throw new IllegalStateException(aAST.toString()); + throw new IllegalStateException(ast.toString()); } } @Override - public void leaveToken(DetailAST aAST) + public void leaveToken(DetailAST ast) { - switch (aAST.getType()) { + switch (ast.getType()) { case TokenTypes.CTOR_DEF: case TokenTypes.METHOD_DEF: case TokenTypes.INSTANCE_INIT: case TokenTypes.STATIC_INIT: - leaveMemberDef(aAST); + leaveMemberDef(ast); break; case TokenTypes.SLIST: // Do nothing break; default: - throw new IllegalStateException(aAST.toString()); + throw new IllegalStateException(ast.toString()); } } /** * Process the start of the member definition. - * @param aAST the token representing the member definition. + * @param ast the token representing the member definition. */ - private void visitMemberDef(DetailAST aAST) + private void visitMemberDef(DetailAST ast) { - mContextStack.push(mContext); - mContext = new Context(aAST); + contextStack.push(context); + context = new Context(ast); } /** * Process the end of a member definition. * - * @param aAST the token representing the member definition. + * @param ast the token representing the member definition. */ - private void leaveMemberDef(DetailAST aAST) + private void leaveMemberDef(DetailAST ast) { - final int count = mContext.getCount(); + final int count = context.getCount(); if (count > getMax()) { - log(aAST.getLineNo(), aAST.getColumnNo(), + log(ast.getLineNo(), ast.getColumnNo(), "executableStatementCount", count, getMax()); } - mContext = mContextStack.pop(); + context = contextStack.pop(); } /** * Process the end of a statement list. * - * @param aAST the token representing the statement list. + * @param ast the token representing the statement list. */ - private void visitSlist(DetailAST aAST) + private void visitSlist(DetailAST ast) { - if (mContext != null) { + if (context != null) { // find member AST for the statement list - final DetailAST contextAST = mContext.getAST(); - DetailAST parent = aAST.getParent(); + final DetailAST contextAST = context.getAST(); + DetailAST parent = ast.getParent(); while (parent != null) { final int type = parent.getType(); if ((type == TokenTypes.CTOR_DEF) @@ -172,7 +172,7 @@ public final class ExecutableStatementCountCheck || (type == TokenTypes.STATIC_INIT)) { if (parent == contextAST) { - mContext.addCount(aAST.getChildCount() / 2); + context.addCount(ast.getChildCount() / 2); } break; } @@ -188,28 +188,28 @@ public final class ExecutableStatementCountCheck private static class Context { /** Member AST node. */ - private final DetailAST mAST; + private final DetailAST ast; /** Counter for context elements. */ - private int mCount; + private int count; /** * Creates new member context. - * @param aAST member AST node. + * @param ast member AST node. */ - public Context(DetailAST aAST) + public Context(DetailAST ast) { - mAST = aAST; - mCount = 0; + this.ast = ast; + count = 0; } /** * Increase count. - * @param aCount the count increment. + * @param count the count increment. */ - public void addCount(int aCount) + public void addCount(int count) { - mCount += aCount; + this.count += count; } /** @@ -218,7 +218,7 @@ public final class ExecutableStatementCountCheck */ public DetailAST getAST() { - return mAST; + return ast; } /** @@ -227,7 +227,7 @@ public final class ExecutableStatementCountCheck */ public int getCount() { - return mCount; + return count; } } } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheck.java index aa12f7700..b3ee84559 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheck.java @@ -58,22 +58,22 @@ public class FileLengthCheck extends AbstractFileSetCheck private static final int DEFAULT_MAX_LINES = 2000; /** the maximum number of lines */ - private int mMaxFileLength = DEFAULT_MAX_LINES; + private int maxFileLength = DEFAULT_MAX_LINES; @Override - protected void processFiltered(File aFile, List aLines) + protected void processFiltered(File file, List lines) { - if (aLines.size() > mMaxFileLength) { - log(1, "maxLen.file", aLines.size(), mMaxFileLength); + if (lines.size() > maxFileLength) { + log(1, "maxLen.file", lines.size(), maxFileLength); } } /** - * @param aLength the maximum length of a Java source file + * @param length the maximum length of a Java source file */ - public void setMax(int aLength) + public void setMax(int length) { - mMaxFileLength = aLength; + maxFileLength = length; } } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheck.java index 907907241..5104ce093 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheck.java @@ -80,10 +80,10 @@ public class LineLengthCheck extends Check private static final int DEFAULT_MAX_COLUMNS = 80; /** the maximum number of columns in a line */ - private int mMax = DEFAULT_MAX_COLUMNS; + private int max = DEFAULT_MAX_COLUMNS; /** the regexp when long lines are ignored */ - private Pattern mIgnorePattern; + private Pattern ignorePattern; /** * Creates a new LineLengthCheck instance. @@ -100,7 +100,7 @@ public class LineLengthCheck extends Check } @Override - public void beginTree(DetailAST aRootAST) + public void beginTree(DetailAST rootAST) { final String[] lines = getLines(); for (int i = 0; i < lines.length; i++) { @@ -110,35 +110,35 @@ public class LineLengthCheck extends Check line, line.length(), getTabWidth()); - if ((realLength > mMax) - && !mIgnorePattern.matcher(line).find()) + if ((realLength > max) + && !ignorePattern.matcher(line).find()) { - log(i + 1, "maxLineLen", mMax, realLength); + log(i + 1, "maxLineLen", max, realLength); } } } /** - * @param aLength the maximum length of a line + * @param length the maximum length of a line */ - public void setMax(int aLength) + public void setMax(int length) { - mMax = aLength; + max = length; } /** * Set the ignore pattern. - * @param aFormat a String value - * @throws ConversionException unable to parse aFormat + * @param format a String value + * @throws ConversionException unable to parse format */ - public void setIgnorePattern(String aFormat) + public void setIgnorePattern(String format) throws ConversionException { try { - mIgnorePattern = Utils.getPattern(aFormat); + ignorePattern = Utils.getPattern(format); } catch (final PatternSyntaxException e) { - throw new ConversionException("unable to parse " + aFormat, e); + throw new ConversionException("unable to parse " + format, e); } } } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodCountCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodCountCheck.java index 735475761..e248e4752 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodCountCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodCountCheck.java @@ -42,69 +42,69 @@ public final class MethodCountCheck extends Check private static class MethodCounter { /** Maintains the counts. */ - private final EnumMap mCounts = + private final EnumMap counts = new EnumMap(Scope.class); /** indicated is an interface, in which case all methods are public */ - private final boolean mInInterface; + private final boolean inInterface; /** tracks the total. */ - private int mTotal; + private int total; /** * Creates an interface. - * @param aInInterface indicated if counter for an interface. In which + * @param inInterface indicated if counter for an interface. In which * case, add all counts as public methods. */ - MethodCounter(boolean aInInterface) + MethodCounter(boolean inInterface) { - mInInterface = aInInterface; + this.inInterface = inInterface; } /** * Increments to counter by one for the supplied scope. - * @param aScope the scope counter to increment. + * @param scope the scope counter to increment. */ - void increment(Scope aScope) + void increment(Scope scope) { - mTotal++; - if (mInInterface) { - mCounts.put(Scope.PUBLIC, 1 + value(Scope.PUBLIC)); + total++; + if (inInterface) { + counts.put(Scope.PUBLIC, 1 + value(Scope.PUBLIC)); } else { - mCounts.put(aScope, 1 + value(aScope)); + counts.put(scope, 1 + value(scope)); } } /** * @return the value of a scope counter - * @param aScope the scope counter to get the value of + * @param scope the scope counter to get the value of */ - int value(Scope aScope) + int value(Scope scope) { - final Integer value = mCounts.get(aScope); + final Integer value = counts.get(scope); return (null == value) ? 0 : value; } /** @return the total number of methods. */ int getTotal() { - return mTotal; + return total; } }; /** default maximum number of methods */ private static final int DEFAULT_MAX_METHODS = 100; /** Maximum private methods. */ - private int mMaxPrivate = DEFAULT_MAX_METHODS; + private int maxPrivate = DEFAULT_MAX_METHODS; /** Maximum package methods. */ - private int mMaxPackage = DEFAULT_MAX_METHODS; + private int maxPackage = DEFAULT_MAX_METHODS; /** Maximum protected methods. */ - private int mMaxProtected = DEFAULT_MAX_METHODS; + private int maxProtected = DEFAULT_MAX_METHODS; /** Maximum public methods. */ - private int mMaxPublic = DEFAULT_MAX_METHODS; + private int maxPublic = DEFAULT_MAX_METHODS; /** Maximum total number of methods. */ - private int mMaxTotal = DEFAULT_MAX_METHODS; + private int maxTotal = DEFAULT_MAX_METHODS; /** Maintains stack of counters, to support inner types. */ - private final FastStack mCounters = + private final FastStack counters = new FastStack(); @Override @@ -120,121 +120,121 @@ public final class MethodCountCheck extends Check } @Override - public void visitToken(DetailAST aAST) + public void visitToken(DetailAST ast) { - if ((TokenTypes.CLASS_DEF == aAST.getType()) - || (TokenTypes.INTERFACE_DEF == aAST.getType()) - || (TokenTypes.ENUM_CONSTANT_DEF == aAST.getType()) - || (TokenTypes.ENUM_DEF == aAST.getType())) + if ((TokenTypes.CLASS_DEF == ast.getType()) + || (TokenTypes.INTERFACE_DEF == ast.getType()) + || (TokenTypes.ENUM_CONSTANT_DEF == ast.getType()) + || (TokenTypes.ENUM_DEF == ast.getType())) { - mCounters.push(new MethodCounter( - TokenTypes.INTERFACE_DEF == aAST.getType())); + counters.push(new MethodCounter( + TokenTypes.INTERFACE_DEF == ast.getType())); } - else if (TokenTypes.METHOD_DEF == aAST.getType()) { - raiseCounter(aAST); + else if (TokenTypes.METHOD_DEF == ast.getType()) { + raiseCounter(ast); } } @Override - public void leaveToken(DetailAST aAST) + public void leaveToken(DetailAST ast) { - if ((TokenTypes.CLASS_DEF == aAST.getType()) - || (TokenTypes.INTERFACE_DEF == aAST.getType()) - || (TokenTypes.ENUM_CONSTANT_DEF == aAST.getType()) - || (TokenTypes.ENUM_DEF == aAST.getType())) + if ((TokenTypes.CLASS_DEF == ast.getType()) + || (TokenTypes.INTERFACE_DEF == ast.getType()) + || (TokenTypes.ENUM_CONSTANT_DEF == ast.getType()) + || (TokenTypes.ENUM_DEF == ast.getType())) { - final MethodCounter counter = mCounters.pop(); - checkCounters(counter, aAST); + final MethodCounter counter = counters.pop(); + checkCounters(counter, ast); } } /** * Determine the visibility modifier and raise the corresponding counter. - * @param aMethod + * @param method * The method-subtree from the AbstractSyntaxTree. */ - private void raiseCounter(DetailAST aMethod) + private void raiseCounter(DetailAST method) { - final MethodCounter actualCounter = mCounters.peek(); - final DetailAST temp = aMethod.findFirstToken(TokenTypes.MODIFIERS); + final MethodCounter actualCounter = counters.peek(); + final DetailAST temp = method.findFirstToken(TokenTypes.MODIFIERS); final Scope scope = ScopeUtils.getScopeFromMods(temp); actualCounter.increment(scope); } /** * Check the counters and report violations. - * @param aCounter the method counters to check - * @param aAst to report errors against. + * @param counter the method counters to check + * @param ast to report errors against. */ - private void checkCounters(MethodCounter aCounter, DetailAST aAst) + private void checkCounters(MethodCounter counter, DetailAST ast) { - 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); + checkMax(maxPrivate, counter.value(Scope.PRIVATE), + "too.many.privateMethods", ast); + checkMax(maxPackage, counter.value(Scope.PACKAGE), + "too.many.packageMethods", ast); + checkMax(maxProtected, counter.value(Scope.PROTECTED), + "too.many.protectedMethods", ast); + checkMax(maxPublic, counter.value(Scope.PUBLIC), + "too.many.publicMethods", ast); + checkMax(maxTotal, counter.getTotal(), "too.many.methods", ast); } /** * Utility for reporting if a maximum has been exceeded. - * @param aMax the maximum allowed value - * @param aValue the actual value - * @param aMsg the message to log. Takes two arguments of value and maximum. - * @param aAst the AST to associate with the message. + * @param max the maximum allowed value + * @param value the actual value + * @param msg the message to log. Takes two arguments of value and maximum. + * @param ast the AST to associate with the message. */ - private void checkMax(int aMax, int aValue, String aMsg, DetailAST aAst) + private void checkMax(int max, int value, String msg, DetailAST ast) { - if (aMax < aValue) { - log(aAst.getLineNo(), aMsg, aValue, aMax); + if (max < value) { + log(ast.getLineNo(), msg, value, max); } } /** * Sets the maximum allowed private methods per type. - * @param aValue the maximum allowed. + * @param value the maximum allowed. */ - public void setMaxPrivate(int aValue) + public void setMaxPrivate(int value) { - mMaxPrivate = aValue; + maxPrivate = value; } /** * Sets the maximum allowed package methods per type. - * @param aValue the maximum allowed. + * @param value the maximum allowed. */ - public void setMaxPackage(int aValue) + public void setMaxPackage(int value) { - mMaxPackage = aValue; + maxPackage = value; } /** * Sets the maximum allowed protected methods per type. - * @param aValue the maximum allowed. + * @param value the maximum allowed. */ - public void setMaxProtected(int aValue) + public void setMaxProtected(int value) { - mMaxProtected = aValue; + maxProtected = value; } /** * Sets the maximum allowed public methods per type. - * @param aValue the maximum allowed. + * @param value the maximum allowed. */ - public void setMaxPublic(int aValue) + public void setMaxPublic(int value) { - mMaxPublic = aValue; + maxPublic = value; } /** * Sets the maximum total methods per type. - * @param aValue the maximum allowed. + * @param value the maximum allowed. */ - public void setMaxTotal(int aValue) + public void setMaxTotal(int value) { - mMaxTotal = aValue; + maxTotal = value; } } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheck.java index 0b7039644..72b7d28e1 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheck.java @@ -56,13 +56,13 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; public class MethodLengthCheck extends Check { /** whether to ignore empty lines and single line comments */ - private boolean mCountEmpty = true; + private boolean countEmpty = true; /** default maximum number of lines */ private static final int DEFAULT_MAX_LINES = 150; /** the maximum number of lines */ - private int mMax = DEFAULT_MAX_LINES; + private int max = DEFAULT_MAX_LINES; @Override public int[] getDefaultTokens() @@ -71,16 +71,16 @@ public class MethodLengthCheck extends Check } @Override - public void visitToken(DetailAST aAST) + public void visitToken(DetailAST ast) { - final DetailAST openingBrace = aAST.findFirstToken(TokenTypes.SLIST); + final DetailAST openingBrace = ast.findFirstToken(TokenTypes.SLIST); if (openingBrace != null) { final DetailAST closingBrace = openingBrace.findFirstToken(TokenTypes.RCURLY); int length = closingBrace.getLineNo() - openingBrace.getLineNo() + 1; - if (!mCountEmpty) { + if (!countEmpty) { final FileContents contents = getFileContents(); final int lastLine = closingBrace.getLineNo(); for (int i = openingBrace.getLineNo() - 1; i < lastLine; i++) { @@ -89,27 +89,27 @@ public class MethodLengthCheck extends Check } } } - if (length > mMax) { - log(aAST.getLineNo(), aAST.getColumnNo(), "maxLen.method", - length, mMax); + if (length > max) { + log(ast.getLineNo(), ast.getColumnNo(), "maxLen.method", + length, max); } } } /** - * @param aLength the maximum length of a method. + * @param length the maximum length of a method. */ - public void setMax(int aLength) + public void setMax(int length) { - mMax = aLength; + max = length; } /** - * @param aCountEmpty whether to count empty and single line comments + * @param countEmpty whether to count empty and single line comments * of the form //. */ - public void setCountEmpty(boolean aCountEmpty) + public void setCountEmpty(boolean countEmpty) { - mCountEmpty = aCountEmpty; + this.countEmpty = countEmpty; } } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/OuterTypeNumberCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/OuterTypeNumberCheck.java index 9fa6b3927..c2457bca9 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/OuterTypeNumberCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/OuterTypeNumberCheck.java @@ -13,7 +13,7 @@ // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// License tong with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //////////////////////////////////////////////////////////////////////////////// package com.puppycrawl.tools.checkstyle.checks.sizes; @@ -29,11 +29,11 @@ import com.puppycrawl.tools.checkstyle.api.Check; public class OuterTypeNumberCheck extends Check { /** The maximum allowed number of outer types. */ - private int mMax = 1; + private int max = 1; /** Tracks the current depth in types. */ - private int mCurrentDepth; + private int currentDepth; /** Tracks the number of outer types found. */ - private int mOuterNum; + private int outerNum; @Override public int[] getDefaultTokens() @@ -43,41 +43,41 @@ public class OuterTypeNumberCheck extends Check } @Override - public void beginTree(DetailAST aAst) + public void beginTree(DetailAST ast) { - mCurrentDepth = 0; - mOuterNum = 0; + currentDepth = 0; + outerNum = 0; } @Override - public void finishTree(DetailAST aAst) + public void finishTree(DetailAST ast) { - if (mMax < mOuterNum) { - log(aAst, "maxOuterTypes", mOuterNum, mMax); + if (max < outerNum) { + log(ast, "maxOuterTypes", outerNum, max); } } @Override - public void visitToken(DetailAST aAst) + public void visitToken(DetailAST ast) { - if (0 == mCurrentDepth) { - mOuterNum++; + if (0 == currentDepth) { + outerNum++; } - mCurrentDepth++; + currentDepth++; } @Override - public void leaveToken(DetailAST aAst) + public void leaveToken(DetailAST ast) { - mCurrentDepth--; + currentDepth--; } /** * Sets the maximum allowed number of outer types. - * @param aTo the new number. + * @param to the new number. */ - public void setMax(int aTo) + public void setMax(int to) { - mMax = aTo; + max = to; } } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/ParameterNumberCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/ParameterNumberCheck.java index eb5c1c8ac..44e58bce3 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/ParameterNumberCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/ParameterNumberCheck.java @@ -76,28 +76,28 @@ public class ParameterNumberCheck private static final int DEFAULT_MAX_PARAMETERS = 7; /** the maximum number of allowed parameters */ - private int mMax = DEFAULT_MAX_PARAMETERS; + private int max = DEFAULT_MAX_PARAMETERS; /** ignore overridden methods */ - private boolean mIgnoreOverriddenMethods; + private boolean ignoreOverriddenMethods; /** * Sets the maximum number of allowed parameters. - * @param aMax the max allowed parameters + * @param max the max allowed parameters */ - public void setMax(int aMax) + public void setMax(int max) { - mMax = aMax; + this.max = max; } /** * Ignore number of parameters for methods with * @{@link java.lang.Override} annotation. - * @param aIgnoreOverriddenMethods set ignore overridden methods + * @param ignoreOverriddenMethods set ignore overridden methods */ - public void setIgnoreOverriddenMethods(boolean aIgnoreOverriddenMethods) + public void setIgnoreOverriddenMethods(boolean ignoreOverriddenMethods) { - mIgnoreOverriddenMethods = aIgnoreOverriddenMethods; + this.ignoreOverriddenMethods = ignoreOverriddenMethods; } @Override @@ -107,27 +107,27 @@ public class ParameterNumberCheck } @Override - public void visitToken(DetailAST aAST) + public void visitToken(DetailAST ast) { - final DetailAST params = aAST.findFirstToken(TokenTypes.PARAMETERS); + final DetailAST params = ast.findFirstToken(TokenTypes.PARAMETERS); final int count = params.getChildCount(TokenTypes.PARAMETER_DEF); - if (count > mMax && !ignoreNumberOfParameters(aAST)) { - final DetailAST name = aAST.findFirstToken(TokenTypes.IDENT); - log(name.getLineNo(), name.getColumnNo(), "maxParam", mMax, count); + if (count > max && !ignoreNumberOfParameters(ast)) { + final DetailAST name = ast.findFirstToken(TokenTypes.IDENT); + log(name.getLineNo(), name.getColumnNo(), "maxParam", max, count); } } /** Determine whether to ignore number of parameters for the method. * - * @param aAST the token to process + * @param ast the token to process * @return true if this is overridden method and number of parameters should be ignored * false otherwise */ - private boolean ignoreNumberOfParameters(DetailAST aAST) + private boolean ignoreNumberOfParameters(DetailAST ast) { //if you override a method, you have no power over the number of parameters - return mIgnoreOverriddenMethods - && (AnnotationUtility.containsAnnotation(aAST, OVERRIDE) - || AnnotationUtility.containsAnnotation(aAST, CANONICAL_OVERRIDE)); + return ignoreOverriddenMethods + && (AnnotationUtility.containsAnnotation(ast, OVERRIDE) + || AnnotationUtility.containsAnnotation(ast, CANONICAL_OVERRIDE)); } }