diff --git a/checkstyle_checks.xml b/checkstyle_checks.xml
index 1cdf361da..df878ad73 100755
--- a/checkstyle_checks.xml
+++ b/checkstyle_checks.xml
@@ -189,6 +189,7 @@
+
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java
index eaa79f209..f99541e62 100755
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java
@@ -246,19 +246,19 @@ public class Checker extends AutomaticBean implements MessageDispatcher
{
// Prepare to start
fireAuditStarted();
- for (FileSetCheck fsc : mFileSetChecks) {
+ for (final FileSetCheck fsc : mFileSetChecks) {
fsc.beginProcessing(mCharset);
}
// Process each file
- for (File f : aFiles) {
+ for (final File f : aFiles) {
final String fileName = f.getAbsolutePath();
fireFileStarted(fileName);
final TreeSet fileMessages = Sets.newTreeSet();
try {
final FileText theText = new FileText(f.getAbsoluteFile(),
mCharset);
- for (FileSetCheck fsc : mFileSetChecks) {
+ for (final FileSetCheck fsc : mFileSetChecks) {
fileMessages.addAll(fsc.process(f, theText));
}
}
@@ -281,7 +281,7 @@ public class Checker extends AutomaticBean implements MessageDispatcher
}
// Finish up
- for (FileSetCheck fsc : mFileSetChecks) {
+ for (final FileSetCheck fsc : mFileSetChecks) {
// They may also log!!!
fsc.finishProcessing();
fsc.destroy();
@@ -334,26 +334,24 @@ public class Checker extends AutomaticBean implements MessageDispatcher
Locale.US);
final boolean onNetWare = (osName.indexOf("netware") > -1);
- final String orig = aPath;
-
- aPath = aPath.replace('/', File.separatorChar).replace('\\',
- File.separatorChar);
+ String path = aPath.replace('/', File.separatorChar).replace('\\',
+ File.separatorChar);
// make sure we are dealing with an absolute path
- final int colon = aPath.indexOf(":");
+ final int colon = path.indexOf(":");
if (!onNetWare) {
- if (!aPath.startsWith(File.separator)
- && !((aPath.length() >= 2)
- && Character.isLetter(aPath.charAt(0)) && (colon == 1)))
+ if (!path.startsWith(File.separator)
+ && !((path.length() >= 2)
+ && Character.isLetter(path.charAt(0)) && (colon == 1)))
{
- final String msg = aPath + " is not an absolute path";
+ final String msg = path + " is not an absolute path";
throw new IllegalArgumentException(msg);
}
}
else {
- if (!aPath.startsWith(File.separator) && (colon == -1)) {
- final String msg = aPath + " is not an absolute path";
+ if (!path.startsWith(File.separator) && (colon == -1)) {
+ final String msg = path + " is not an absolute path";
throw new IllegalArgumentException(msg);
}
}
@@ -361,20 +359,20 @@ public class Checker extends AutomaticBean implements MessageDispatcher
boolean dosWithDrive = false;
String root = null;
// Eliminate consecutive slashes after the drive spec
- if ((!onNetWare && (aPath.length() >= 2)
- && Character.isLetter(aPath.charAt(0)) && (aPath.charAt(1) == ':'))
+ if ((!onNetWare && (path.length() >= 2)
+ && Character.isLetter(path.charAt(0)) && (path.charAt(1) == ':'))
|| (onNetWare && (colon > -1)))
{
dosWithDrive = true;
- final char[] ca = aPath.replace('/', '\\').toCharArray();
+ final char[] ca = path.replace('/', '\\').toCharArray();
final StringBuffer sbRoot = new StringBuffer();
for (int i = 0; i < colon; i++) {
sbRoot.append(Character.toUpperCase(ca[i]));
}
sbRoot.append(':');
- if (colon + 1 < aPath.length()) {
+ if (colon + 1 < path.length()) {
sbRoot.append(File.separatorChar);
}
root = sbRoot.toString();
@@ -387,28 +385,28 @@ public class Checker extends AutomaticBean implements MessageDispatcher
sbPath.append(ca[i]);
}
}
- aPath = sbPath.toString().replace('\\', File.separatorChar);
+ path = sbPath.toString().replace('\\', File.separatorChar);
}
else {
- if (aPath.length() == 1) {
+ if (path.length() == 1) {
root = File.separator;
- aPath = "";
+ path = "";
}
- else if (aPath.charAt(1) == File.separatorChar) {
+ else if (path.charAt(1) == File.separatorChar) {
// UNC drive
root = File.separator + File.separator;
- aPath = aPath.substring(2);
+ path = path.substring(2);
}
else {
root = File.separator;
- aPath = aPath.substring(1);
+ path = path.substring(1);
}
}
final FastStack s = FastStack.newInstance();
s.push(root);
- final StringTokenizer tok = new StringTokenizer(aPath, File.separator);
+ final StringTokenizer tok = new StringTokenizer(path, File.separator);
while (tok.hasMoreTokens()) {
final String thisToken = tok.nextToken();
if (".".equals(thisToken)) {
@@ -417,7 +415,7 @@ public class Checker extends AutomaticBean implements MessageDispatcher
else if ("..".equals(thisToken)) {
if (s.size() < 2) {
throw new IllegalArgumentException("Cannot resolve path "
- + orig);
+ + aPath);
}
s.pop();
}
@@ -436,11 +434,11 @@ public class Checker extends AutomaticBean implements MessageDispatcher
sb.append(s.peek(i));
}
- aPath = sb.toString();
+ path = sb.toString();
if (dosWithDrive) {
- aPath = aPath.replace('/', '\\');
+ path = path.replace('/', '\\');
}
- return aPath;
+ return path;
}
/** @return the base directory property used in unit-test. */
@@ -453,7 +451,7 @@ public class Checker extends AutomaticBean implements MessageDispatcher
protected void fireAuditStarted()
{
final AuditEvent evt = new AuditEvent(this);
- for (AuditListener listener : mListeners) {
+ for (final AuditListener listener : mListeners) {
listener.auditStarted(evt);
}
}
@@ -462,7 +460,7 @@ public class Checker extends AutomaticBean implements MessageDispatcher
protected void fireAuditFinished()
{
final AuditEvent evt = new AuditEvent(this);
- for (AuditListener listener : mListeners) {
+ for (final AuditListener listener : mListeners) {
listener.auditFinished(evt);
}
}
@@ -477,7 +475,7 @@ public class Checker extends AutomaticBean implements MessageDispatcher
{
final String stripped = getStrippedFileName(aFileName);
final AuditEvent evt = new AuditEvent(this, stripped);
- for (AuditListener listener : mListeners) {
+ for (final AuditListener listener : mListeners) {
listener.fileStarted(evt);
}
}
@@ -492,7 +490,7 @@ public class Checker extends AutomaticBean implements MessageDispatcher
{
final String stripped = getStrippedFileName(aFileName);
final AuditEvent evt = new AuditEvent(this, stripped);
- for (AuditListener listener : mListeners) {
+ for (final AuditListener listener : mListeners) {
listener.fileFinished(evt);
}
}
@@ -506,10 +504,10 @@ public class Checker extends AutomaticBean implements MessageDispatcher
public void fireErrors(String aFileName, TreeSet aErrors)
{
final String stripped = getStrippedFileName(aFileName);
- for (LocalizedMessage element : aErrors) {
+ for (final LocalizedMessage element : aErrors) {
final AuditEvent evt = new AuditEvent(this, stripped, element);
if (mFilters.accept(evt)) {
- for (AuditListener listener : mListeners) {
+ for (final AuditListener listener : mListeners) {
listener.addError(evt);
}
}
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/CheckUtils.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/CheckUtils.java
index ba0bae14a..3ba3b8b27 100755
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/CheckUtils.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/CheckUtils.java
@@ -151,32 +151,33 @@ public final class CheckUtils
*/
public static double parseDouble(String aText, int aType)
{
+ String txt = aText;
double result = 0;
switch (aType) {
case TokenTypes.NUM_FLOAT:
case TokenTypes.NUM_DOUBLE:
- result = Double.parseDouble(aText);
+ result = Double.parseDouble(txt);
break;
case TokenTypes.NUM_INT:
case TokenTypes.NUM_LONG:
int radix = BASE_10;
- if (aText.startsWith("0x") || aText.startsWith("0X")) {
+ if (txt.startsWith("0x") || txt.startsWith("0X")) {
radix = BASE_16;
- aText = aText.substring(2);
+ txt = txt.substring(2);
}
- else if (aText.charAt(0) == '0') {
+ else if (txt.charAt(0) == '0') {
radix = BASE_8;
- aText = aText.substring(1);
+ txt = txt.substring(1);
}
- if ((aText.endsWith("L")) || (aText.endsWith("l"))) {
- aText = aText.substring(0, aText.length() - 1);
+ if ((txt.endsWith("L")) || (txt.endsWith("l"))) {
+ txt = txt.substring(0, txt.length() - 1);
}
- if (aText.length() > 0) {
+ if (txt.length() > 0) {
if (aType == TokenTypes.NUM_INT) {
- result = parseInt(aText, radix);
+ result = parseInt(txt, radix);
}
else {
- result = parseLong(aText, radix);
+ result = parseLong(txt, radix);
}
}
break;
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenTextCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenTextCheck.java
index ba04b9f64..48b40bd6f 100755
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenTextCheck.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenTextCheck.java
@@ -84,7 +84,7 @@ public class IllegalTokenTextCheck
final Set tokenNames = getTokenNames();
final int[] result = new int[tokenNames.size()];
int i = 0;
- for (String name : tokenNames) {
+ for (final String name : tokenNames) {
result[i] = TokenTypes.getTokenId(name);
i++;
}
@@ -115,10 +115,7 @@ public class IllegalTokenTextCheck
*/
public void setMessage(String aMessage)
{
- if (aMessage == null) {
- aMessage = "";
- }
- mMessage = aMessage;
+ mMessage = (null == aMessage) ? "" : aMessage;
}
/**
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/indentation/ExpressionHandler.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/indentation/ExpressionHandler.java
index c15527135..16ee2bb6a 100755
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/indentation/ExpressionHandler.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/indentation/ExpressionHandler.java
@@ -228,15 +228,16 @@ public abstract class ExpressionHandler
* @param aIndentLevel the required indent level
*/
protected final void checkLinesIndent(int aStartLine, int aEndLine,
- IndentLevel aIndentLevel)
+ IndentLevel aIndentLevel)
{
// check first line
checkSingleLine(aStartLine, aIndentLevel);
// check following lines
- aIndentLevel = new IndentLevel(aIndentLevel, getBasicOffset());
+ final IndentLevel offsetLevel =
+ new IndentLevel(aIndentLevel, getBasicOffset());
for (int i = aStartLine + 1; i <= aEndLine; i++) {
- checkSingleLine(i, aIndentLevel);
+ checkSingleLine(i, offsetLevel);
}
}
@@ -289,10 +290,11 @@ public abstract class ExpressionHandler
// TODO: shouldIncreaseIndent() is a hack, should be removed
// after complete rewriting of checkExpressionSubtree()
+ IndentLevel theLevel = aIndentLevel;
if (aFirstLineMatches
|| ((aFirstLine > mMainAst.getLineNo()) && shouldIncreaseIndent()))
{
- aIndentLevel = new IndentLevel(aIndentLevel, getBasicOffset());
+ theLevel = new IndentLevel(aIndentLevel, getBasicOffset());
}
// check following lines
@@ -303,7 +305,7 @@ public abstract class ExpressionHandler
// checked by a child expression)
if (col != null) {
- checkSingleLine(i, col.intValue(), aIndentLevel, false);
+ checkSingleLine(i, col.intValue(), theLevel, false);
}
}
}
@@ -439,10 +441,10 @@ public abstract class ExpressionHandler
// find line for this node
// TODO: getLineNo should probably not return < 0, but it is for
// the interface methods... I should ask about this
-
+ int realStart = aStartLine;
final int currLine = aTree.getLineNo();
- if (currLine < aStartLine) {
- aStartLine = currLine;
+ if (currLine < realStart) {
+ realStart = currLine;
}
// check children
@@ -450,10 +452,10 @@ public abstract class ExpressionHandler
node != null;
node = node.getNextSibling())
{
- aStartLine = getFirstLine(aStartLine, node);
+ realStart = getFirstLine(realStart, node);
}
- return aStartLine;
+ return realStart;
}
/**
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/indentation/HandlerFactory.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/indentation/HandlerFactory.java
index 92efed497..5075fe6b3 100755
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/indentation/HandlerFactory.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/indentation/HandlerFactory.java
@@ -142,7 +142,7 @@ public class HandlerFactory
final Set typeSet = mTypeHandlers.keySet();
final int[] types = new int[typeSet.size()];
int index = 0;
- for (Integer val : typeSet) {
+ for (final Integer val : typeSet) {
types[index++] = val;
}
@@ -215,15 +215,16 @@ public class HandlerFactory
ExpressionHandler createMethodCallHandler(IndentationCheck aIndentCheck,
DetailAST aAst, ExpressionHandler aParent)
{
+ ExpressionHandler theParent = aParent;
DetailAST ast = aAst.getFirstChild();
while ((ast != null) && (ast.getType() == TokenTypes.DOT)) {
ast = ast.getFirstChild();
}
if ((ast != null) && isHandledType(ast.getType())) {
- aParent = getHandler(aIndentCheck, ast, aParent);
- mCreatedHandlers.put(ast, aParent);
+ theParent = getHandler(aIndentCheck, ast, theParent);
+ mCreatedHandlers.put(ast, theParent);
}
- return new MethodCallHandler(aIndentCheck, aAst, aParent);
+ return new MethodCallHandler(aIndentCheck, aAst, theParent);
}
/** Clears cache of created handlers. */
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheck.java
index 9f013fba1..da47e4f33 100755
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheck.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheck.java
@@ -78,25 +78,26 @@ public class ParenPadCheck extends AbstractParenPadCheck
@Override
public void visitToken(DetailAST aAST)
{
+ DetailAST theAst = aAST;
// Strange logic in this method to guard against checking RPAREN tokens
// that are associated with a TYPECAST token.
- if (aAST.getType() != TokenTypes.RPAREN) {
- if ((aAST.getType() == TokenTypes.CTOR_CALL)
- || (aAST.getType() == TokenTypes.SUPER_CTOR_CALL))
+ if (theAst.getType() != TokenTypes.RPAREN) {
+ if ((theAst.getType() == TokenTypes.CTOR_CALL)
+ || (theAst.getType() == TokenTypes.SUPER_CTOR_CALL))
{
- aAST = aAST.getFirstChild();
+ theAst = theAst.getFirstChild();
}
- if (!isPreceedsEmptyForInit(aAST)) {
- processLeft(aAST);
+ if (!isPreceedsEmptyForInit(theAst)) {
+ processLeft(theAst);
}
}
- else if ((aAST.getParent() == null)
- || (aAST.getParent().getType() != TokenTypes.TYPECAST)
- || (aAST.getParent().findFirstToken(TokenTypes.RPAREN)
- != aAST))
+ else if ((theAst.getParent() == null)
+ || (theAst.getParent().getType() != TokenTypes.TYPECAST)
+ || (theAst.getParent().findFirstToken(TokenTypes.RPAREN)
+ != theAst))
{
- if (!isFollowsEmptyForIterator(aAST)) {
- processRight(aAST);
+ if (!isFollowsEmptyForIterator(theAst)) {
+ processRight(theAst);
}
}
}