Skip to content

Commit

Permalink
minor: renaming to comply with new config rules in main repo
Browse files Browse the repository at this point in the history
  • Loading branch information
nrmancuso authored and romani committed Apr 10, 2022
1 parent 9c88282 commit f3b1a08
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public void setAnnotationNames(final String... names) {
public void setAnnotationTargets(String... targets) {
if (targets != null) {
annotationTargets = new int[targets.length];
for (int i = 0; i < targets.length; i++) {
annotationTargets[i] = TokenUtil.getTokenId(targets[i]);
for (int index = 0; index < targets.length; index++) {
annotationTargets[index] = TokenUtil.getTokenId(targets[index]);
}
Arrays.sort(annotationTargets);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public class AvoidConstantAsFirstOperandInConditionCheck extends AbstractCheck {
public void setTargetConstantTypes(String... targets) {
if (targets != null) {
targetConstantTypes = new int[targets.length];
for (int i = 0; i < targets.length; i++) {
targetConstantTypes[i] = TokenUtil.getTokenId(targets[i]);
for (int index = 0; index < targets.length; index++) {
targetConstantTypes[index] = TokenUtil.getTokenId(targets[index]);
}
Arrays.sort(targetConstantTypes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@ public int[] getDefaultTokens() {
final int size = customOrderDeclaration.size();
final int[] tokenTypes = new int[size + 1];

for (int i = 0; i < size; i++) {
final FormatMatcher currentRule = customOrderDeclaration.get(i);
tokenTypes[i] = currentRule.getClassMember();
for (int index = 0; index < size; index++) {
final FormatMatcher currentRule = customOrderDeclaration.get(index);
tokenTypes[index] = currentRule.getClassMember();

if (currentRule.hasRule(INNER_CLASS_MACRO)) {
checkInnerClasses = true;
Expand Down Expand Up @@ -1371,8 +1371,8 @@ public Map<DetailAST, DetailAST> getWrongOrderedGettersSetters() {
// sort by line numbers
Collections.sort(allGettersSetters, AST_LINE_COMPARATOR);

for (int i = 0; i < allGettersSetters.size(); i++) {
result.putAll(getWrongOrderedGettersSetters(allGettersSetters, i));
for (int index = 0; index < allGettersSetters.size(); index++) {
result.putAll(getWrongOrderedGettersSetters(allGettersSetters, index));
}
}
return result;
Expand Down Expand Up @@ -1402,17 +1402,19 @@ else if (isBooleanGetterName(getterName)) {

if (getterField != null) {
// review rest of the list to find a proper setter
for (int j = 0; j < allGettersSetters.size(); j++) {
if (index != j) {
for (int allGettersSettersIndex = 0;
allGettersSettersIndex < allGettersSetters.size();
allGettersSettersIndex++) {
if (index != allGettersSettersIndex) {
// method is NOT getter
final DetailAST setterAst = allGettersSetters.get(j);
final DetailAST setterAst = allGettersSetters.get(allGettersSettersIndex);
final String setterName = getIdentifier(setterAst);
if (isSetterName(setterName)) {
final String setterField = getNameWithoutPrefix(
getIdentifier(setterAst), SETTER_PREFIX);

// if fields are same and setter is sibling with getter
if (j != index + 1
if (allGettersSettersIndex != index + 1
&& getterField.equals(setterField)) {
result.put(setterAst, getterAst);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ private static DetailAST[] getChilds(DetailAST node) {

DetailAST currNode = node.getFirstChild();

for (int i = 0; i < result.length; i++) {
result[i] = currNode;
for (int index = 0; index < result.length; index++) {
result[index] = currNode;
currNode = currNode.getNextSibling();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,8 @@ private static boolean numericSegmentPassesRequirement(String numericSegment,
final char underscore = '_';
int symbolCount = 0;

for (int i = 0; i < numericSegment.length(); i++) {
final char current = numericSegment.charAt(i);
for (int index = 0; index < numericSegment.length(); index++) {
final char current = numericSegment.charAt(index);
if (symbolCount >= symbolsUntilUnderscore && current != underscore) {
passes = false;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ private boolean isTestMethod(DetailAST method) {
boolean result = false;
if (method != null) {
result = importTest && AnnotationUtil.containsAnnotation(method, "Test");
for (int i = 0; !result && i < FQ_JUNIT_TESTS.size(); i++) {
result = AnnotationUtil.containsAnnotation(method, FQ_JUNIT_TESTS.get(i));
for (int index = 0; !result && index < FQ_JUNIT_TESTS.size(); index++) {
result = AnnotationUtil.containsAnnotation(method, FQ_JUNIT_TESTS.get(index));
}
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ private static boolean checkNameOfParameters(DetailAST parameters,
final DetailAST parameterDef = parameters
.findFirstToken(TokenTypes.PARAMETER_DEF);

for (int i = 0; i < parametersChildCount && !isNameOfParameter; i++) {
for (int index = 0; index < parametersChildCount && !isNameOfParameter; index++) {
isNameOfParameter = parameterDef.findFirstToken(TokenTypes.IDENT).getText()
.equals(fieldName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ private boolean isIsolatedTernaryOnLine(DetailAST questionAST) {
private boolean isSingleTernaryLine(String line, int lineNo) {
int questionsPerLine = 0;
final char[] charArrayFromLine = line.toCharArray();
for (int i = 0; i < line.length(); i++) {
final char currentSymbol = charArrayFromLine[i];
for (int index = 0; index < line.length(); index++) {
final char currentSymbol = charArrayFromLine[index];
if (currentSymbol == '?' && !getFileContents().hasIntersectionWithComment(lineNo + 1,
i, lineNo + 1, i)) {
index, lineNo + 1, index)) {
questionsPerLine++;
}
if (questionsPerLine > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ private static boolean inTokenList(int type, int... tokens) {
// HashMap to do the searches.

boolean found = false;
for (int i = 0; i < tokens.length && !found; i++) {
found = tokens[i] == type;
for (int index = 0; index < tokens.length && !found; index++) {
found = tokens[index] == type;
}
return found;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public class ChildBlockLengthCheck extends AbstractCheck {
**/
public void setBlockTypes(final String... blockTypes) {
this.blockTypes = new int[blockTypes.length];
for (int i = 0; i < blockTypes.length; i++) {
this.blockTypes[i] = TokenUtil.getTokenId(blockTypes[i]);
for (int index = 0; index < blockTypes.length; index++) {
this.blockTypes[index] = TokenUtil.getTokenId(blockTypes[index]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ private void logViolation(DetailAST member, String enumName, BitSet violated) {
*/
private BitSet match(String name, BitSet conformedPatterns) {
final BitSet result = new BitSet(patternCount);
for (int i = 0; i < patterns.size(); i++) {
if (conformedPatterns.get(i)) {
final Pattern pattern = patterns.get(i);
for (int index = 0; index < patterns.size(); index++) {
if (conformedPatterns.get(index)) {
final Pattern pattern = patterns.get(index);
if (pattern.matcher(name).find()) {
result.set(i);
result.set(index);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,17 @@ public void beginTree(DetailAST rootAST) {

@Override
public void finishTree(DetailAST rootAST) {
for (int i = 0; i < lines.length; i++) {
if (lines[i] == null) {
for (int index = 0; index < lines.length; index++) {
if (lines[index] == null) {
continue;
}

final String line = lines[i];
final String line = lines[index];
final int realLength = CommonUtil.lengthExpandedTabs(line,
line.length(), getTabWidth());

if (realLength > max && !ignorePattern.matcher(line).find()) {
log(i + 1, MSG_KEY, max, realLength);
log(index + 1, MSG_KEY, max, realLength);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public static Set<String> getCheckStyleChecksReferencedInConfig(String configFil
final NodeList nodeList = document.getElementsByTagName("module");

final Set<String> checksReferencedInCheckstyleChecksXml = new HashSet<>();
for (int i = 0; i < nodeList.getLength(); i++) {
final Node currentNode = nodeList.item(i);
for (int index = 0; index < nodeList.getLength(); index++) {
final Node currentNode = nodeList.item(index);
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
final Element module = (Element) currentNode;
final String checkName = module.getAttribute("name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,20 @@ public void verifyTestConfigurationFiles() throws Exception {

// eclipsecs

for (String p : packages) {
for (String packageName : packages) {
Assertions.assertTrue(new File(
getEclipseCsPath(p)).exists(), "folder " + p + " must exist in eclipsecs");
getEclipseCsPath(packageName)).exists(), "folder " + packageName
+ " must exist in eclipsecs");

final Set<Class<?>> pkgModules = CheckUtil.getModulesInPackage(modules, p);
final Set<Class<?>> pkgModules = CheckUtil.getModulesInPackage(modules, packageName);

validateEclipseCsMetaXmlFile(
new File(getEclipseCsPath(p + "/checkstyle-metadata.xml")), p, new HashSet<>(
new File(getEclipseCsPath(packageName
+ "/checkstyle-metadata.xml")), packageName, new HashSet<>(
pkgModules));

validateEclipseCsMetaPropFile(new File(getEclipseCsPath(p
+ "/checkstyle-metadata.properties")), p, new HashSet<>(pkgModules));
validateEclipseCsMetaPropFile(new File(getEclipseCsPath(packageName
+ "/checkstyle-metadata.properties")), packageName, new HashSet<>(pkgModules));
}
}

Expand Down Expand Up @@ -389,9 +391,9 @@ private static Set<String> getProperties(Class<?> clss) {
final Set<String> result = new TreeSet<>();
final PropertyDescriptor[] map = PropertyUtils.getPropertyDescriptors(clss);

for (PropertyDescriptor p : map) {
if (p.getWriteMethod() != null) {
result.add(p.getName());
for (PropertyDescriptor descriptor : map) {
if (descriptor.getWriteMethod() != null) {
result.add(descriptor.getName());
}
}

Expand Down

0 comments on commit f3b1a08

Please sign in to comment.