Fix and suppress PMD violations from ShortClassName rule, issue #982
This commit is contained in:
parent
4ac32a7c0c
commit
b29ca6b5f6
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
<subpackage name="checks">
|
||||
<allow pkg="com.puppycrawl.tools.checkstyle.checks"/>
|
||||
<allow class="com.puppycrawl.tools.checkstyle.Defn"/>
|
||||
<allow class="com.puppycrawl.tools.checkstyle.Definitions"/>
|
||||
<allow pkg="java.math"/>
|
||||
|
||||
<subpackage name="indentation">
|
||||
|
|
|
|||
|
|
@ -164,9 +164,14 @@
|
|||
<exclude name="AbstractNaming"/>
|
||||
<exclude name="AvoidFieldNameMatchingMethodName"/>
|
||||
<exclude name="LongVariable"/>
|
||||
<exclude name="ShortClassName"/>
|
||||
<exclude name="ShortVariable"/>
|
||||
</rule>
|
||||
<rule ref="rulesets/java/naming.xml/ShortClassName">
|
||||
<properties>
|
||||
<!-- Main is good name for class containing main method, Tag as inner class name is also fine -->
|
||||
<property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='Main' or @Image='Tag']"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="rulesets/java/optimizations.xml">
|
||||
<!--produces more false-positives than real problems-->
|
||||
<exclude name="AvoidInstantiatingObjectsInLoops"/>
|
||||
|
|
|
|||
2
pom.xml
2
pom.xml
|
|
@ -613,7 +613,7 @@
|
|||
|
||||
<regex><pattern>.*.DefaultConfiguration</pattern><branchRate>100</branchRate><lineRate>92</lineRate></regex>
|
||||
<regex><pattern>.*.DefaultLogger</pattern><branchRate>75</branchRate><lineRate>76</lineRate></regex>
|
||||
<regex><pattern>.*.Defn</pattern><branchRate>100</branchRate><lineRate>0</lineRate></regex>
|
||||
<regex><pattern>.*.Definitions</pattern><branchRate>100</branchRate><lineRate>0</lineRate></regex>
|
||||
<regex><pattern>.*.Main</pattern><branchRate>0</branchRate><lineRate>0</lineRate></regex>
|
||||
<regex><pattern>.*.PackageNamesLoader</pattern><branchRate>78</branchRate><lineRate>72</lineRate></regex>
|
||||
<regex><pattern>.*.PackageObjectFactory</pattern><branchRate>75</branchRate><lineRate>75</lineRate></regex>
|
||||
|
|
|
|||
|
|
@ -275,13 +275,13 @@ public class Checker extends AutomaticBean implements MessageDispatcher
|
|||
catch (final FileNotFoundException fnfe) {
|
||||
LOG.debug("FileNotFoundException occured.", fnfe);
|
||||
fileMessages.add(new LocalizedMessage(0,
|
||||
Defn.CHECKSTYLE_BUNDLE, "general.fileNotFound", null,
|
||||
Definitions.CHECKSTYLE_BUNDLE, "general.fileNotFound", null,
|
||||
null, this.getClass(), null));
|
||||
}
|
||||
catch (final IOException ioe) {
|
||||
LOG.debug("IOException occured.", ioe);
|
||||
fileMessages.add(new LocalizedMessage(0,
|
||||
Defn.CHECKSTYLE_BUNDLE, "general.exception",
|
||||
Definitions.CHECKSTYLE_BUNDLE, "general.exception",
|
||||
new String[] {ioe.getMessage()}, null, this.getClass(),
|
||||
null));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ package com.puppycrawl.tools.checkstyle;
|
|||
* Contains constant definitions common to the package.
|
||||
* @author Oliver Burn
|
||||
**/
|
||||
public final class Defn
|
||||
public final class Definitions
|
||||
{
|
||||
/**
|
||||
* Do no allow <code>Defn</code> instances to be created.
|
||||
* Do no allow <code>Definitions</code> instances to be created.
|
||||
**/
|
||||
private Defn()
|
||||
private Definitions()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -242,7 +242,7 @@ public final class TreeWalker
|
|||
{
|
||||
return new LocalizedMessage(
|
||||
0,
|
||||
Defn.CHECKSTYLE_BUNDLE,
|
||||
Definitions.CHECKSTYLE_BUNDLE,
|
||||
"general.exception",
|
||||
new String[] {message },
|
||||
getId(),
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import com.google.common.collect.Lists;
|
|||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.io.Closeables;
|
||||
import com.puppycrawl.tools.checkstyle.Defn;
|
||||
import com.puppycrawl.tools.checkstyle.Definitions;
|
||||
import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck;
|
||||
import com.puppycrawl.tools.checkstyle.api.LocalizedMessage;
|
||||
import com.puppycrawl.tools.checkstyle.api.MessageDispatcher;
|
||||
|
|
@ -227,7 +227,7 @@ public class TranslationCheck
|
|||
final LocalizedMessage message =
|
||||
new LocalizedMessage(
|
||||
0,
|
||||
Defn.CHECKSTYLE_BUNDLE,
|
||||
Definitions.CHECKSTYLE_BUNDLE,
|
||||
key,
|
||||
args,
|
||||
getId(),
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class UnusedImportsCheckTest extends BaseCheckTestSupport
|
|||
"37:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.Checker"),
|
||||
"38:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.CheckerTest"),
|
||||
"39:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport"),
|
||||
"40:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.Defn"),
|
||||
"40:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.Definitions"),
|
||||
"41:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.Input15Extensions"),
|
||||
"42:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.ConfigurationLoaderTest"),
|
||||
"43:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.CheckStyleTask"),
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import java.util.BitSet;
|
|||
import com.puppycrawl.tools.checkstyle.Checker;
|
||||
import com.puppycrawl.tools.checkstyle.CheckerTest;
|
||||
import com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.Defn;
|
||||
import com.puppycrawl.tools.checkstyle.Definitions;
|
||||
import com.puppycrawl.tools.checkstyle.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.ConfigurationLoaderTest;
|
||||
import com.puppycrawl.tools.checkstyle.CheckStyleTask;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import java.util.BitSet;
|
|||
import com.puppycrawl.tools.checkstyle.Checker;
|
||||
import com.puppycrawl.tools.checkstyle.CheckerTest;
|
||||
import com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.Defn;
|
||||
import com.puppycrawl.tools.checkstyle.Definitions;
|
||||
import com.puppycrawl.tools.checkstyle.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.ConfigurationLoaderTest;
|
||||
import com.puppycrawl.tools.checkstyle.CheckStyleTask;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import java.util.BitSet;
|
|||
import com.puppycrawl.tools.checkstyle.Checker;
|
||||
import com.puppycrawl.tools.checkstyle.CheckerTest;
|
||||
import com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.Defn;
|
||||
import com.puppycrawl.tools.checkstyle.Definitions;
|
||||
import com.puppycrawl.tools.checkstyle.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.ConfigurationLoaderTest;
|
||||
import com.puppycrawl.tools.checkstyle.CheckStyleTask;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import java.util.BitSet;
|
|||
import com.puppycrawl.tools.checkstyle.Checker;
|
||||
import com.puppycrawl.tools.checkstyle.CheckerTest;
|
||||
import com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.Defn;
|
||||
import com.puppycrawl.tools.checkstyle.Definitions;
|
||||
import com.puppycrawl.tools.checkstyle.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.ConfigurationLoaderTest;
|
||||
import com.puppycrawl.tools.checkstyle.CheckStyleTask;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import java.util.BitSet;
|
|||
import com.puppycrawl.tools.checkstyle.Checker;
|
||||
import com.puppycrawl.tools.checkstyle.CheckerTest;
|
||||
import com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.Defn;
|
||||
import com.puppycrawl.tools.checkstyle.Definitions;
|
||||
import com.puppycrawl.tools.checkstyle.Input15Extensions;
|
||||
import com.puppycrawl.tools.checkstyle.ConfigurationLoaderTest;
|
||||
import com.puppycrawl.tools.checkstyle.CheckStyleTask;
|
||||
|
|
@ -100,7 +100,7 @@ class InputUnusedImportsCheck
|
|||
|
||||
/**
|
||||
* First is a class with a method with arguments {@link Checker#method1(CheckerTest)}.
|
||||
* Next is a class with typed method {@link BaseFileSetCheckTestSupport#method2(Defn, Input15Extensions)}.
|
||||
* Next is a class with typed method {@link BaseFileSetCheckTestSupport#method2(Definitions, Input15Extensions)}.
|
||||
*
|
||||
* @param param1 with a link {@link ConfigurationLoaderTest}
|
||||
* @throws CheckStyleTask when broken
|
||||
|
|
|
|||
Loading…
Reference in New Issue