renamed DesignForInheritanceCheck to DesignForExtensionCheck
This commit is contained in:
parent
3925906fae
commit
9bb2ad91c9
|
|
@ -47,7 +47,7 @@
|
|||
i.e. if you get error messages from this check you should be
|
||||
able to name a good reason to implement your code the way you do it,
|
||||
especially if you are designing a library and not an application. -->
|
||||
<module name="DesignForInheritance">
|
||||
<module name="DesignForExtension">
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
<a href="#HideUtilityClassConstructor">HideUtilityClassConstructor</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#DesignForInheritance">DesignForInheritance</a>
|
||||
<a href="#DesignForExtension">DesignForExtension</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
|
|
@ -239,9 +239,9 @@ public class StringUtils // not final to allow subclassing
|
|||
<a href="config.html#treewalker">TreeWalker</a>
|
||||
</p>
|
||||
|
||||
<!-- --> <a name="DesignForInheritance"></a> <h2>DesignForInheritance</h2> <h4>Description</h4>
|
||||
<!-- --> <a name="DesignForExtension"></a> <h2>DesignForExtension</h2> <h4>Description</h4>
|
||||
<p class="body">
|
||||
Checks that classes are designed for inheritance.
|
||||
Checks that classes are designed for extension.
|
||||
More specifically, it enforces a programming style
|
||||
where superclasses provide empty "hooks" that can be
|
||||
implemented by subclasses.
|
||||
|
|
@ -273,7 +273,7 @@ public class StringUtils // not final to allow subclassing
|
|||
To configure the check:
|
||||
</p>
|
||||
<pre class="body">
|
||||
<module name="DesignForInheritance"/>
|
||||
<module name="DesignForExtension"/>
|
||||
</pre>
|
||||
<h4>Package</h4>
|
||||
<p class="body">
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@
|
|||
|
||||
<li class="body">Added check to enforce an API design that shields
|
||||
classes against bugs in derived classes (module
|
||||
DesignForInheritance, request 659715).</li>
|
||||
DesignForExtension, request 659715).</li>
|
||||
|
||||
<li class="body">Added check to enforce that Interfaces do not
|
||||
contain only constants (module InterfaceIsType, request 659717, see
|
||||
|
|
|
|||
|
|
@ -53,9 +53,9 @@ import com.puppycrawl.tools.checkstyle.api.ScopeUtils;
|
|||
* </p>
|
||||
*
|
||||
* @author lkuehne
|
||||
* @version $Revision: 1.5 $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
public class DesignForInheritanceCheck extends Check
|
||||
public class DesignForExtensionCheck extends Check
|
||||
{
|
||||
/** @see Check */
|
||||
public int[] getDefaultTokens()
|
||||
|
|
@ -119,7 +119,7 @@ public class DesignForInheritanceCheck extends Check
|
|||
if (hasDefaultConstructor || hasExplNonPrivateCtor) {
|
||||
String name = aAST.findFirstToken(TokenTypes.IDENT).getText();
|
||||
log(aAST.getLineNo(), aAST.getColumnNo(),
|
||||
"design.forInheritance", name);
|
||||
"design.forExtension", name);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ simplify.boolreturn=Conditional logic can be removed.
|
|||
|
||||
doublechecked.locking.avoid=The double-checked locking idiom is broken and should be avoided.
|
||||
|
||||
design.forInheritance=Method ''{0}'' is not designed for inheritance - needs to be abstract, final or empty.
|
||||
design.forExtension=Method ''{0}'' is not designed for extension - needs to be abstract, final or empty.
|
||||
|
||||
final.class=Class {0} should be declared as final.
|
||||
missing.switch.default=switch without \"default\" clause.
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ simplify.boolreturn=Die Verzweigung sollte entfernt werden.
|
|||
|
||||
doublechecked.locking.avoid=Das ''double-checked locking'' Idiom sollte vermieden werden.
|
||||
|
||||
design.forInheritance=Die Methode ''{0}'' ist nicht für Vererbung entworfen - muss abstract, final oder leer sein.
|
||||
design.forExtension=Die Methode ''{0}'' ist nicht für Vererbung entworfen - muss abstract, final oder leer sein.
|
||||
|
||||
final.class=Die Klasse {0} sollte als final deklariert sein, da alle ihre Konstruktoren private sind.
|
||||
missing.switch.default=switch ohne \"default\".
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ simplify.boolreturn=Konditionaalilogiikan voisi poistaa.
|
|||
|
||||
doublechecked.locking.avoid=The double-checked locking idiom is broken and should be avoided.
|
||||
|
||||
design.forInheritance=Method ''{0}'' is not designed for inheritance - needs to be abstract, final or empty.
|
||||
design.forExtension=Method ''{0}'' is not designed for extension - needs to be abstract, final or empty.
|
||||
|
||||
final.class=Class {0} should be declared as final
|
||||
missing.switch.default=switch without \"default\" clause
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ simplify.boolreturn=Supprimez la logique conditionnelle.
|
|||
|
||||
doublechecked.locking.avoid=The double-checked locking idiom is broken and should be avoided.
|
||||
|
||||
design.forInheritance=Method ''{0}'' is not designed for inheritance - needs to be abstract, final or empty.
|
||||
design.forExtension=Method ''{0}'' is not designed for extension - needs to be abstract, final or empty.
|
||||
|
||||
final.class=Class {0} should be declared as final
|
||||
missing.switch.default=switch without \"default\" clause
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ simplify.boolreturn=A l
|
|||
|
||||
doublechecked.locking.avoid=The double-checked locking idiom is broken and should be avoided.
|
||||
|
||||
design.forInheritance=Method ''{0}'' is not designed for inheritance - needs to be abstract, final or empty.
|
||||
design.forExtension=Method ''{0}'' is not designed for inheritance - needs to be abstract, final or empty.
|
||||
|
||||
final.class=Class {0} should be declared as final
|
||||
missing.switch.default=switch without \"default\" clause
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ package com.puppycrawl.tools.checkstyle;
|
|||
* Test case for the "design for inheritance" check.
|
||||
* @author Lars Kühne
|
||||
**/
|
||||
public class InputDesignForInheritance
|
||||
public class InputDesignForExtension
|
||||
{
|
||||
// some methods that are OK
|
||||
|
||||
|
|
@ -5,7 +5,7 @@ import com.puppycrawl.tools.checkstyle.api.DetailASTTest;
|
|||
import com.puppycrawl.tools.checkstyle.checks.AvoidInlineConditionalsCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.AvoidStarImportTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.ConstantNameCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.DesignForInheritanceCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.DesignForExtensionCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.DoubleCheckedLockingCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.EmptyBlockCheckTest;
|
||||
import com.puppycrawl.tools.checkstyle.checks.EmptyForIteratorPadCheckTest;
|
||||
|
|
@ -91,7 +91,7 @@ public class AllTests {
|
|||
suite.addTest(new TestSuite(AvoidStarImportTest.class));
|
||||
suite.addTest(new TestSuite(ConfigurationLoaderTest.class));
|
||||
suite.addTest(new TestSuite(ConstantNameCheckTest.class));
|
||||
suite.addTest(new TestSuite(DesignForInheritanceCheckTest.class));
|
||||
suite.addTest(new TestSuite(DesignForExtensionCheckTest.class));
|
||||
suite.addTest(new TestSuite(DoubleCheckedLockingCheckTest.class));
|
||||
suite.addTest(new TestSuite(EmptyBlockCheckTest.class));
|
||||
suite.addTest(new TestSuite(EmptyForIteratorPadCheckTest.class));
|
||||
|
|
|
|||
|
|
@ -3,17 +3,17 @@ package com.puppycrawl.tools.checkstyle.checks;
|
|||
import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
|
||||
public class DesignForInheritanceCheckTest
|
||||
public class DesignForExtensionCheckTest
|
||||
extends BaseCheckTestCase
|
||||
{
|
||||
public void testIt() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(DesignForInheritanceCheck.class);
|
||||
createCheckConfig(DesignForExtensionCheck.class);
|
||||
final String[] expected = {
|
||||
"46:5: Method 'doh' is not designed for inheritance - needs to be abstract, final or empty.",
|
||||
"46:5: Method 'doh' is not designed for extension - needs to be abstract, final or empty.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputDesignForInheritance.java"), expected);
|
||||
verify(checkConfig, getPath("InputDesignForExtension.java"), expected);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ public class HideUtilityClassConstructorCheckTest
|
|||
createCheckConfig(HideUtilityClassConstructorCheck.class);
|
||||
final String[] expected = {
|
||||
};
|
||||
verify(checkConfig, getPath("InputDesignForInheritance.java"), expected);
|
||||
verify(checkConfig, getPath("InputDesignForExtension.java"), expected);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue