Added MethodCount that checks the number of methods declared in
each type. This includes the number of each scope as well as an overall total. Thanks to Alexander Jesse for patch #1151669, which was the inspiration.
This commit is contained in:
parent
764360d861
commit
2a30b5aba2
|
|
@ -92,7 +92,7 @@ public final class MethodCountCheck extends Check
|
|||
};
|
||||
|
||||
/** default maximum number of methods */
|
||||
private static final int DEFAULT_MAX_METHODS = 999;
|
||||
private static final int DEFAULT_MAX_METHODS = 100;
|
||||
/** Maximum private methods. */
|
||||
private int mMaxPrivate = DEFAULT_MAX_METHODS;
|
||||
/** Maximum package methods. */
|
||||
|
|
|
|||
|
|
@ -353,6 +353,10 @@
|
|||
Checks that instance variable names conform to a format specified
|
||||
by the format property.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="config_sizes.html#MethodCount">MethodCount</a></td>
|
||||
<td>Checks the number of methods declared in each type.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="config_sizes.html#MethodLength">MethodLength</a></td>
|
||||
<td>
|
||||
|
|
|
|||
|
|
@ -525,5 +525,88 @@
|
|||
</subsection>
|
||||
</section>
|
||||
|
||||
<section name="MethodCount">
|
||||
<subsection name="Description">
|
||||
<p>
|
||||
Checks the number of methods declared in each type. This
|
||||
includes the number of each scope (<code>private</code>,
|
||||
<code>package</code>, <code>protected</code> and
|
||||
<code>public</code>) as well as an overall total.
|
||||
</p>
|
||||
</subsection>
|
||||
|
||||
<subsection name="Properties">
|
||||
<table>
|
||||
<tr>
|
||||
<th>name</th>
|
||||
<th>description</th>
|
||||
<th>type</th>
|
||||
<th>default value</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maxTotal</td>
|
||||
<td>maximum allowable number of methods at all scope levels</td>
|
||||
<td><a href="property_types.html#integer">integer</a></td>
|
||||
<td>100</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maxPrivate</td>
|
||||
<td>maximum allowable number of <code>private</code> methods</td>
|
||||
<td><a href="property_types.html#integer">integer</a></td>
|
||||
<td>100</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maxPackage</td>
|
||||
<td>maximum allowable number of <code>package</code> methods</td>
|
||||
<td><a href="property_types.html#integer">integer</a></td>
|
||||
<td>100</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maxProtected</td>
|
||||
<td>maximum allowable number of <code>protected</code> methods</td>
|
||||
<td><a href="property_types.html#integer">integer</a></td>
|
||||
<td>100</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maxPublic</td>
|
||||
<td>maximum allowable number of <code>public</code> methods</td>
|
||||
<td><a href="property_types.html#integer">integer</a></td>
|
||||
<td>100</td>
|
||||
</tr>
|
||||
</table>
|
||||
</subsection>
|
||||
|
||||
<subsection name="Examples">
|
||||
<p>
|
||||
To configure the check with defaults:
|
||||
</p>
|
||||
<source>
|
||||
<module name="MethodCount"/>
|
||||
</source>
|
||||
|
||||
<p>
|
||||
To configure the check to allow at most 30 methods per type:
|
||||
</p>
|
||||
<source>
|
||||
<module name="MethodCount">
|
||||
<property name="maxTotal" value="30"/>
|
||||
</module>
|
||||
</source>
|
||||
|
||||
</subsection>
|
||||
|
||||
<subsection name="Package">
|
||||
<p>
|
||||
com.puppycrawl.tools.checkstyle.checks.sizes
|
||||
</p>
|
||||
</subsection>
|
||||
|
||||
<subsection name="Parent Module">
|
||||
<p>
|
||||
<a href="config.html#TreeWalker">TreeWalker</a>
|
||||
</p>
|
||||
</subsection>
|
||||
</section>
|
||||
|
||||
</body>
|
||||
</document>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
depth (default = 1). Thanks to Alexander Jesse for patch
|
||||
#1151673.
|
||||
</li>
|
||||
<li>
|
||||
Added <a href="config_sizes.html#MethodCount">MethodCount</a>
|
||||
that checks the number of methods declared in each type. This
|
||||
includes the number of each scope (<code>private</code>,
|
||||
<code>package</code>, <code>protected</code> and
|
||||
<code>public</code>) as well as an overall total. Thanks to
|
||||
Alexander Jesse for patch #1151669, which was the inspiration.
|
||||
</li>
|
||||
</ul>
|
||||
<p>Bug fixes:</p>
|
||||
<ul>
|
||||
|
|
|
|||
Loading…
Reference in New Issue