NestedTryDepth: prevent all nested try blocks

This commit is contained in:
Paul Campbell 2016-09-05 17:37:06 +01:00
parent 78b24a265d
commit bb3aec4ab6
2 changed files with 7 additions and 9 deletions

View file

@ -1551,19 +1551,17 @@ if (isValid()) { // depth 0
#### [NestedTryDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedTryDepth)
Checks that `try` blocks are not nested more than 1 deep.
Checks that `try` blocks are not nested.
Valid:
````
try {
doSomething();
try {
doSomeOtherThing();
} catch (OtherExceptions oe) {
// handle it
}
doSomeOtherThing();
} catch (SomeException se) {
// handle it
} catch (OtherExceptions oe) {
// handle it
}
````
@ -1581,8 +1579,6 @@ try {
}
````
> TODO: max = 0 - don't nest try blocks
#### [NewlineAtEndOfFile](http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile)
Checks that files end with a line-feed character, (i.e. unix-style line ending).

View file

@ -143,7 +143,9 @@
<module name="NeedBraces"/> <!-- braces around code blocks -->
<module name="NestedForDepth"/> <!-- prevent nested for loops -->
<module name="NestedIfDepth"/> <!-- prevent nested if-else blocks -->
<module name="NestedTryDepth"/> <!-- prevent nested try blocks -->
<module name="NestedTryDepth"> <!-- prevent nested try blocks -->
<property name="max" value="0"/>
</module>
<module name="NoClone"/> <!-- prevent overriding Object.clone() -->
<module name="NonEmptyAtclauseDescription"/> <!-- javadoc tags have descriptions -->
<module name="NoWhitespaceAfter"/> <!-- prevent white space after tokens -->