diff --git a/config/checkstyle_checks.xml b/config/checkstyle_checks.xml
index 474b8e438..e8a85bfd6 100644
--- a/config/checkstyle_checks.xml
+++ b/config/checkstyle_checks.xml
@@ -236,6 +236,7 @@
+
@@ -252,7 +253,6 @@
-
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/ConfigurationLoader.java b/src/main/java/com/puppycrawl/tools/checkstyle/ConfigurationLoader.java
index c9ce3290b..d993862e0 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/ConfigurationLoader.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/ConfigurationLoader.java
@@ -229,20 +229,6 @@ public final class ConfigurationLoader
/** flags if modules with the severity 'ignore' should be omitted. */
private final boolean omitIgnoredModules;
- /**
- * Creates mapping between local resources and dtd ids.
- * @return map between local resources and dtd ids.
- */
- private static Map createIdToResourceNameMap()
- {
- final Map map = Maps.newHashMap();
- map.put(DTD_PUBLIC_ID_1_0, DTD_RESOURCE_NAME_1_0);
- map.put(DTD_PUBLIC_ID_1_1, DTD_RESOURCE_NAME_1_1);
- map.put(DTD_PUBLIC_ID_1_2, DTD_RESOURCE_NAME_1_2);
- map.put(DTD_PUBLIC_ID_1_3, DTD_RESOURCE_NAME_1_3);
- return map;
- }
-
/**
* Creates a new ConfigurationLoader instance.
* @param overrideProps resolver for overriding properties
@@ -260,6 +246,20 @@ public final class ConfigurationLoader
this.omitIgnoredModules = omitIgnoredModules;
}
+ /**
+ * Creates mapping between local resources and dtd ids.
+ * @return map between local resources and dtd ids.
+ */
+ private static Map createIdToResourceNameMap()
+ {
+ final Map map = Maps.newHashMap();
+ map.put(DTD_PUBLIC_ID_1_0, DTD_RESOURCE_NAME_1_0);
+ map.put(DTD_PUBLIC_ID_1_1, DTD_RESOURCE_NAME_1_1);
+ map.put(DTD_PUBLIC_ID_1_2, DTD_RESOURCE_NAME_1_2);
+ map.put(DTD_PUBLIC_ID_1_3, DTD_RESOURCE_NAME_1_3);
+ return map;
+ }
+
/**
* Parses the specified input source loading the configuration information.
* The stream wrapped inside the source, if any, is NOT
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/Definitions.java b/src/main/java/com/puppycrawl/tools/checkstyle/Definitions.java
index 390e78e73..853772891 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/Definitions.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/Definitions.java
@@ -25,14 +25,14 @@ package com.puppycrawl.tools.checkstyle;
**/
public final class Definitions
{
+ /** Name of resource bundle for Checkstyle. */
+ public static final String CHECKSTYLE_BUNDLE =
+ "com.puppycrawl.tools.checkstyle.messages";
+
/**
* Do no allow Definitions instances to be created.
**/
private Definitions()
{
}
-
- /** Name of resource bundle for Checkstyle. */
- public static final String CHECKSTYLE_BUNDLE =
- "com.puppycrawl.tools.checkstyle.messages";
}
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/Main.java b/src/main/java/com/puppycrawl/tools/checkstyle/Main.java
index de00b62db..0291b89b1 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/Main.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/Main.java
@@ -47,6 +47,11 @@ import org.apache.commons.cli.PosixParser;
**/
public final class Main
{
+ /** Don't create instance of this class, use {@link #main(String[])} method instead. */
+ private Main()
+ {
+ }
+
/**
* Loops over the files specified checking them for errors. The exit code
* is the number of errors found in all the files.
@@ -163,11 +168,6 @@ public final class Main
}
}
- /** Don't create instance of this class, use {@link #main(String[])} method instead. */
- private Main()
- {
- }
-
/**
* Creates the Checker object.
* @param config
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/PropertyCacheFile.java b/src/main/java/com/puppycrawl/tools/checkstyle/PropertyCacheFile.java
index 5cae66e97..9aec4857e 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/PropertyCacheFile.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/PropertyCacheFile.java
@@ -62,6 +62,18 @@ final class PropertyCacheFile
*/
private static final String CONFIG_HASH_KEY = "configuration*?";
+ /** hex digits */
+ private static final char[] HEX_CHARS = {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
+ };
+
+ /** mask for last byte */
+ private static final int MASK_0X0F = 0x0F;
+
+ /** bit shift */
+ private static final int SHIFT_4 = 4;
+
/** name of file to store details **/
private final String detailsFile;
/** the details on files **/
@@ -204,18 +216,6 @@ final class PropertyCacheFile
}
}
- /** hex digits */
- private static final char[] HEX_CHARS = {
- '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
- };
-
- /** mask for last byte */
- private static final int MASK_0X0F = 0x0F;
-
- /** bit shift */
- private static final int SHIFT_4 = 4;
-
/**
* Hex-encodes a byte array.
* @param byteArray the byte array
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java b/src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java
index ba6c348c3..d88ca772b 100755
--- a/src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java
@@ -83,6 +83,9 @@ public final class TreeWalker
/** default distance between tab stops */
private static final int DEFAULT_TAB_WIDTH = 8;
+ /** logger for debug purpose */
+ private static final Log LOG = LogFactory.getLog(TreeWalker.class);
+
/** maps from token name to ordinary checks */
private final Multimap tokenToOrdinaryChecks =
HashMultimap.create();
@@ -112,9 +115,6 @@ public final class TreeWalker
/** a factory for creating submodules (i.e. the Checks) */
private ModuleFactory moduleFactory;
- /** logger for debug purpose */
- private static final Log LOG = LogFactory.getLog(TreeWalker.class);
-
/**
* Creates a new TreeWalker instance.
*/
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/XMLLogger.java b/src/main/java/com/puppycrawl/tools/checkstyle/XMLLogger.java
index 4d6755a4d..8f2bf2271 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/XMLLogger.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/XMLLogger.java
@@ -49,16 +49,16 @@ public class XMLLogger
/** hex radix */
private static final int BASE_16 = 16;
+ /** some known entities to detect */
+ private static final String[] ENTITIES = {"gt", "amp", "lt", "apos",
+ "quot", };
+
/** close output stream in auditFinished */
private boolean closeStream;
/** helper writer that allows easy encoding and printing */
private PrintWriter writer;
- /** some known entities to detect */
- private static final String[] ENTITIES = {"gt", "amp", "lt", "apos",
- "quot", };
-
/**
* Creates a new XMLLogger instance.
* Sets the output to a defined stream.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/api/LocalizedMessage.java b/src/main/java/com/puppycrawl/tools/checkstyle/api/LocalizedMessage.java
index 84e2152c2..04e9fc426 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/api/LocalizedMessage.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/LocalizedMessage.java
@@ -65,6 +65,9 @@ public final class LocalizedMessage
private static final Map BUNDLE_CACHE =
Collections.synchronizedMap(new HashMap());
+ /** the default severity level if one is not specified */
+ private static final SeverityLevel DEFAULT_SEVERITY = SeverityLevel.ERROR;
+
/** the line number **/
private final int lineNo;
/** the column number **/
@@ -76,9 +79,6 @@ public final class LocalizedMessage
/** the id of the module generating the message. */
private final String moduleId;
- /** the default severity level if one is not specified */
- private static final SeverityLevel DEFAULT_SEVERITY = SeverityLevel.ERROR;
-
/** key for the message format **/
private final String key;
@@ -94,51 +94,6 @@ public final class LocalizedMessage
/** a custom message overriding the default message from the bundle. */
private final String customMessage;
- @Override
- public boolean equals(Object object)
- {
- if (this == object) {
- return true;
- }
- if (!(object instanceof LocalizedMessage)) {
- return false;
- }
-
- final LocalizedMessage localizedMessage = (LocalizedMessage) object;
-
- if (colNo != localizedMessage.colNo) {
- return false;
- }
- if (lineNo != localizedMessage.lineNo) {
- return false;
- }
- if (!key.equals(localizedMessage.key)) {
- return false;
- }
-
- if (!Arrays.equals(args, localizedMessage.args)) {
- return false;
- }
- // ignoring bundle for perf reasons.
-
- // we currently never load the same error from different bundles.
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result;
- result = lineNo;
- result = HASH_MULT * result + colNo;
- result = HASH_MULT * result + key.hashCode();
- for (final Object element : args) {
- result = HASH_MULT * result + element.hashCode();
- }
- return result;
- }
-
/**
* Creates a new LocalizedMessage instance.
*
@@ -255,6 +210,51 @@ public final class LocalizedMessage
sourceClass, customMessage);
}
+ @Override
+ public boolean equals(Object object)
+ {
+ if (this == object) {
+ return true;
+ }
+ if (!(object instanceof LocalizedMessage)) {
+ return false;
+ }
+
+ final LocalizedMessage localizedMessage = (LocalizedMessage) object;
+
+ if (colNo != localizedMessage.colNo) {
+ return false;
+ }
+ if (lineNo != localizedMessage.lineNo) {
+ return false;
+ }
+ if (!key.equals(localizedMessage.key)) {
+ return false;
+ }
+
+ if (!Arrays.equals(args, localizedMessage.args)) {
+ return false;
+ }
+ // ignoring bundle for perf reasons.
+
+ // we currently never load the same error from different bundles.
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result;
+ result = lineNo;
+ result = HASH_MULT * result + colNo;
+ result = HASH_MULT * result + key.hashCode();
+ for (final Object element : args) {
+ result = HASH_MULT * result + element.hashCode();
+ }
+ return result;
+ }
+
/** Clears the cache. */
public static void clearCache()
{
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/api/TokenTypes.java b/src/main/java/com/puppycrawl/tools/checkstyle/api/TokenTypes.java
index f3894bc1f..17b695738 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/api/TokenTypes.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/TokenTypes.java
@@ -37,11 +37,6 @@ import com.puppycrawl.tools.checkstyle.grammars.GeneratedJavaTokenTypes;
*/
public final class TokenTypes
{
- /** prevent instantiation */
- private TokenTypes()
- {
- }
-
// The following three types are never part of an AST,
// left here as a reminder so nobody will read them accidentally
@@ -3533,6 +3528,11 @@ public final class TokenTypes
TOKEN_VALUE_TO_NAME = tempTokenValueToName;
}
+ /** prevent instantiation */
+ private TokenTypes()
+ {
+ }
+
/**
* Returns the name of a token for a given ID.
* @param iD the ID of the token name to get
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/AbstractTypeAwareCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/AbstractTypeAwareCheck.java
index 1c9769075..af3902847 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/AbstractTypeAwareCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/AbstractTypeAwareCheck.java
@@ -74,6 +74,12 @@ public abstract class AbstractTypeAwareCheck extends Check
*/
private boolean logLoadErrors = true;
+ /**
+ * Whether to show class loading errors in the checkstyle report.
+ * Request ID 1491630
+ */
+ private boolean suppressLoadErrors;
+
/**
* Controls whether to log class loading errors to the checkstyle report
* instead of throwing a RTE.
@@ -85,12 +91,6 @@ public abstract class AbstractTypeAwareCheck extends Check
this.logLoadErrors = logLoadErrors;
}
- /**
- * Whether to show class loading errors in the checkstyle report.
- * Request ID 1491630
- */
- private boolean suppressLoadErrors;
-
/**
* Controls whether to show class loading errors in the checkstyle report.
*
@@ -428,15 +428,6 @@ public abstract class AbstractTypeAwareCheck extends Check
/** FullIdent associated with this class. */
private final Token name;
- /** @return class name */
- public final Token getName()
- {
- return name;
- }
-
- /** @return Class associated with an object. */
- public abstract Class> getClazz();
-
/**
* Creates new instance of class inforamtion object.
* @param className token which represents class name.
@@ -449,6 +440,15 @@ public abstract class AbstractTypeAwareCheck extends Check
}
name = className;
}
+
+ /** @return class name */
+ public final Token getName()
+ {
+ return name;
+ }
+
+ /** @return Class associated with an object. */
+ public abstract Class> getClazz();
}
/** Represents regular classes/enumes. */
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/CheckUtils.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/CheckUtils.java
index 4d9966fdd..05d78f0c0 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/CheckUtils.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/CheckUtils.java
@@ -34,6 +34,16 @@ import java.util.List;
*/
public final class CheckUtils
{
+ // constants for parseDouble()
+ /** octal radix */
+ private static final int BASE_8 = 8;
+
+ /** decimal radix */
+ private static final int BASE_10 = 10;
+
+ /** hex radix */
+ private static final int BASE_16 = 16;
+
/** prevent instances */
private CheckUtils()
{
@@ -132,16 +142,6 @@ public final class CheckUtils
return FullIdent.createFullIdent(typeAST.getFirstChild());
}
- // constants for parseDouble()
- /** octal radix */
- private static final int BASE_8 = 8;
-
- /** decimal radix */
- private static final int BASE_10 = 10;
-
- /** hex radix */
- private static final int BASE_16 = 16;
-
/**
* Returns the value represented by the specified string of the specified
* type. Returns 0 for types other than float, double, int, and long.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheck.java
index 24b9839b2..f4cfe0ed5 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheck.java
@@ -59,20 +59,6 @@ public class FinalParametersCheck extends Check
*/
public static final String MSG_KEY = "final.parameter";
- /**
- * Option to ignore primitive types as params.
- */
- private boolean ignorePrimitiveTypes;
-
- /**
- * Sets ignoring primitive types as params.
- * @param ignorePrimitiveTypes true or false.
- */
- public void setIgnorePrimitiveTypes(boolean ignorePrimitiveTypes)
- {
- this.ignorePrimitiveTypes = ignorePrimitiveTypes;
- }
-
/**
* Contains
*
@@ -88,6 +74,20 @@ public class FinalParametersCheck extends Check
TokenTypes.LITERAL_BOOLEAN,
TokenTypes.LITERAL_CHAR);
+ /**
+ * Option to ignore primitive types as params.
+ */
+ private boolean ignorePrimitiveTypes;
+
+ /**
+ * Sets ignoring primitive types as params.
+ * @param ignorePrimitiveTypes true or false.
+ */
+ public void setIgnorePrimitiveTypes(boolean ignorePrimitiveTypes)
+ {
+ this.ignorePrimitiveTypes = ignorePrimitiveTypes;
+ }
+
@Override
public int[] getDefaultTokens()
{
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/TrailingCommentCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/TrailingCommentCheck.java
index 51ae32630..f165ee935 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/TrailingCommentCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/TrailingCommentCheck.java
@@ -113,6 +113,15 @@ public class TrailingCommentCheck extends AbstractFormatCheck
/** pattern for legal trailing comment. */
private Pattern legalComment;
+ /**
+ * Creates new instance of the check.
+ * @throws ConversionException unable to parse DEFAULT_FORMAT.
+ */
+ public TrailingCommentCheck() throws ConversionException
+ {
+ super(DEFAULT_FORMAT);
+ }
+
/**
* Sets patter for legal trailing comments.
* @param format format to set.
@@ -123,14 +132,6 @@ public class TrailingCommentCheck extends AbstractFormatCheck
{
legalComment = Utils.createPattern(format);
}
- /**
- * Creates new instance of the check.
- * @throws ConversionException unable to parse DEFAULT_FORMAT.
- */
- public TrailingCommentCheck() throws ConversionException
- {
- super(DEFAULT_FORMAT);
- }
@Override
public int[] getDefaultTokens()
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheck.java
index 81d8bd608..bf914eaa9 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheck.java
@@ -121,13 +121,6 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
*/
public final class AnnotationUseStyleCheck extends Check
{
- /**
- * the element name used to receive special linguistic support
- * for annotation use.
- */
- private static final String ANNOTATION_ELEMENT_SINGLE_NAME =
- "value";
-
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
@@ -163,6 +156,13 @@ public final class AnnotationUseStyleCheck extends Check
public static final String MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT =
"annotation.trailing.comma.present";
+ /**
+ * the element name used to receive special linguistic support
+ * for annotation use.
+ */
+ private static final String ANNOTATION_ELEMENT_SINGLE_NAME =
+ "value";
+
//not extending AbstractOptionCheck because check
//has more than one option type.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheck.java
index 82baeee8a..bdd976239 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheck.java
@@ -74,6 +74,26 @@ import com.puppycrawl.tools.checkstyle.Utils;
*/
public final class MissingDeprecatedCheck extends Check
{
+ /**
+ * A key is pointing to the warning message text in "messages.properties"
+ * file.
+ */
+ public static final String MSG_KEY_ANNOTATION_MISSING_DEPRECATED =
+ "annotation.missing.deprecated";
+
+ /**
+ * A key is pointing to the warning message text in "messages.properties"
+ * file.
+ */
+ public static final String MSG_KEY_JAVADOC_DUPLICATE_TAG =
+ "javadoc.duplicateTag";
+
+ /**
+ * A key is pointing to the warning message text in "messages.properties"
+ * file.
+ */
+ public static final String MSG_KEY_JAVADOC_MISSING = "javadoc.missing";
+
/** {@link Deprecated Deprecated} annotation name */
private static final String DEPRECATED = "Deprecated";
@@ -97,26 +117,6 @@ public final class MissingDeprecatedCheck extends Check
/** Multiline finished at next Javadoc * */
private static final String NEXT_TAG = "@";
- /**
- * A key is pointing to the warning message text in "messages.properties"
- * file.
- */
- public static final String MSG_KEY_ANNOTATION_MISSING_DEPRECATED =
- "annotation.missing.deprecated";
-
- /**
- * A key is pointing to the warning message text in "messages.properties"
- * file.
- */
- public static final String MSG_KEY_JAVADOC_DUPLICATE_TAG =
- "javadoc.duplicateTag";
-
- /**
- * A key is pointing to the warning message text in "messages.properties"
- * file.
- */
- public static final String MSG_KEY_JAVADOC_MISSING = "javadoc.missing";
-
/** {@inheritDoc} */
@Override
public int[] getDefaultTokens()
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheck.java
index 0a6d1087e..eecf3a670 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheck.java
@@ -77,16 +77,6 @@ import com.puppycrawl.tools.checkstyle.Utils;
*/
public final class MissingOverrideCheck extends Check
{
- /** {@link Override Override} annotation name */
- private static final String OVERRIDE = "Override";
-
- /** fully-qualified {@link Override Override} annotation name */
- private static final String FQ_OVERRIDE = "java.lang." + OVERRIDE;
-
- /** compiled regexp to match Javadoc tags with no argument and {} * */
- private static final Pattern MATCH_INHERITDOC =
- Utils.createPattern("\\{\\s*@(inheritDoc)\\s*\\}");
-
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
@@ -100,6 +90,16 @@ public final class MissingOverrideCheck extends Check
public static final String MSG_KEY_ANNOTATION_MISSING_OVERRIDE =
"annotation.missing.override";
+ /** {@link Override Override} annotation name */
+ private static final String OVERRIDE = "Override";
+
+ /** fully-qualified {@link Override Override} annotation name */
+ private static final String FQ_OVERRIDE = "java.lang." + OVERRIDE;
+
+ /** compiled regexp to match Javadoc tags with no argument and {} * */
+ private static final Pattern MATCH_INHERITDOC =
+ Utils.createPattern("\\{\\s*@(inheritDoc)\\s*\\}");
+
/** @see #setJavaFiveCompatibility(boolean) */
private boolean javaFiveCompatibility;
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheck.java
index 468dd44a3..45a882ff3 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheck.java
@@ -87,6 +87,13 @@ import com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck;
*/
public class SuppressWarningsCheck extends AbstractFormatCheck
{
+ /**
+ * A key is pointing to the warning message text in "messages.properties"
+ * file.
+ */
+ public static final String MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED =
+ "suppressed.warning.not.allowed";
+
/** {@link SuppressWarnings SuppressWarnings} annotation name */
private static final String SUPPRESS_WARNINGS = "SuppressWarnings";
@@ -97,13 +104,6 @@ public class SuppressWarningsCheck extends AbstractFormatCheck
private static final String FQ_SUPPRESS_WARNINGS =
"java.lang." + SUPPRESS_WARNINGS;
- /**
- * A key is pointing to the warning message text in "messages.properties"
- * file.
- */
- public static final String MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED =
- "suppressed.warning.not.allowed";
-
/**
* Ctor that specifies the default for the format property
* as specified in the class javadocs.
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/AvoidNestedBlocksCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/AvoidNestedBlocksCheck.java
index 43ed52e63..2c41bdd77 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/AvoidNestedBlocksCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/AvoidNestedBlocksCheck.java
@@ -87,18 +87,18 @@ import com.puppycrawl.tools.checkstyle.api.DetailAST;
*/
public class AvoidNestedBlocksCheck extends Check
{
- /**
- * Whether nested blocks are allowed if they are the
- * only child of a switch case.
- */
- private boolean allowInSwitchCase;
-
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_KEY_BLOCK_NESTED = "block.nested";
+ /**
+ * Whether nested blocks are allowed if they are the
+ * only child of a switch case.
+ */
+ private boolean allowInSwitchCase;
+
@Override
public int[] getDefaultTokens()
{
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheck.java
index 0369dafc9..05a8cba98 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheck.java
@@ -76,9 +76,6 @@ import com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck;
public class LeftCurlyCheck
extends AbstractOptionCheck
{
- /** default maximum line length */
- private static final int DEFAULT_MAX_LINE_LENGTH = 80;
-
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
@@ -97,6 +94,9 @@ public class LeftCurlyCheck
*/
public static final String MSG_KEY_LINE_BREAK_AFTER = "line.break.after";
+ /** default maximum line length */
+ private static final int DEFAULT_MAX_LINE_LENGTH = 80;
+
/** maxLineLength **/
private int maxLineLength = DEFAULT_MAX_LINE_LENGTH;
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/NeedBracesCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/NeedBracesCheck.java
index 9481309cc..f5929f5c2 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/NeedBracesCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/NeedBracesCheck.java
@@ -103,17 +103,17 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
*/
public class NeedBracesCheck extends Check
{
- /**
- * Check's option for skipping single-line statements.
- */
- private boolean allowSingleLineStatement;
-
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_KEY_NEED_BRACES = "needBraces";
+ /**
+ * Check's option for skipping single-line statements.
+ */
+ private boolean allowSingleLineStatement;
+
/**
* Setter.
* @param allowSingleLineStatement Check's option for skipping single-line statements
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheck.java
index f87290fb3..f84dd510b 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheck.java
@@ -72,9 +72,6 @@ import com.puppycrawl.tools.checkstyle.checks.CheckUtils;
*/
public class RightCurlyCheck extends AbstractOptionCheck
{
- /** Do we need to check if rculry starts line. */
- private boolean shouldStartLine = true;
-
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
@@ -99,6 +96,9 @@ public class RightCurlyCheck extends AbstractOptionCheck
*/
public static final String MSG_KEY_LINE_NEW = "line.new";
+ /** Do we need to check if rculry starts line. */
+ private boolean shouldStartLine = true;
+
/**
* Sets the right curly option to same.
*/
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheck.java
index 675223ea3..110b4e05a 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheck.java
@@ -64,15 +64,6 @@ public class MultipleStringLiteralsCheck extends Check
*/
private int allowedDuplicates = 1;
- /**
- * Sets the maximum allowed duplicates of a string.
- * @param allowedDuplicates The maximum number of duplicates.
- */
- public void setAllowedDuplicates(int allowedDuplicates)
- {
- this.allowedDuplicates = allowedDuplicates;
- }
-
/**
* Pattern for matching ignored strings.
*/
@@ -87,6 +78,15 @@ public class MultipleStringLiteralsCheck extends Check
ignoreOccurrenceContext.set(TokenTypes.ANNOTATION);
}
+ /**
+ * Sets the maximum allowed duplicates of a string.
+ * @param allowedDuplicates The maximum number of duplicates.
+ */
+ public void setAllowedDuplicates(int allowedDuplicates)
+ {
+ this.allowedDuplicates = allowedDuplicates;
+ }
+
/**
* Sets regular expression pattern for ignored strings.
* @param ignoreStringsRegexp
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/InnerTypeLastCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/InnerTypeLastCheck.java
index c580fb03f..a58a6add9 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/InnerTypeLastCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/InnerTypeLastCheck.java
@@ -41,6 +41,9 @@ public class InnerTypeLastCheck extends Check
*/
public static final String MSG_KEY = "arrangement.members.before.inner";
+ /** Meet a root class. */
+ private boolean rootClass = true;
+
@Override
public int[] getDefaultTokens()
{
@@ -53,9 +56,6 @@ public class InnerTypeLastCheck extends Check
return new int[] {TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF};
}
- /** Meet a root class. */
- private boolean rootClass = true;
-
@Override
public void visitToken(DetailAST ast)
{
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheck.java
index c517497ac..17757d9e1 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheck.java
@@ -238,6 +238,39 @@ public class VisibilityModifierCheck
*/
public static final String MSG_KEY = "variable.notPrivate";
+ /** Default immutable types canonical names. */
+ private static final List DEFAULT_IMMUTABLE_TYPES = ImmutableList.of(
+ "java.lang.String",
+ "java.lang.Integer",
+ "java.lang.Byte",
+ "java.lang.Character",
+ "java.lang.Short",
+ "java.lang.Boolean",
+ "java.lang.Long",
+ "java.lang.Double",
+ "java.lang.Float",
+ "java.lang.StackTraceElement",
+ "java.math.BigInteger",
+ "java.math.BigDecimal",
+ "java.io.File",
+ "java.util.Locale",
+ "java.util.UUID",
+ "java.net.URL",
+ "java.net.URI",
+ "java.net.Inet4Address",
+ "java.net.Inet6Address",
+ "java.net.InetSocketAddress"
+ );
+
+ /** Default ignore annotations canonical names. */
+ private static final List DEFAULT_IGNORE_ANNOTATIONS = ImmutableList.of(
+ "org.junit.Rule",
+ "com.google.common.annotations.VisibleForTesting"
+ );
+
+ /** contains explicit access modifiers. */
+ private static final String[] EXPLICIT_MODS = {"public", "private", "protected"};
+
/** whether protected members are allowed */
private boolean protectedAllowed;
@@ -274,39 +307,6 @@ public class VisibilityModifierCheck
private final List immutableClassShortNames =
getClassShortNames(DEFAULT_IMMUTABLE_TYPES);
- /** Default immutable types canonical names. */
- private static final List DEFAULT_IMMUTABLE_TYPES = ImmutableList.of(
- "java.lang.String",
- "java.lang.Integer",
- "java.lang.Byte",
- "java.lang.Character",
- "java.lang.Short",
- "java.lang.Boolean",
- "java.lang.Long",
- "java.lang.Double",
- "java.lang.Float",
- "java.lang.StackTraceElement",
- "java.math.BigInteger",
- "java.math.BigDecimal",
- "java.io.File",
- "java.util.Locale",
- "java.util.UUID",
- "java.net.URL",
- "java.net.URI",
- "java.net.Inet4Address",
- "java.net.Inet6Address",
- "java.net.InetSocketAddress"
- );
-
- /** Default ignore annotations canonical names. */
- private static final List DEFAULT_IGNORE_ANNOTATIONS = ImmutableList.of(
- "org.junit.Rule",
- "com.google.common.annotations.VisibleForTesting"
- );
-
- /** contains explicit access modifiers. */
- private static final String[] EXPLICIT_MODS = {"public", "private", "protected"};
-
/** @return whether protected members are allowed */
public boolean isProtectedAllowed()
{
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader.java
index b6a824ba2..0502972c8 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader.java
@@ -56,12 +56,12 @@ final class ImportControlLoader extends AbstractLoader
private static final String DTD_RESOURCE_NAME_1_1 =
"com/puppycrawl/tools/checkstyle/checks/imports/import_control_1_1.dtd";
- /** Used to hold the {@link PkgControl} objects. */
- private final Deque stack = new ArrayDeque<>();
-
/** the map to lookup the resource name by the id */
private static final Map DTD_RESOURCE_BY_ID = new HashMap<>();
+ /** Used to hold the {@link PkgControl} objects. */
+ private final Deque stack = new ArrayDeque<>();
+
/** Initialise the map */
static {
DTD_RESOURCE_BY_ID.put(DTD_PUBLIC_ID_1_0, DTD_RESOURCE_NAME_1_0);
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/BlockParentHandler.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/BlockParentHandler.java
index 67dbbfbc2..519c65597 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/BlockParentHandler.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/BlockParentHandler.java
@@ -56,15 +56,6 @@ public class BlockParentHandler extends ExpressionHandler
TokenTypes.LITERAL_CONTINUE,
};
- /**
- * Returns array of token types which should be checked among childrens.
- * @return array of token types to check.
- */
- protected int[] getCheckedChildren()
- {
- return CHECKED_CHILDREN.clone();
- }
-
/**
* Construct an instance of this handler with the given indentation check,
* name, abstract syntax tree, and parent handler.
@@ -80,6 +71,15 @@ public class BlockParentHandler extends ExpressionHandler
super(indentCheck, name, ast, parent);
}
+ /**
+ * Returns array of token types which should be checked among childrens.
+ * @return array of token types to check.
+ */
+ protected int[] getCheckedChildren()
+ {
+ return CHECKED_CHILDREN.clone();
+ }
+
/**
* Get the top level expression being managed by this handler.
*
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/HandlerFactory.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/HandlerFactory.java
index eaa9529ab..70c654dd0 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/HandlerFactory.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/HandlerFactory.java
@@ -45,30 +45,9 @@ public class HandlerFactory
private final Map> typeHandlers =
Maps.newHashMap();
- /**
- * registers a handler
- *
- * @param type
- * type from TokenTypes
- * @param handlerClass
- * the handler to register
- */
- private void register(int type, Class> handlerClass)
- {
- try {
- final Constructor> ctor = handlerClass
- .getConstructor(new Class[] {IndentationCheck.class,
- DetailAST.class, // current AST
- ExpressionHandler.class, // parent
- });
- typeHandlers.put(type, ctor);
- }
- catch (final NoSuchMethodException | SecurityException e) {
- final String message = "couldn't find ctor for " + handlerClass;
- LOG.debug(message, e);
- throw new RuntimeException(message);
- }
- }
+ /** cache for created method call handlers */
+ private final Map createdHandlers =
+ Maps.newHashMap();
/** Creates a HandlerFactory. */
public HandlerFactory()
@@ -104,6 +83,31 @@ public class HandlerFactory
register(TokenTypes.LITERAL_SYNCHRONIZED, SynchronizedHandler.class);
}
+ /**
+ * registers a handler
+ *
+ * @param type
+ * type from TokenTypes
+ * @param handlerClass
+ * the handler to register
+ */
+ private void register(int type, Class> handlerClass)
+ {
+ try {
+ final Constructor> ctor = handlerClass
+ .getConstructor(new Class[] {IndentationCheck.class,
+ DetailAST.class, // current AST
+ ExpressionHandler.class, // parent
+ });
+ typeHandlers.put(type, ctor);
+ }
+ catch (final NoSuchMethodException | SecurityException e) {
+ final String message = "couldn't find ctor for " + handlerClass;
+ LOG.debug(message, e);
+ throw new RuntimeException(message);
+ }
+ }
+
/**
* Returns true if this type (form TokenTypes) is handled.
*
@@ -209,8 +213,4 @@ public class HandlerFactory
{
createdHandlers.clear();
}
-
- /** cache for created method call handlers */
- private final Map createdHandlers =
- Maps.newHashMap();
}
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalVariableNameCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalVariableNameCheck.java
index f987a039d..95a18f4b8 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalVariableNameCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalVariableNameCheck.java
@@ -74,14 +74,14 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
public class LocalVariableNameCheck
extends AbstractNameCheck
{
+ /** Regexp for one-char loop variables. */
+ private static Pattern sSingleChar = Pattern.compile("^[a-z]$");
+
/**
* Allow one character name for initialization expression in FOR loop.
*/
private boolean allowOneCharVarInForLoop;
- /** Regexp for one-char loop variables. */
- private static Pattern sSingleChar = Pattern.compile("^[a-z]$");
-
/** Creates a new LocalVariableNameCheck instance. */
public LocalVariableNameCheck()
{
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheck.java
index 2262b14cd..0b8842cb0 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheck.java
@@ -80,11 +80,6 @@ public class MethodNameCheck
*/
public static final String MSG_KEY = "method.name.equals.class.name";
- /**
- * for allowing method name to be the same as the class name.
- */
- private boolean allowClassName;
-
/**
* {@link Override Override} annotation name.
*/
@@ -95,6 +90,11 @@ public class MethodNameCheck
*/
private static final String CANONICAL_OVERRIDE = "java.lang." + OVERRIDE;
+ /**
+ * for allowing method name to be the same as the class name.
+ */
+ private boolean allowClassName;
+
/** Creates a new MethodNameCheck instance. */
public MethodNameCheck()
{
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheck.java
index 86889b9d1..e00b5fb0a 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheck.java
@@ -63,12 +63,12 @@ public class MethodLengthCheck extends Check
*/
public static final String MSG_KEY = "maxLen.method";
- /** whether to ignore empty lines and single line comments */
- private boolean countEmpty = true;
-
/** default maximum number of lines */
private static final int DEFAULT_MAX_LINES = 150;
+ /** whether to ignore empty lines and single line comments */
+ private boolean countEmpty = true;
+
/** the maximum number of lines */
private int max = DEFAULT_MAX_LINES;
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/MethodParamPadCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/MethodParamPadCheck.java
index 4abf6b2ec..df4443efa 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/MethodParamPadCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/MethodParamPadCheck.java
@@ -84,6 +84,10 @@ public class MethodParamPadCheck
*/
public static final String WS_NOT_PRECEDED = "ws.notPreceded";
+ /** Whether whitespace is allowed if the method identifier is at a
+ * linebreak */
+ private boolean allowLineBreaks;
+
/**
* Sets the pad option to nospace.
*/
@@ -92,10 +96,6 @@ public class MethodParamPadCheck
super(PadOption.NOSPACE, PadOption.class);
}
- /** Whether whitespace is allowed if the method identifier is at a
- * linebreak */
- private boolean allowLineBreaks;
-
@Override
public int[] getDefaultTokens()
{
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/filters/CSVFilter.java b/src/main/java/com/puppycrawl/tools/checkstyle/filters/CSVFilter.java
index 3b7a3a969..c66afa891 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/CSVFilter.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/CSVFilter.java
@@ -36,24 +36,6 @@ class CSVFilter implements IntFilter
/** filter set */
private final Set filters = Sets.newHashSet();
- /**
- * Adds a IntFilter to the set.
- * @param filter the IntFilter to add.
- */
- public void addFilter(IntFilter filter)
- {
- filters.add(filter);
- }
-
- /**
- * Returns the IntFilters of the filter set.
- * @return the IntFilters of the filter set.
- */
- protected Set getFilters()
- {
- return filters;
- }
-
/**
* Constructs a CSVFilter from a CSV, Comma-Separated Values,
* string. Each value is an integer, or a range of integers. A range of
@@ -84,6 +66,24 @@ class CSVFilter implements IntFilter
}
}
+ /**
+ * Adds a IntFilter to the set.
+ * @param filter the IntFilter to add.
+ */
+ public void addFilter(IntFilter filter)
+ {
+ filters.add(filter);
+ }
+
+ /**
+ * Returns the IntFilters of the filter set.
+ * @return the IntFilters of the filter set.
+ */
+ protected Set getFilters()
+ {
+ return filters;
+ }
+
/**
* Determines whether an Integer matches a CSV integer value.
* @param intValue the Integer to check.
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckTest.java
index b53d82f0c..b33fa0e19 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckTest.java
@@ -34,10 +34,10 @@ import static com.puppycrawl.tools.checkstyle.checks.regexp.MultilineDetector.RE
public class RegexpMultilineCheckTest extends BaseFileSetCheckTestSupport
{
- private DefaultConfiguration checkConfig;
-
@Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ private DefaultConfiguration checkConfig;
+
@Before
public void setUp()
{