Skip to content

Commit

Permalink
Merge 2d5cd5c into ff5cbc3
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhavik3 committed Feb 16, 2015
2 parents ff5cbc3 + 2d5cd5c commit 8d93762
Show file tree
Hide file tree
Showing 43 changed files with 81 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ private Checker createChecker()

// setup the listeners
final AuditListener[] listeners = getListeners();
for (AuditListener element : listeners) {
for (final AuditListener element : listeners) {
c.addListener(element);
}
}
Expand Down Expand Up @@ -419,14 +419,14 @@ private Properties createOverridingProperties()

// override with Ant properties like ${basedir}
final Hashtable<?, ?> antProps = this.getProject().getProperties();
for (Object name : antProps.keySet()) {
for (final Object name : antProps.keySet()) {
final String key = (String) name;
final String value = String.valueOf(antProps.get(key));
retVal.put(key, value);
}

// override with properties specified in subelements
for (Property p : overrideProps) {
for (final Property p : overrideProps) {
retVal.put(p.getKey(), p.getValue());
}

Expand Down Expand Up @@ -486,7 +486,7 @@ protected List<File> scanFileSets()
log(i + ") Adding " + names.length + " files from directory "
+ ds.getBasedir(), Project.MSG_VERBOSE);

for (String element : names) {
for (final String element : names) {
final String pathname = ds.getBasedir() + File.separator
+ element;
list.add(new File(pathname));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/puppycrawl/tools/checkstyle/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private static List<File> getFilesToProcess(CommandLine line)
{
final List<File> files = Lists.newLinkedList();
final String[] remainingArgs = line.getArgs();
for (String element : remainingArgs) {
for (final String element : remainingArgs) {
traverse(new File(element), files);
}

Expand Down Expand Up @@ -257,7 +257,7 @@ private static void traverse(File node, List<File> files)
if (node.canRead()) {
if (node.isDirectory()) {
final File[] nodes = node.listFiles();
for (File element : nodes) {
for (final File element : nodes) {
traverse(element, files);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void startElement(String namespaceURI,
private String getPackageName()
{
final StringBuilder buf = new StringBuilder();
for (String subPackage : packageStack) {
for (final String subPackage : packageStack) {
buf.append(subPackage);
if (!subPackage.endsWith(".")) {
buf.append(".");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private Object doMakeObject(String name)
}

//now try packages
for (String packageName : packages) {
for (final String packageName : packages) {

final String className = packageName + name;
try {
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private void registerCheck(Check check)
//register configured tokens
final int[] acceptableTokens = check.getAcceptableTokens();
Arrays.sort(acceptableTokens);
for (String token : checkTokens) {
for (final String token : checkTokens) {
final int tokenId = TokenTypes.getTokenId(token);
if (Arrays.binarySearch(acceptableTokens, tokenId) >= 0) {
registerCheck(token, check);
Expand All @@ -323,7 +323,7 @@ private void registerCheck(Check check)
else {
tokens = check.getDefaultTokens();
}
for (int element : tokens) {
for (final int element : tokens) {
registerCheck(element, check);
}
if (check.isCommentNodesRequired()) {
Expand Down Expand Up @@ -404,7 +404,7 @@ private void notifyBegin(DetailAST rootAST, FileContents contents
checks = ordinaryChecks;
}

for (Check ch : checks) {
for (final Check ch : checks) {
ch.setFileContents(contents);
ch.beginTree(rootAST);
}
Expand All @@ -426,7 +426,7 @@ private void notifyEnd(DetailAST rootAST, AstState astState)
checks = ordinaryChecks;
}

for (Check ch : checks) {
for (final Check ch : checks) {
ch.finishTree(rootAST);
}
}
Expand Down Expand Up @@ -454,7 +454,7 @@ private void notifyVisit(DetailAST ast, AstState astState)
visitors = tokenToOrdinaryChecks.get(tokenType);
}

for (Check c : visitors) {
for (final Check c : visitors) {
c.visitToken(ast);
}
}
Expand Down Expand Up @@ -483,7 +483,7 @@ private void notifyLeave(DetailAST ast, AstState astState)
visitors = tokenToOrdinaryChecks.get(tokenType);
}

for (Check ch : visitors) {
for (final Check ch : visitors) {
ch.leaveToken(ast);
}
}
Expand Down Expand Up @@ -528,10 +528,10 @@ public static DetailAST parse(FileContents contents)
@Override
public void destroy()
{
for (Check c : ordinaryChecks) {
for (final Check c : ordinaryChecks) {
c.destroy();
}
for (Check c : commentChecks) {
for (final Check c : commentChecks) {
c.destroy();
}
cache.destroy();
Expand Down Expand Up @@ -750,7 +750,7 @@ private static Entry<Integer, Integer> countLinesColumns(
{
int lines = initialLinesCnt;
int columns = initialColumnsCnt;
for (char c : text.toCharArray()) {
for (final char c : text.toCharArray()) {
switch (c) {
case '\n':
lines++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public boolean isReference(String ent)
}

final String name = ent.substring(1, ent.length() - 1);
for (String element : ENTITIES) {
for (final String element : ENTITIES) {
if (name.equals(element)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public boolean equals(Object object)
@Override
public boolean accept(AuditEvent event)
{
for (Filter filter : filters) {
for (final Filter filter : filters) {
if (!filter.accept(event)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Class<?> resolve(String name, String currentClass)
}

// try matching explicit imports
for (String imp : imports) {
for (final String imp : imports) {
// Very important to add the "." in the check below. Otherwise you
// when checking for "DataException", it will match on
// "SecurityDataException". This has been the cause of a very
Expand Down Expand Up @@ -106,7 +106,7 @@ public Class<?> resolve(String name, String currentClass)
}

// try star imports
for (String imp : imports) {
for (final String imp : imports) {
if (imp.endsWith(".*")) {
final String fqn = imp.substring(0, imp.lastIndexOf('.') + 1)
+ name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public void visitToken(DetailAST ast)

if (sumTokenCounts) {
int total = 0;
for (int element : limitedTokens) {
for (final int element : limitedTokens) {
total += counts[element - 1];
}
if (total < minimumNumber) {
Expand All @@ -225,7 +225,7 @@ public void visitToken(DetailAST ast)
}
}
else {
for (int element : limitedTokens) {
for (final int element : limitedTokens) {
final int tokenCount = counts[element - 1];
if (tokenCount < minimumNumber) {
final String descendantName = TokenTypes
Expand Down Expand Up @@ -284,7 +284,7 @@ public int[] getAcceptableTokens()
final Set<String> 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);
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public static void registerAlias(String sourceName, String checkAlias)
*/
public void setAliasList(String aliasList)
{
for (String sourceAlias : aliasList.split(",")) {
for (final String sourceAlias : aliasList.split(",")) {
final int index = sourceAlias.indexOf("=");
if (index > 0) {
registerAlias(sourceAlias.substring(0, index), sourceAlias
Expand Down Expand Up @@ -204,7 +204,7 @@ public static boolean isSuppressed(String sourceName, int line,
final List<Entry> entries = ENTRIES.get();
final String checkAlias = getAlias(sourceName);
if (entries != null && checkAlias != null) {
for (Entry entry : entries) {
for (final Entry entry : entries) {
final boolean afterStart =
entry.getFirstLine() < line
|| (entry.getFirstLine() == line && entry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void beginTree(DetailAST rootAST)
lines.addAll(cppComments.keySet());
lines.addAll(cComments.keySet());

for (Integer lineNo : lines) {
for (final Integer lineNo : lines) {
final String line = getLines()[lineNo.intValue() - 1];
String lineBefore = "";
TextBlock comment = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private void compareKeySets(Set<Object> keys,
{
final Set<Entry<File, Set<Object>>> fls = fileMap.entrySet();

for (Entry<File, Set<Object>> entry : fls) {
for (final Entry<File, Set<Object>> entry : fls) {
final File currentFile = entry.getKey();
final MessageDispatcher dispatcher = getMessageDispatcher();
final String path = currentFile.getPath();
Expand All @@ -250,7 +250,7 @@ private void compareKeySets(Set<Object> keys,

// Remaining elements in the key set are missing in the current file
if (!keysClone.isEmpty()) {
for (Object key : keysClone) {
for (final Object key : keysClone) {
log(0, "translation.missingKey", key);
}
}
Expand All @@ -274,15 +274,15 @@ private void checkPropertyFileSets(Map<String, Set<File>> propFiles)
{
final Set<Entry<String, Set<File>>> entrySet = propFiles.entrySet();

for (Entry<String, Set<File>> entry : entrySet) {
for (final Entry<String, Set<File>> entry : entrySet) {
final Set<File> files = entry.getValue();

if (files.size() >= 2) {
// build a map from files to the keys they contain
final Set<Object> keys = Sets.newHashSet();
final Map<File, Set<Object>> fileMap = Maps.newHashMap();

for (File file : files) {
for (final File file : files) {
final Set<Object> fileKeys = loadKeys(file);
keys.addAll(fileKeys);
fileMap.put(file, fileKeys);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected void processFiltered(File file, List<String> lines)
e.getLocalizedMessage());
}

for (Entry<String> duplication : properties
for (final Entry<String> duplication : properties
.getDuplicatedStrings().entrySet())
{
final String keyName = duplication.getElement();
Expand Down Expand Up @@ -100,7 +100,7 @@ protected int getLineNumber(List<String> lines, String keyName)
final Pattern keyPattern = Pattern.compile(keyPatternString);
int lineNumber = 1;
final Matcher matcher = keyPattern.matcher("");
for (String line : lines) {
for (final String line : lines) {
matcher.reset(line);
if (matcher.matches()) {
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void visitToken(DetailAST ast)

// report equals method definitions
if (!hasEqualsObject) {
for (DetailAST equalsAST : equalsMethods) {
for (final DetailAST equalsAST : equalsMethods) {
final DetailAST nameNode = equalsAST
.findFirstToken(TokenTypes.IDENT);
log(nameNode.getLineNo(), nameNode.getColumnNo(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private boolean isObjectParam(AST firstChild)
public void finishTree(DetailAST rootAST)
{
final Set<DetailAST> equalsDefs = objBlockEquals.keySet();
for (DetailAST objBlock : equalsDefs) {
for (final DetailAST objBlock : equalsDefs) {
if (!objBlockWithHashCode.contains(objBlock)) {
final DetailAST equalsAST = objBlockEquals.get(objBlock);
log(equalsAST.getLineNo(), equalsAST.getColumnNo(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public void visitToken(DetailAST ast)
}
case TokenTypes.VARIABLE_DEF:
if ((ast.getParent().getType() != TokenTypes.OBJBLOCK)
&& (ast.getParent().getType() != TokenTypes.FOR_EACH_CLAUSE)
&& isFirstVariableInForInit(ast))
{
insertVariable(ast);
Expand Down Expand Up @@ -228,7 +227,7 @@ public void leaveToken(DetailAST ast)
case TokenTypes.INSTANCE_INIT:
case TokenTypes.METHOD_DEF:
final Map<String, DetailAST> state = scopeStack.pop();
for (DetailAST var : state.values()) {
for (final DetailAST var : state.values()) {
log(var.getLineNo(), var.getColumnNo(), "final.variable", var
.getText());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void visitToken(DetailAST detailAST)
paradef.findFirstToken(TokenTypes.TYPE);
final List<DetailAST> excTypes = getAllExceptionTypes(excTypeParent);

for (DetailAST excType : excTypes) {
for (final DetailAST excType : excTypes) {
final FullIdent ident = FullIdent.createFullIdent(excType);

if (isIllegalClassName(ident.getText())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void visitToken(DetailAST ast)
@Override
public void finishTree(DetailAST rootAST)
{
for (DetailAST literalNewAST : instantiations) {
for (final DetailAST literalNewAST : instantiations) {
postprocessLiteralNew(literalNewAST);
}
}
Expand Down Expand Up @@ -239,7 +239,7 @@ private String getIllegalInstantiation(String className)
final int clsNameLen = className.length();
final int pkgNameLen = (pkgName == null) ? 0 : pkgName.length();

for (String illegal : illegalClasses) {
for (final String illegal : illegalClasses) {
final int illegalLen = illegal.length();

// class from java.lang
Expand Down Expand Up @@ -291,7 +291,7 @@ private String getIllegalInstantiation(String className)
return illegal;
}
// import statements
for (FullIdent importLineText : imports) {
for (final FullIdent importLineText : imports) {
final String importArg = importLineText.getText();
if (importArg.endsWith(".*")) {
final String fqClass =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public int[] getAcceptableTokens()
if (!tokenNames.isEmpty()) {
tokensToCopy = new int[tokenNames.size()];
int i = 0;
for (String name : tokenNames) {
for (final String name : tokenNames) {
tokensToCopy[i] = TokenTypes.getTokenId(name);
i++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public String[] getLegalAbstractClassNames()
public void setMemberModifiers(String modifiers)
{
final List<Integer> modifiersList = new ArrayList<>(modifiers.length());
for (String modifier : modifiers.split(", ")) {
for (final String modifier : modifiers.split(", ")) {
modifiersList.add(TokenTypes.getTokenId(modifier));
}
this.memberModifiers = modifiersList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private static boolean isComparison(DetailAST ast)
*/
private static boolean isInContext(DetailAST ast, int[][] contextSet)
{
for (int[] element : contextSet) {
for (final int[] element : contextSet) {
DetailAST current = ast;
final int len = element.length;
for (int j = 0; j < len; j++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void beginTree(DetailAST rootAST)
public void finishTree(DetailAST rootAST)
{
final Set<String> keys = stringMap.keySet();
for (String key : keys) {
for (final String key : keys) {
final List<StringInfo> hits = stringMap.get(key);
if (hits.size() > allowedDuplicates) {
final StringInfo firstFinding = hits.get(0);
Expand Down

0 comments on commit 8d93762

Please sign in to comment.