moving/renaming [Illegal]AbstractClassName check to naming package.
This commit is contained in:
parent
d69cc899d0
commit
ec796dc641
|
|
@ -31,9 +31,6 @@
|
|||
<li>
|
||||
<a href="#HideUtilityClassConstructor">HideUtilityClassConstructor</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#IllegalAbstractClassName">IllegalAbstractClassName</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#InterfaceIsType">InterfaceIsType</a>
|
||||
</li>
|
||||
|
|
@ -349,52 +346,6 @@ public class StringUtils // not final to allow subclassing
|
|||
<a href="config.html#treewalker">TreeWalker</a>
|
||||
</p>
|
||||
|
||||
<!-- --> <a name="IllegalAbstractClassName"></a> <h2>IllegalAbstractClassName</h2>
|
||||
<h4>Description</h4>
|
||||
<p class="body">
|
||||
Ensures that the names of abstract classes conforming to some
|
||||
regular expression.
|
||||
</p>
|
||||
|
||||
<p class="body">
|
||||
Rationale:
|
||||
Abtsract classes are conevnience base class
|
||||
implementations of interfaces not types as such. As
|
||||
such they should be named to indicate this.
|
||||
</p>
|
||||
|
||||
<h4>Properties</h4>
|
||||
<table width="100%" border="1" cellpadding="5" class="body">
|
||||
<tr class="header">
|
||||
<th>name</th>
|
||||
<th>description</th>
|
||||
<th>type</th>
|
||||
<th>default value</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>format</td>
|
||||
<td>pattern for abstract class name.</td>
|
||||
<td><a href="property_types.html#regexp">regular expression</a></td>
|
||||
<td><span class="default">^Abstract.*$|^.*Factory$</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h4>Examples</h4>
|
||||
<p class="body">
|
||||
To configure the check:
|
||||
</p>
|
||||
<pre class="body">
|
||||
<module name="IllegalAbstractClassName"/>
|
||||
</pre>
|
||||
<h4>Package</h4>
|
||||
<p class="body">
|
||||
com.puppycrawl.tools.checkstyle.checks.design
|
||||
</p>
|
||||
<h4>Parent Module</h4>
|
||||
<p class="body">
|
||||
<a href="config.html#treewalker">TreeWalker</a>
|
||||
</p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@
|
|||
<th>validates identifiers for</th>
|
||||
<th>default value of <span class="code">format</span></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="code">AbstractClassName</span></td>
|
||||
<td><span class="code">abstract</span> classes</td>
|
||||
<td><span class="default">^Abstract.*$|^.*Factory$</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="code">ConstantName</span></td>
|
||||
<td>constants (<span class="code">static</span>, <span class="code">
|
||||
|
|
|
|||
|
|
@ -3,4 +3,3 @@ final.class=Class {0} should be declared as final.
|
|||
interface.type=interfaces should describe a type and hence have methods.
|
||||
variable.notPrivate=Variable ''{0}'' must be private and have accessor methods.
|
||||
mutable.exception=The field ''{0}'' must be declared final.
|
||||
illegal.abstract.class.name=Name ''{0}'' must match pattern ''{1}''.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.design;
|
||||
package com.puppycrawl.tools.checkstyle.checks.naming;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
||||
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
||||
|
|
@ -35,13 +35,13 @@ import com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck;
|
|||
*
|
||||
* @author <a href="mailto:simon@redhillconsulting.com.au">Simon Harris</a>
|
||||
*/
|
||||
public final class IllegalAbstractClassNameCheck extends AbstractFormatCheck
|
||||
public final class AbstractClassNameCheck extends AbstractFormatCheck
|
||||
{
|
||||
/** Defualt format for abstract class names */
|
||||
private static final String DEFAULT_FORMAT = "^Abstract.*$|^.*Factory$";
|
||||
|
||||
/** Creates new instance of the check. */
|
||||
public IllegalAbstractClassNameCheck()
|
||||
public AbstractClassNameCheck()
|
||||
{
|
||||
super(DEFAULT_FORMAT);
|
||||
}
|
||||
|
|
@ -1 +1,2 @@
|
|||
name.invalidPattern=Name ''{0}'' must match pattern ''{1}''.
|
||||
illegal.abstract.class.name=Name ''{0}'' must match pattern ''{1}''.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package com.puppycrawl.tools.checkstyle.checks.design;
|
||||
package com.puppycrawl.tools.checkstyle.checks.naming;
|
||||
|
||||
abstract public class InputAbstractClassName {
|
||||
}
|
||||
|
|
@ -47,7 +47,6 @@ import com.puppycrawl.tools.checkstyle.checks.coding.SuperFinalizeCheckTest;
|
|||
import com.puppycrawl.tools.checkstyle.checks.design.DesignForExtensionCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.design.HideUtilityClassConstructorCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.design.IllegalAbstractClassNameCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.design.InterfaceIsTypeCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.design.MutableExceptionCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheckTest;
|
||||
|
|
@ -72,6 +71,7 @@ import com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheckTest;
|
|||
import com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.javadoc.PackageHtmlCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.metrics.CyclomaticComplexityCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.naming.AbstractClassNameCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.naming.LocalFinalVariableNameCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheckTest;
|
||||
|
|
@ -120,6 +120,7 @@ public class AllTests {
|
|||
//$JUnit-BEGIN$
|
||||
suite.addTest(new TestSuite(CheckerTest.class));
|
||||
suite.addTest(new TestSuite(DetailASTTest.class));
|
||||
suite.addTest(new TestSuite(AbstractClassNameCheckTest.class));
|
||||
suite.addTest(new TestSuite(AbstractViolationReporterTest.class));
|
||||
suite.addTest(new TestSuite(AnonInnerLengthCheckTest.class));
|
||||
suite.addTest(new TestSuite(ArrayTypeStyleCheckTest.class));
|
||||
|
|
@ -145,7 +146,6 @@ public class AllTests {
|
|||
suite.addTest(new TestSuite(HeaderCheckTest.class));
|
||||
suite.addTest(new TestSuite(HiddenFieldCheckTest.class));
|
||||
suite.addTest(new TestSuite(HideUtilityClassConstructorCheckTest.class));
|
||||
suite.addTest(new TestSuite(IllegalAbstractClassNameCheckTest.class));
|
||||
suite.addTest(new TestSuite(IllegalCatchCheckTest.class));
|
||||
suite.addTest(new TestSuite(IllegalImportCheckTest.class));
|
||||
suite.addTest(new TestSuite(IllegalInstantiationCheckTest.class));
|
||||
|
|
|
|||
|
|
@ -1,23 +1,22 @@
|
|||
package com.puppycrawl.tools.checkstyle.checks.design;
|
||||
package com.puppycrawl.tools.checkstyle.checks.naming;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class IllegalAbstractClassNameCheckTest
|
||||
extends BaseCheckTestCase
|
||||
public class AbstractClassNameCheckTest extends BaseCheckTestCase
|
||||
{
|
||||
public void testIllegalAbstractClassName() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(IllegalAbstractClassNameCheck.class);
|
||||
createCheckConfig(AbstractClassNameCheck.class);
|
||||
final String[] expected = {
|
||||
"3:1: Name 'InputAbstractClassName' must match pattern '^Abstract.*$|^.*Factory$'.",
|
||||
"6:1: Name 'NonAbstractClassName' must match pattern '^Abstract.*$|^.*Factory$'.",
|
||||
"9:1: Name 'FactoryWithBadName' must match pattern '^Abstract.*$|^.*Factory$'.",
|
||||
"13:5: Name 'NonAbstractInnerClass' must match pattern '^Abstract.*$|^.*Factory$'.",
|
||||
};
|
||||
verify(checkConfig, getPath("design" + File.separator + "InputAbstractClassName.java"), expected);
|
||||
verify(checkConfig, getPath("naming" + File.separator + "InputAbstractClassName.java"), expected);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue