Skip to content

Commit

Permalink
Issue #7615: Update doc for ThrowsCount
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-kukreja authored and strkkk committed Mar 28, 2020
1 parent 2625cbb commit 2324d2c
Show file tree
Hide file tree
Showing 2 changed files with 185 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,40 @@
* </li>
* </ul>
* <p>
* To configure check:
* </p>
* <pre>
* &lt;module name="ThrowsCount"/&gt;
* </pre>
* <p>
* Example:
* </p>
* <pre>
* class Test {
* public void myFunction() throws CloneNotSupportedException,
* ArrayIndexOutOfBoundsException,
* StringIndexOutOfBoundsException,
* IllegalStateException,
* NullPointerException { // violation, max allowed is 4
* // body
* }
*
* public void myFunc() throws ArithmeticException,
* NumberFormatException { // ok
* // body
* }
*
* private void privateFunc() throws CloneNotSupportedException,
* ClassNotFoundException,
* IllegalAccessException,
* ArithmeticException,
* ClassCastException { // ok, private methods are ignored
* // body
* }
*
* }
* </pre>
* <p>
* To configure the check so that it doesn't allow more than two throws per method:
* </p>
* <pre>
Expand All @@ -70,13 +104,72 @@
* &lt;/module&gt;
* </pre>
* <p>
* Example:
* </p>
* <pre>
* class Test {
* public void myFunction() throws IllegalStateException,
* ArrayIndexOutOfBoundsException,
* NullPointerException { // violation, max allowed is 2
* // body
* }
*
* public void myFunc() throws ArithmeticException,
* NumberFormatException { // ok
* // body
* }
*
* private void privateFunc() throws CloneNotSupportedException,
* ClassNotFoundException,
* IllegalAccessException,
* ArithmeticException,
* ClassCastException { // ok, private methods are ignored
* // body
* }
*
* }
* </pre>
* <p>
* To configure the check so that it doesn't skip private methods:
* </p>
* <pre>
* &lt;module name="ThrowsCount"&gt;
* &lt;property name=&quot;ignorePrivateMethods&quot; value=&quot;false&quot;/&gt;
* &lt;/module&gt;
* </pre>
* <p>
* Example:
* </p>
* <pre>
* class Test {
* public void myFunction() throws CloneNotSupportedException,
* ArrayIndexOutOfBoundsException,
* StringIndexOutOfBoundsException,
* IllegalStateException,
* NullPointerException { // violation, max allowed is 4
* // body
* }
*
* public void myFunc() throws ArithmeticException,
* NumberFormatException { // ok
* // body
* }
*
* private void privateFunc() throws CloneNotSupportedException,
* ClassNotFoundException,
* IllegalAccessException,
* ArithmeticException,
* ClassCastException { // violation, max allowed is 4
* // body
* }
*
* private void func() throws IllegalStateException,
* NullPointerException { // ok
* // body
* }
*
* }
* </pre>
*
* @since 3.2
*/
Expand Down
92 changes: 92 additions & 0 deletions src/xdocs/config_design.xml
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,40 @@ public class Foo { // OK, only one top-level class
</subsection>

<subsection name="Examples" id="ThrowsCount_Examples">
<p>
To configure check:
</p>
<source>
&lt;module name="ThrowsCount"/&gt;
</source>
<p>
Example:
</p>
<source>
class Test {
public void myFunction() throws CloneNotSupportedException,
ArrayIndexOutOfBoundsException,
StringIndexOutOfBoundsException,
IllegalStateException,
NullPointerException { // violation, max allowed is 4
// body
}

public void myFunc() throws ArithmeticException,
NumberFormatException { // ok
// body
}

private void privateFunc() throws CloneNotSupportedException,
ClassNotFoundException,
IllegalAccessException,
ArithmeticException,
ClassCastException { // ok, private methods are ignored
// body
}

}
</source>
<p>
To configure the check so that it doesn't allow more than two throws
per method:
Expand All @@ -855,7 +889,32 @@ public class Foo { // OK, only one top-level class
&lt;property name=&quot;max&quot; value=&quot;2&quot;/&gt;
&lt;/module&gt;
</source>
<p>
Example:
</p>
<source>
class Test {
public void myFunction() throws IllegalStateException,
ArrayIndexOutOfBoundsException,
NullPointerException { // violation, max allowed is 2
// body
}

public void myFunc() throws ArithmeticException,
NumberFormatException { // ok
// body
}

private void privateFunc() throws CloneNotSupportedException,
ClassNotFoundException,
IllegalAccessException,
ArithmeticException,
ClassCastException { // ok, private methods are ignored
// body
}

}
</source>
<p>
To configure the check so that it doesn't skip private methods:
</p>
Expand All @@ -864,6 +923,39 @@ public class Foo { // OK, only one top-level class
&lt;property name=&quot;ignorePrivateMethods&quot; value=&quot;false&quot;/&gt;
&lt;/module&gt;
</source>
<p>
Example:
</p>
<source>
class Test {
public void myFunction() throws CloneNotSupportedException,
ArrayIndexOutOfBoundsException,
StringIndexOutOfBoundsException,
IllegalStateException,
NullPointerException { // violation, max allowed is 4
// body
}

public void myFunc() throws ArithmeticException,
NumberFormatException { // ok
// body
}

private void privateFunc() throws CloneNotSupportedException,
ClassNotFoundException,
IllegalAccessException,
ArithmeticException,
ClassCastException { // violation, max allowed is 4
// body
}

private void func() throws IllegalStateException,
NullPointerException { // ok
// body
}

}
</source>
</subsection>

<subsection name="Example of Usage" id="ThrowsCount_Example_of_Usage">
Expand Down

0 comments on commit 2324d2c

Please sign in to comment.