Issue #1293: Refactoring of InnerAssignmentCheck

This commit is contained in:
Baratali Izmailov 2015-07-24 00:14:40 -07:00 committed by Roman Ivanov
parent dba2da926c
commit 779d30b759
2 changed files with 11 additions and 6 deletions

View File

@ -1122,7 +1122,6 @@
<regex><pattern>.*.checks.coding.FinalLocalVariableCheck</pattern><branchRate>83</branchRate><lineRate>100</lineRate></regex>
<regex><pattern>.*.checks.coding.IllegalInstantiationCheck</pattern><branchRate>81</branchRate><lineRate>97</lineRate></regex>
<regex><pattern>.*.checks.coding.IllegalTypeCheck</pattern><branchRate>93</branchRate><lineRate>94</lineRate></regex>
<regex><pattern>.*.checks.coding.InnerAssignmentCheck</pattern><branchRate>88</branchRate><lineRate>100</lineRate></regex>
<regex><pattern>.*.checks.coding.ModifiedControlVariableCheck</pattern><branchRate>91</branchRate><lineRate>97</lineRate></regex>
<regex><pattern>.*.checks.coding.OverloadMethodsDeclarationOrderCheck</pattern><branchRate>93</branchRate><lineRate>100</lineRate></regex>
<regex><pattern>.*.checks.coding.ParameterAssignmentCheck</pattern><branchRate>80</branchRate><lineRate>96</lineRate></regex>

View File

@ -191,7 +191,7 @@ public class InnerAssignmentCheck
}
final DetailAST expr = ast.getParent();
final AST exprNext = expr.getNextSibling();
return exprNext != null && exprNext.getType() == TokenTypes.SEMI;
return exprNext.getType() == TokenTypes.SEMI;
}
/**
@ -237,20 +237,26 @@ public class InnerAssignmentCheck
* one of the allowed type paths
*/
private static boolean isInContext(DetailAST ast, int[]... contextSet) {
boolean found = false;
for (int[] element : contextSet) {
DetailAST current = ast;
final int len = element.length;
for (int j = 0; j < len; j++) {
current = current.getParent();
final int expectedType = element[j];
if (current == null || current.getType() != expectedType) {
if (current.getType() != expectedType) {
found = false;
break;
}
if (j == len - 1) {
return true;
else {
found = true;
}
}
if (found) {
break;
}
}
return false;
return found;
}
}