NestedTryDepth: prevent all nested try blocks
This commit is contained in:
parent
78b24a265d
commit
bb3aec4ab6
2 changed files with 7 additions and 9 deletions
12
README.md
12
README.md
|
@ -1551,19 +1551,17 @@ if (isValid()) { // depth 0
|
||||||
|
|
||||||
#### [NestedTryDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedTryDepth)
|
#### [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:
|
Valid:
|
||||||
````
|
````
|
||||||
try {
|
try {
|
||||||
doSomething();
|
doSomething();
|
||||||
try {
|
doSomeOtherThing();
|
||||||
doSomeOtherThing();
|
|
||||||
} catch (OtherExceptions oe) {
|
|
||||||
// handle it
|
|
||||||
}
|
|
||||||
} catch (SomeException se) {
|
} catch (SomeException se) {
|
||||||
// handle it
|
// 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)
|
#### [NewlineAtEndOfFile](http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile)
|
||||||
|
|
||||||
Checks that files end with a line-feed character, (i.e. unix-style line ending).
|
Checks that files end with a line-feed character, (i.e. unix-style line ending).
|
||||||
|
|
|
@ -143,7 +143,9 @@
|
||||||
<module name="NeedBraces"/> <!-- braces around code blocks -->
|
<module name="NeedBraces"/> <!-- braces around code blocks -->
|
||||||
<module name="NestedForDepth"/> <!-- prevent nested for loops -->
|
<module name="NestedForDepth"/> <!-- prevent nested for loops -->
|
||||||
<module name="NestedIfDepth"/> <!-- prevent nested if-else blocks -->
|
<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="NoClone"/> <!-- prevent overriding Object.clone() -->
|
||||||
<module name="NonEmptyAtclauseDescription"/> <!-- javadoc tags have descriptions -->
|
<module name="NonEmptyAtclauseDescription"/> <!-- javadoc tags have descriptions -->
|
||||||
<module name="NoWhitespaceAfter"/> <!-- prevent white space after tokens -->
|
<module name="NoWhitespaceAfter"/> <!-- prevent white space after tokens -->
|
||||||
|
|
Loading…
Reference in a new issue