Issue #2080: name violations are fixed, checkstyle suppressions were updated to validate names in tests too
This commit is contained in:
parent
c269a41736
commit
78103da033
|
|
@ -13,6 +13,10 @@
|
|||
<suppress checks="AbbreviationAsWordInName"
|
||||
files="JavaNCSSCheck.java"
|
||||
lines="41"/>
|
||||
<!-- test should be named as their main class -->
|
||||
<suppress checks="AbbreviationAsWordInName"
|
||||
files="JavaNCSSCheckTest.java"
|
||||
lines="41"/>
|
||||
|
||||
<!-- illegal words are part of Javadoc -->
|
||||
<suppress checks="TodoComment" files=".*TodoCommentCheck\.java"/>
|
||||
|
|
@ -28,6 +32,9 @@
|
|||
<!-- 'Abstract' pattern is used to show it is checking for abstract class name -->
|
||||
<suppress checks="AbstractClassNameCheck"
|
||||
files="AbstractClassNameCheck.java"/>
|
||||
<!-- test should be named as their main class -->
|
||||
<suppress checks="AbstractClassNameCheck"
|
||||
files="AbstractClassNameCheckTest.java|AbstractTypeAwareCheckTest.java|AbstractJavadocCheckTest.java|AbstractViolationReporterTest.java"/>
|
||||
|
||||
<!-- Tone down the checking for test code -->
|
||||
<suppress checks="EmptyBlock" files=".*[\\/]src[\\/]test[\\/]"/>
|
||||
|
|
@ -43,7 +50,6 @@
|
|||
<!-- suppressions to remove over time -->
|
||||
<suppress checks="FinalLocalVariable" files=".*[\\/]src[\\/]test[\\/]"/>
|
||||
<suppress checks="LineLength" files=".*[\\/]src[\\/]test[\\/]"/>
|
||||
<suppress checks="Name" files=".*[\\/]src[\\/]test[\\/]"/>
|
||||
|
||||
<!--
|
||||
Turn off all checks for Generated and Test code. Fixes issues with using
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@ public class ConfigurationLoaderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLoadConfiguration_WrongURL() throws CheckstyleException {
|
||||
public void testLoadConfigurationWrongURL() throws CheckstyleException {
|
||||
try {
|
||||
final DefaultConfiguration config =
|
||||
(DefaultConfiguration) ConfigurationLoader.loadConfiguration(
|
||||
|
|
@ -451,7 +451,7 @@ public class ConfigurationLoaderTest {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testLoadConfiguration_URISyntaxException() throws CheckstyleException {
|
||||
public void testLoadConfigurationURISyntaxException() throws CheckstyleException {
|
||||
mockStatic(ConfigurationLoader.class, Mockito.CALLS_REAL_METHODS);
|
||||
|
||||
PropertiesExpander expander = new PropertiesExpander(new Properties());
|
||||
|
|
@ -472,7 +472,7 @@ public class ConfigurationLoaderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLoadConfiguration_Deprecated() throws CheckstyleException {
|
||||
public void testLoadConfigurationDeprecated() throws CheckstyleException {
|
||||
try {
|
||||
@SuppressWarnings("deprecation")
|
||||
final DefaultConfiguration config =
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ public class MainTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testExistingTargetFilePlainOutputToFileWithoutReadAndRwPermissions()
|
||||
public void testExistingFilePlainOutputToFileWithoutReadAndRwPermissions()
|
||||
throws Exception {
|
||||
final File file = temporaryFolder.newFile("file.output");
|
||||
// That works fine on Linux/Unix, but ....
|
||||
|
|
@ -401,7 +401,7 @@ public class MainTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLoadProperties_IOException() throws Exception {
|
||||
public void testLoadPropertiesIOException() throws Exception {
|
||||
Class<?>[] param = new Class<?>[1];
|
||||
param[0] = File.class;
|
||||
Method method = Main.class.getDeclaredMethod("loadProperties", param);
|
||||
|
|
@ -432,7 +432,7 @@ public class MainTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateListener_IllegalStateException() throws Exception {
|
||||
public void testCreateListenerIllegalStateException() throws Exception {
|
||||
Method method = Main.class.getDeclaredMethod("createListener", String.class, String.class);
|
||||
method.setAccessible(true);
|
||||
try {
|
||||
|
|
@ -446,7 +446,7 @@ public class MainTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateListenerWithLocation_IllegalStateException() throws Exception {
|
||||
public void testCreateListenerWithLocationIllegalStateException() throws Exception {
|
||||
Method method = Main.class.getDeclaredMethod("createListener", String.class, String.class);
|
||||
method.setAccessible(true);
|
||||
String outDir = "myfolder123";
|
||||
|
|
@ -499,7 +499,7 @@ public class MainTest {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testListFiles_notFile() throws Exception {
|
||||
public void testListFilesNotFile() throws Exception {
|
||||
Method method = Main.class.getDeclaredMethod("listFiles", File.class);
|
||||
method.setAccessible(true);
|
||||
|
||||
|
|
@ -514,7 +514,7 @@ public class MainTest {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testListFiles_DirectoryWithNull() throws Exception {
|
||||
public void testListFilesDirectoryWithNull() throws Exception {
|
||||
Method method = Main.class.getDeclaredMethod("listFiles", File.class);
|
||||
method.setAccessible(true);
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ public class PackageNamesLoaderTest {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testPackagesWithIoException_getResources() throws Exception {
|
||||
public void testPackagesWithIoExceptionGetResources() throws Exception {
|
||||
|
||||
ClassLoader classLoader = mock(ClassLoader.class);
|
||||
when(classLoader.getResources("checkstyle_packages.xml")).thenThrow(IOException.class);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public class PropertyCacheFileTest {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testException_NoSuchAlgorithmException() throws Exception {
|
||||
public void testExceptionNoSuchAlgorithmException() throws Exception {
|
||||
|
||||
Configuration config = new DefaultConfiguration("myName");
|
||||
final String filePath = temporaryFolder.newFile().getPath();
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ public class TreeWalkerTest extends BaseCheckTestSupport {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCacheFile_changeInConfig() throws Exception {
|
||||
public void testCacheFileChangeInConfig() throws Exception {
|
||||
final DefaultConfiguration checkConfig = createCheckConfig(HiddenFieldCheck.class);
|
||||
|
||||
final DefaultConfiguration treeWalkerConfig = createCheckConfig(TreeWalker.class);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import com.puppycrawl.tools.checkstyle.DefaultContext;
|
|||
public class AutomaticBeanTest {
|
||||
|
||||
@Test
|
||||
public void testConfigure_NoSuchAttribute() {
|
||||
public void testConfigureNoSuchAttribute() {
|
||||
final TestBean testBean = new TestBean();
|
||||
final DefaultConfiguration conf = new DefaultConfiguration("testConf");
|
||||
conf.addAttribute("NonExisting", "doesn't matter");
|
||||
|
|
@ -48,7 +48,7 @@ public class AutomaticBeanTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testConfigure_NoSuchAttribute2() {
|
||||
public void testConfigureNoSuchAttribute2() {
|
||||
final TestBean testBean = new TestBean();
|
||||
final DefaultConfiguration conf = new DefaultConfiguration("testConf");
|
||||
conf.addAttribute("privateField", "doesn't matter");
|
||||
|
|
@ -68,7 +68,7 @@ public class AutomaticBeanTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testContextualize_InvocationTargetException() {
|
||||
public void testContextualizeInvocationTargetException() {
|
||||
final TestBean testBean = new TestBean();
|
||||
DefaultContext context = new DefaultContext();
|
||||
context.add("exceptionalMethod", 123.0f);
|
||||
|
|
@ -83,7 +83,7 @@ public class AutomaticBeanTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testContextualize_ConversionException() {
|
||||
public void testContextualizeConversionException() {
|
||||
final TestBean testBean = new TestBean();
|
||||
DefaultContext context = new DefaultContext();
|
||||
context.add("val", "some string");
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class LocalizedMessageTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testBundleReload_UrlNull() throws IOException {
|
||||
public void testBundleReloadUrlNull() throws IOException {
|
||||
LocalizedMessage.UTF8Control cntrl = new LocalizedMessage.UTF8Control();
|
||||
cntrl.newBundle("com.puppycrawl.tools.checkstyle.checks.coding.messages",
|
||||
Locale.ENGLISH, "java.class",
|
||||
|
|
@ -71,7 +71,7 @@ public class LocalizedMessageTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testBundleReload_UrlNotNull() throws IOException {
|
||||
public void testBundleReloadUrlNotNull() throws IOException {
|
||||
|
||||
ClassLoader classloader = mock(ClassLoader.class);
|
||||
final URLConnection mockConnection = Mockito.mock(URLConnection.class);
|
||||
|
|
@ -89,7 +89,7 @@ public class LocalizedMessageTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testBundleReload_UrlNotNullStreamNull() throws IOException {
|
||||
public void testBundleReloadUrlNotNullStreamNull() throws IOException {
|
||||
|
||||
ClassLoader classloader = mock(ClassLoader.class);
|
||||
String resource = "com/puppycrawl/tools/checkstyle/checks/coding/messages_en.properties";
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testNLOW() throws Exception {
|
||||
public void testNlow() throws Exception {
|
||||
checkConfig.addAttribute("option", LeftCurlyOption.NLOW.toString());
|
||||
final String[] expected = {
|
||||
"8:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1),
|
||||
|
|
|
|||
|
|
@ -476,19 +476,19 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_1168408_1() throws Exception {
|
||||
public void test11684081() throws Exception {
|
||||
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
verify(checkConfig, getPath("checks/javadoc/Input_01.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_1168408_2() throws Exception {
|
||||
public void test11684082() throws Exception {
|
||||
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
verify(checkConfig, getPath("checks/javadoc/Input_02.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_1168408_3() throws Exception {
|
||||
public void test11684083() throws Exception {
|
||||
checkConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
|
||||
checkConfig.addAttribute("allowUndeclaredRTE", "true");
|
||||
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
|
|
@ -496,7 +496,7 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_generics_1() throws Exception {
|
||||
public void testGenerics1() throws Exception {
|
||||
checkConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
|
||||
checkConfig.addAttribute("allowUndeclaredRTE", "true");
|
||||
checkConfig.addAttribute("validateThrows", "true");
|
||||
|
|
@ -511,7 +511,7 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_generics_2() throws Exception {
|
||||
public void testGenerics2() throws Exception {
|
||||
checkConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
|
||||
checkConfig.addAttribute("validateThrows", "true");
|
||||
final String[] expected = {
|
||||
|
|
@ -525,7 +525,7 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_generics_3() throws Exception {
|
||||
public void testGenerics3() throws Exception {
|
||||
checkConfig.addAttribute("validateThrows", "true");
|
||||
final String[] expected = {
|
||||
"8:8: " + getCheckMessage(MSG_UNUSED_TAG, "@throws", "RE"),
|
||||
|
|
@ -539,7 +539,7 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_1379666() throws Exception {
|
||||
public void test1379666() throws Exception {
|
||||
checkConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
|
||||
checkConfig.addAttribute("allowUndeclaredRTE", "true");
|
||||
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
|
|
|
|||
|
|
@ -597,7 +597,7 @@ public class CommentsTest extends BaseCheckTestSupport {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCompareExpectedTreeWithInput_1() throws Exception {
|
||||
public void testCompareExpectedTreeWithInput1() throws Exception {
|
||||
DefaultConfiguration checkConfig = createCheckConfig(CompareTreesWithComments.class);
|
||||
CompareTreesWithComments.expectedTree = buildInput1();
|
||||
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
|
|
@ -606,7 +606,7 @@ public class CommentsTest extends BaseCheckTestSupport {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCompareExpectedTreeWithInput_2() throws Exception {
|
||||
public void testCompareExpectedTreeWithInput2() throws Exception {
|
||||
DefaultConfiguration checkConfig = createCheckConfig(CompareTreesWithComments.class);
|
||||
CompareTreesWithComments.expectedTree = buildInput2();
|
||||
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public class SuppressElementTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDecideByFileNameAndModuleMatching_FileNameNull() {
|
||||
public void testDecideByFileNameAndModuleMatchingFileNameNull() {
|
||||
LocalizedMessage message =
|
||||
new LocalizedMessage(10, 10, "", "", null, null, getClass(), null);
|
||||
final AuditEvent ev = new AuditEvent(this, null, message);
|
||||
|
|
@ -91,13 +91,13 @@ public class SuppressElementTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDecideByFileNameAndModuleMatching_MessageNull() {
|
||||
public void testDecideByFileNameAndModuleMatchingMessageNull() {
|
||||
final AuditEvent ev = new AuditEvent(this, "ATest.java", null);
|
||||
assertTrue(filter.accept(ev));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecideByFileNameAndModuleMatching_ModuleNull() {
|
||||
public void testDecideByFileNameAndModuleMatchingModuleNull() {
|
||||
LocalizedMessage message =
|
||||
new LocalizedMessage(10, 10, "", "", null, "MyModule", getClass(), null);
|
||||
final AuditEvent ev = new AuditEvent(this, "ATest.java", message);
|
||||
|
|
@ -106,7 +106,7 @@ public class SuppressElementTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDecideByFileNameAndModuleMatching_ModuleEqual() {
|
||||
public void testDecideByFileNameAndModuleMatchingModuleEqual() {
|
||||
LocalizedMessage message =
|
||||
new LocalizedMessage(10, 10, "", "", null, "MyModule", getClass(), null);
|
||||
final AuditEvent ev = new AuditEvent(this, "ATest.java", message);
|
||||
|
|
@ -115,7 +115,7 @@ public class SuppressElementTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDecideByFileNameAndModuleMatching_ModuleNotEqual() {
|
||||
public void testDecideByFileNameAndModuleMatchingModuleNotEqual() {
|
||||
LocalizedMessage message =
|
||||
new LocalizedMessage(10, 10, "", "", null, "TheirModule", getClass(), null);
|
||||
final AuditEvent ev = new AuditEvent(this, "ATest.java", message);
|
||||
|
|
@ -124,7 +124,7 @@ public class SuppressElementTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDecideByFileNameAndModuleMatching_RegExpNotMatch() {
|
||||
public void testDecideByFileNameAndModuleMatchingRegExpNotMatch() {
|
||||
LocalizedMessage message =
|
||||
new LocalizedMessage(10, 10, "", "", null, null, getClass(), null);
|
||||
final AuditEvent ev = new AuditEvent(this, "T1est", message);
|
||||
|
|
@ -132,7 +132,7 @@ public class SuppressElementTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDecideByFileNameAndModuleMatching_RegExpMatch() {
|
||||
public void testDecideByFileNameAndModuleMatchingRegExpMatch() {
|
||||
LocalizedMessage message =
|
||||
new LocalizedMessage(10, 10, "", "", null, null, getClass(), null);
|
||||
final AuditEvent ev = new AuditEvent(this, "TestSUFFIX", message);
|
||||
|
|
@ -141,7 +141,7 @@ public class SuppressElementTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDecideByFileNameAndModuleMatching_CheckRegExpNotMatch() {
|
||||
public void testDecideByFileNameAndModuleMatchingCheckRegExpNotMatch() {
|
||||
LocalizedMessage message =
|
||||
new LocalizedMessage(10, 10, "", "", null, null, getClass(), null);
|
||||
final AuditEvent ev = new AuditEvent(this, "ATest.java", message);
|
||||
|
|
@ -150,7 +150,7 @@ public class SuppressElementTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDecideByFileNameAndModuleMatching_CheckRegExpMatch() {
|
||||
public void testDecideByFileNameAndModuleMatchingCheckRegExpMatch() {
|
||||
LocalizedMessage message =
|
||||
new LocalizedMessage(10, 10, "", "", null, null, getClass(), null);
|
||||
final AuditEvent ev = new AuditEvent(this, "ATest.java", message);
|
||||
|
|
|
|||
Loading…
Reference in New Issue