diff --git a/pom.xml b/pom.xml
index 1b90daccc..7667a9891 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1095,7 +1095,6 @@
.*.checks.coding.AbstractIllegalMethodCheck10093
- .*.checks.coding.AbstractNestedDepthCheck10093
.*.checks.coding.AbstractSuperCheck7889
.*.checks.coding.CovariantEqualsCheck9596
.*.checks.coding.DeclarationOrderCheck8293
@@ -1114,9 +1113,6 @@
.*.checks.coding.ModifiedControlVariableCheck9197
.*.checks.coding.MultipleStringLiteralsCheck9096
.*.checks.coding.MultipleVariableDeclarationsCheck96100
- .*.checks.coding.NestedForDepthCheck50100
- .*.checks.coding.NestedIfDepthCheck7588
- .*.checks.coding.NestedTryDepthCheck5087
.*.checks.coding.OneStatementPerLineCheck93100
.*.checks.coding.OverloadMethodsDeclarationOrderCheck93100
.*.checks.coding.PackageDeclarationCheck7585
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/AbstractNestedDepthCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/AbstractNestedDepthCheck.java
index 742d15ce4..7738d88f3 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/AbstractNestedDepthCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/AbstractNestedDepthCheck.java
@@ -51,14 +51,6 @@ public abstract class AbstractNestedDepthCheck extends Check {
depth = 0;
}
- /**
- * Getter for maximum allowed nesting depth.
- * @return maximum allowed nesting depth.
- */
- public final int getMax() {
- return max;
- }
-
/**
* Setter for maximum allowed nesting depth.
* @param max maximum allowed nesting depth.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedForDepthCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedForDepthCheck.java
index 17626a6bb..d24b6847a 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedForDepthCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedForDepthCheck.java
@@ -69,15 +69,11 @@ public final class NestedForDepthCheck extends AbstractNestedDepthCheck {
@Override
public void visitToken(DetailAST ast) {
- if (TokenTypes.LITERAL_FOR == ast.getType()) {
- nestIn(ast, MSG_KEY);
- }
+ nestIn(ast, MSG_KEY);
}
@Override
public void leaveToken(DetailAST ast) {
- if (TokenTypes.LITERAL_FOR == ast.getType()) {
- nestOut();
- }
+ nestOut();
}
}
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedIfDepthCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedIfDepthCheck.java
index f1c77ec29..f9d153760 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedIfDepthCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedIfDepthCheck.java
@@ -55,42 +55,17 @@ public final class NestedIfDepthCheck extends AbstractNestedDepthCheck {
}
@Override
- public void visitToken(DetailAST ast) {
- if (ast.getType() == TokenTypes.LITERAL_IF) {
- visitLiteralIf(ast);
- }
- else {
- throw new IllegalStateException(ast.toString());
- }
- }
-
- @Override
- public void leaveToken(DetailAST ast) {
- if (ast.getType() == TokenTypes.LITERAL_IF) {
- leaveLiteralIf(ast);
- }
- else {
- throw new IllegalStateException(ast.toString());
- }
- }
-
- /**
- * Increases current nesting depth.
- * @param literalIf node for if.
- */
- private void visitLiteralIf(DetailAST literalIf) {
+ public void visitToken(DetailAST literalIf) {
if (!CheckUtils.isElseIf(literalIf)) {
nestIn(literalIf, MSG_KEY);
}
}
- /**
- * Decreases current nesting depth.
- * @param literalIf node for if.
- */
- private void leaveLiteralIf(DetailAST literalIf) {
+ @Override
+ public void leaveToken(DetailAST literalIf) {
if (!CheckUtils.isElseIf(literalIf)) {
nestOut();
}
}
+
}
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedTryDepthCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedTryDepthCheck.java
index 27594290c..caa33edfb 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedTryDepthCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedTryDepthCheck.java
@@ -53,35 +53,13 @@ public final class NestedTryDepthCheck extends AbstractNestedDepthCheck {
}
@Override
- public void visitToken(DetailAST ast) {
- if (ast.getType() == TokenTypes.LITERAL_TRY) {
- visitLiteralTry(ast);
- }
- else {
- throw new IllegalStateException(ast.toString());
- }
- }
-
- @Override
- public void leaveToken(DetailAST ast) {
- if (ast.getType() == TokenTypes.LITERAL_TRY) {
- leaveLiteralTry();
- }
- else {
- throw new IllegalStateException(ast.toString());
- }
- }
-
- /**
- * Increases current nesting depth.
- * @param literalTry node for try.
- */
- private void visitLiteralTry(DetailAST literalTry) {
+ public void visitToken(DetailAST literalTry) {
nestIn(literalTry, MSG_KEY);
}
- /** Decreases current nesting depth */
- private void leaveLiteralTry() {
+ @Override
+ public void leaveToken(DetailAST literalTry) {
nestOut();
}
+
}