diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java index cb37622466..bededb0f95 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd; /** * Base configuration class for both PMD and CPD. - * + * * @author Brian Remedios */ public abstract class AbstractConfiguration { @@ -23,7 +23,7 @@ public abstract class AbstractConfiguration { /** * Get the character encoding of source files. - * + * * @return The character encoding. */ public String getSourceEncoding() { @@ -32,7 +32,7 @@ public abstract class AbstractConfiguration { /** * Set the character encoding of source files. - * + * * @param sourceEncoding * The character encoding. */ @@ -43,7 +43,7 @@ public abstract class AbstractConfiguration { /** * Return the debug indicator. If this value is true then PMD * will log debug information. - * + * * @return true if debug logging is enabled, false * otherwise. */ @@ -53,7 +53,7 @@ public abstract class AbstractConfiguration { /** * Set the debug indicator. - * + * * @param debug * The debug indicator to set. * @see #isDebug() diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/AbstractPropertySource.java b/pmd-core/src/main/java/net/sourceforge/pmd/AbstractPropertySource.java index 35c158edef..e9ee2d60d5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/AbstractPropertySource.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/AbstractPropertySource.java @@ -17,7 +17,7 @@ import net.sourceforge.pmd.util.CollectionUtil; /** * Base class for objects which can be configured through properties. Rules and * Reports are such objects. - * + * * @author Brian Remedios */ public abstract class AbstractPropertySource implements PropertySource { @@ -29,7 +29,7 @@ public abstract class AbstractPropertySource implements PropertySource { /** * Creates a copied list of the property descriptors and returns it. - * + * * @return a copy of the property descriptors. */ protected List> copyPropertyDescriptors() { @@ -38,7 +38,7 @@ public abstract class AbstractPropertySource implements PropertySource { /** * Creates a copied map of the values of the properties and returns it. - * + * * @return a copy of the values */ protected Map, Object> copyPropertyValues() { @@ -48,6 +48,7 @@ public abstract class AbstractPropertySource implements PropertySource { /** * {@inheritDoc} */ + @Override public Set> ignoredProperties() { return Collections.emptySet(); } @@ -55,6 +56,7 @@ public abstract class AbstractPropertySource implements PropertySource { /** * {@inheritDoc} */ + @Override public void definePropertyDescriptor(PropertyDescriptor propertyDescriptor) { // Check to ensure the property does not already exist. for (PropertyDescriptor descriptor : propertyDescriptors) { @@ -71,7 +73,7 @@ public abstract class AbstractPropertySource implements PropertySource { /** * Gets the name of the property source. This is e.g. the rule name or the * report name. - * + * * @return the name */ public abstract String getName(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/NumericPropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/NumericPropertyDescriptor.java index 06523bd207..d15703d768 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/NumericPropertyDescriptor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/NumericPropertyDescriptor.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd; /** * Defines a descriptor type whose instance values are required lie within * specified upper and lower limits. - * + * * @author Brian Remedios * * @param @@ -16,14 +16,14 @@ public interface NumericPropertyDescriptor extends PropertyDes /** * Returns the maximum value that instances of the property can have - * + * * @return Number */ Number upperLimit(); /** * Returns the minimum value that instances of the property can have - * + * * @return Number */ Number lowerLimit(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java b/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java index 7670d6aa5d..89d42117e4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java @@ -106,7 +106,7 @@ public class PMD { /** * Parses the given string as a database uri and returns a list of * datasources. - * + * * @param uriString * the URI to parse * @return list of data sources @@ -153,7 +153,7 @@ public class PMD { /** * Helper method to get a configured parser for the requested language. The * parser is configured based on the given {@link PMDConfiguration}. - * + * * @param languageVersion * the requested language * @param configuration @@ -232,7 +232,7 @@ public class PMD { /** * Gets the source code processor. - * + * * @return SourceCodeProcessor */ public SourceCodeProcessor getSourceCodeProcessor() { @@ -423,7 +423,7 @@ public class PMD { /** * Determines all the files, that should be analyzed by PMD. - * + * * @param configuration * contains either the file path or the DB URI, from where to * load the files @@ -516,7 +516,7 @@ public class PMD { /** * Parses the command line arguments and executes PMD. - * + * * @param args * command line arguments * @return the exit code, where 0 means successful execution, @@ -533,8 +533,10 @@ public class PMD { final Handler logHandler = new ConsoleLogHandler(); final ScopedLogHandlersManager logHandlerManager = new ScopedLogHandlersManager(logLevel, logHandler); final Level oldLogLevel = LOG.getLevel(); - LOG.setLevel(logLevel); // Need to do this, since the static logger has - // already been initialized at this point + // Need to do this, since the static logger has already been initialized + // at this point + LOG.setLevel(logLevel); + try { int violations = PMD.doPMD(configuration); if (violations > 0 && configuration.isFailOnViolation()) { @@ -554,9 +556,9 @@ public class PMD { long end = System.nanoTime(); Benchmarker.mark(Benchmark.TotalPMD, end - start, 0); - TextReport report = new TextReport(); // TODO get specified - // report format from - // config + // TODO get specified report format from config + TextReport report = new TextReport(); + report.generate(Benchmarker.values(), System.err); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java index a4b2169256..f4fbfea0bd 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java @@ -514,7 +514,7 @@ public class PMDConfiguration extends AbstractConfiguration { /** * Whether PMD should exit with status 4 (the default behavior, true) if * violations are found or just with 0 (to not break the build, e.g.). - * + * * @return failOnViolation */ public boolean isFailOnViolation() { @@ -524,7 +524,7 @@ public class PMDConfiguration extends AbstractConfiguration { /** * Sets whether PMD should exit with status 4 (the default behavior, true) * if violations are found or just with 0 (to not break the build, e.g.). - * + * * @param failOnViolation * failOnViolation */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PMDException.java b/pmd-core/src/main/java/net/sourceforge/pmd/PMDException.java index fdd1e15541..4cadd9728d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PMDException.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PMDException.java @@ -8,7 +8,7 @@ package net.sourceforge.pmd; * A convenience exception wrapper. Contains the original exception, if any. * Also, contains a severity number (int). Zero implies no severity. The higher * the number the greater the severity. - * + * * @author Donald A. Leckie * @version $Revision$, $Date$ * @since August 30, 2002 @@ -20,7 +20,7 @@ public class PMDException extends Exception { /** * Creates a new PMD exception with the specified message. - * + * * @param message * the message */ @@ -31,7 +31,7 @@ public class PMDException extends Exception { /** * Creates a new PMD exception with the specified message and the given * reason as root cause. - * + * * @param message * the message * @param reason diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/PropertyDescriptor.java index d8691c1e42..5d26eb04d4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PropertyDescriptor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PropertyDescriptor.java @@ -11,7 +11,7 @@ import java.util.Map; * property values for use within PMD and any associated GUIs. While concrete * descriptor instances are static and immutable they provide validation, * serialization, and default values for any specific datatypes. - * + * * @author Brian Remedios * @param */ @@ -19,7 +19,7 @@ public interface PropertyDescriptor extends Comparable extends Comparable type(); /** * Returns whether the property is multi-valued, i.e. an array of strings, - * + * * As unary property rule properties will return a value of one, you must * use the get/setProperty accessors when working with the actual values. * When working with multi-value properties then the get/setProperties * accessors must be used. - * + * * @return boolean */ boolean isMultiValue(); @@ -54,7 +54,7 @@ public interface PropertyDescriptor extends Comparable extends Comparable extends Comparable extends Comparable 0.0 description 1.0 minValue -> 2.0 maxValue -> 2.1 - * + * * ..would have their fields placed like: - * + * * name: [ ] description: [ ] minimum: [ ] maximum: [ ] - * + * * @return float */ float uiOrder(); @@ -97,7 +97,7 @@ public interface PropertyDescriptor extends Comparable extends Comparable extends Comparable extends Comparable extends Comparable extends Comparable extends Comparable */ Map attributeValuesById(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PropertyDescriptorFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/PropertyDescriptorFactory.java index 2d355919fe..9ed7c55997 100755 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PropertyDescriptorFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PropertyDescriptorFactory.java @@ -8,7 +8,7 @@ import java.util.Map; /** * A factory to create {@link PropertyDescriptor}s based on a map of values. - * + * * @author Brian Remedios */ public interface PropertyDescriptorFactory { @@ -16,7 +16,7 @@ public interface PropertyDescriptorFactory { /** * The type of the value of the {@link PropertyDescriptor} created by this * factory. - * + * * @return the type of the value. */ Class valueType(); @@ -24,7 +24,7 @@ public interface PropertyDescriptorFactory { /** * Denote the identifiers of the expected fields paired with booleans * denoting whether they are required (non-null) or not. - * + * * @return Map */ Map expectedFields(); @@ -32,7 +32,7 @@ public interface PropertyDescriptorFactory { /** * Create a property descriptor of the appropriate type using the values * provided. - * + * * @param valuesById * the map of values * @return a new and initialized {@link PropertyDescriptor} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PropertyDescriptorFields.java b/pmd-core/src/main/java/net/sourceforge/pmd/PropertyDescriptorFields.java index 90d4de6d1a..1de85f25a9 100755 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PropertyDescriptorFields.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PropertyDescriptorFields.java @@ -8,7 +8,7 @@ import net.sourceforge.pmd.lang.rule.properties.factories.PropertyDescriptorUtil /** * Field names for parsing the properties out of the ruleset xml files. - * + * * @author Brian Remedios * @see RuleSetFactory */ @@ -16,7 +16,7 @@ public class PropertyDescriptorFields { /** * The type of the property. - * + * * @see PropertyDescriptorUtil */ public static final String TYPE = "type"; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PropertySource.java b/pmd-core/src/main/java/net/sourceforge/pmd/PropertySource.java index 5e79214fb8..ecabc141b7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PropertySource.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PropertySource.java @@ -11,14 +11,14 @@ import java.util.Set; /** * Any entity that manages a list of properties is a {@link PropertySource}. * These are e.g. Rules and Renderers. - * + * * @author Brian Remedios */ public interface PropertySource { /** * Define a new property via a PropertyDescriptor. - * + * * @param propertyDescriptor * The property descriptor. * @throws IllegalArgumentException @@ -28,7 +28,7 @@ public interface PropertySource { /** * Get the PropertyDescriptor for the given property name. - * + * * @param name * The name of the property. * @return The PropertyDescriptor for the named property, null @@ -39,14 +39,14 @@ public interface PropertySource { /** * Get the PropertyDescriptors for all defined properties. The properties * are returned sorted by UI order. - * + * * @return The PropertyDescriptors in UI order. */ List> getPropertyDescriptors(); /** * Get the typed value for the given property. - * + * * @param * The underlying type of the property descriptor. * @param propertyDescriptor @@ -57,7 +57,7 @@ public interface PropertySource { /** * Set the property value specified (will be type-checked) - * + * * @param * The underlying type of the property descriptor. * @param propertyDescriptor @@ -70,14 +70,14 @@ public interface PropertySource { /** * Returns all the current property values for the receiver or an immutable * empty map if none are specified. - * + * * @return all current property values or a empty map. */ Map, Object> getPropertiesByPropertyDescriptor(); /** * Returns whether this Rule has the specified PropertyDescriptor. - * + * * @param descriptor * The PropertyDescriptor for which to check. * @return boolean true if the descriptor is present, @@ -87,7 +87,7 @@ public interface PropertySource { /** * Returns whether this Rule uses default values for properties. - * + * * @return boolean true if the properties all have default * values, false otherwise. */ @@ -96,7 +96,7 @@ public interface PropertySource { /** * Clears out any user-specified value for the property allowing it to use * the default value in the descriptor. - * + * * @param desc * the property to clear out */ @@ -106,7 +106,7 @@ public interface PropertySource { * Return the properties that are effectively ignored due to the * configuration of the rule and values held by other properties. This can * be used to disable corresponding widgets in a UI. - * + * * @return the properties that are ignored */ Set> ignoredProperties(); @@ -115,7 +115,7 @@ public interface PropertySource { * Returns a description of why the receiver may be dysfunctional. Usually * due to missing property values or some kind of conflict between values. * Returns null if the receiver is ok. - * + * * @return String */ String dysfunctionReason(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/ReportListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/ReportListener.java index 65862f033b..ad1a383404 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/ReportListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/ReportListener.java @@ -13,7 +13,7 @@ import net.sourceforge.pmd.stat.Metric; public interface ReportListener { /** * A new violation has been found. - * + * * @param ruleViolation * the found violation. */ @@ -21,7 +21,7 @@ public interface ReportListener { /** * A new metric point has been reported. - * + * * @param metric * the metric */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java b/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java index b21dfd6d5a..98e44a9de6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java @@ -40,14 +40,14 @@ public interface Rule extends PropertySource { /** * Get the Language of this Rule. - * + * * @return the language */ Language getLanguage(); /** * Set the Language of this Rule. - * + * * @param language * the language */ @@ -56,14 +56,14 @@ public interface Rule extends PropertySource { /** * Get the minimum LanguageVersion to which this Rule applies. If this value * is null it indicates there is no minimum bound. - * + * * @return the minimum language version */ LanguageVersion getMinimumLanguageVersion(); /** * Set the minimum LanguageVersion to which this Rule applies. - * + * * @param minimumLanguageVersion * the minimum language version */ @@ -72,14 +72,14 @@ public interface Rule extends PropertySource { /** * Get the maximum LanguageVersion to which this Rule applies. If this value * is null it indicates there is no maximum bound. - * + * * @return the maximum language version */ LanguageVersion getMaximumLanguageVersion(); /** * Set the maximum LanguageVersion to which this Rule applies. - * + * * @param maximumLanguageVersion * the maximum language version */ @@ -94,14 +94,14 @@ public interface Rule extends PropertySource { *
  • or, has been renamed/moved and the old name will be completely * removed in a future version of PMD
  • * - * + * * @return true if this rule is deprecated */ boolean isDeprecated(); /** * Sets whether this Rule is deprecated. - * + * * @param deprecated * whether this rule is deprecated */ @@ -109,14 +109,14 @@ public interface Rule extends PropertySource { /** * Get the name of this Rule. - * + * * @return the name */ String getName(); /** * Set the name of this Rule. - * + * * @param name * the name */ @@ -125,14 +125,14 @@ public interface Rule extends PropertySource { /** * Get the version of PMD in which this Rule was added. Return * null if not applicable. - * + * * @return version of PMD since when this rule was added */ String getSince(); /** * Set the version of PMD in which this Rule was added. - * + * * @param since * the version of PMD since when this rule was added */ @@ -140,14 +140,14 @@ public interface Rule extends PropertySource { /** * Get the implementation class of this Rule. - * + * * @return the implementation class name of this rule. */ String getRuleClass(); /** * Set the class of this Rule. - * + * * @param ruleClass * the class name of this rule. */ @@ -155,7 +155,7 @@ public interface Rule extends PropertySource { /** * Get the name of the RuleSet containing this Rule. - * + * * @return the name of th ruleset containing this rule. * @see RuleSet */ @@ -163,7 +163,7 @@ public interface Rule extends PropertySource { /** * Set the name of the RuleSet containing this Rule. - * + * * @param name * the name of the ruleset containing this rule. * @see RuleSet @@ -172,14 +172,14 @@ public interface Rule extends PropertySource { /** * Get the message to show when this Rule identifies a violation. - * + * * @return the message to show for a violation. */ String getMessage(); /** * Set the message to show when this Rule identifies a violation. - * + * * @param message * the message to show for a violation. */ @@ -187,14 +187,14 @@ public interface Rule extends PropertySource { /** * Get the description of this Rule. - * + * * @return the description */ String getDescription(); /** * Set the description of this Rule. - * + * * @param description * the description */ @@ -202,14 +202,14 @@ public interface Rule extends PropertySource { /** * Get the list of examples for this Rule. - * + * * @return the list of examples for this rule. */ List getExamples(); /** * Add a single example for this Rule. - * + * * @param example * a single example to add */ @@ -217,14 +217,14 @@ public interface Rule extends PropertySource { /** * Get a URL for external information about this Rule. - * + * * @return the URL for external information about this rule. */ String getExternalInfoUrl(); /** * Set a URL for external information about this Rule. - * + * * @param externalInfoUrl * the URL for external information about this rule. */ @@ -232,14 +232,14 @@ public interface Rule extends PropertySource { /** * Get the priority of this Rule. - * + * * @return the priority */ RulePriority getPriority(); /** * Set the priority of this Rule. - * + * * @param priority * the priority */ @@ -250,7 +250,7 @@ public interface Rule extends PropertySource { * configure the {@link net.sourceforge.pmd.lang.Parser} to create an AST in * the form the Rule is expecting. Because ParserOptions are mutable, a Rule * should return a new instance on each call. - * + * * @return the parser options */ ParserOptions getParserOptions(); @@ -263,7 +263,7 @@ public interface Rule extends PropertySource { /** * Gets whether this Rule uses Data Flow Analysis. - * + * * @return true if Data Flow Analysis is used. */ // FUTURE Use JavaBean conventions for boolean attributes @@ -277,7 +277,7 @@ public interface Rule extends PropertySource { /** * Gets whether this Rule uses Type Resolution. - * + * * @return true if Type Resolution is used. */ // FUTURE Use JavaBean conventions for boolean attributes @@ -285,7 +285,7 @@ public interface Rule extends PropertySource { /** * Gets whether this Rule uses the RuleChain. - * + * * @return true if RuleChain is used. */ // FUTURE Use JavaBean conventions for boolean attributes @@ -294,14 +294,14 @@ public interface Rule extends PropertySource { /** * Gets the collection of AST node names visited by the Rule on the * RuleChain. - * + * * @return the list of AST node names */ List getRuleChainVisits(); /** * Adds an AST node by class to be visited by the Rule on the RuleChain. - * + * * @param nodeClass * the AST node to add to the RuleChain visit list */ @@ -309,7 +309,7 @@ public interface Rule extends PropertySource { /** * Adds an AST node by name to be visited by the Rule on the RuleChain. - * + * * @param astNodeName * the AST node to add to the RuleChain visit list as string */ @@ -317,7 +317,7 @@ public interface Rule extends PropertySource { /** * Start processing. Called once, before apply() is first called. - * + * * @param ctx * the rule context */ @@ -326,7 +326,7 @@ public interface Rule extends PropertySource { /** * Apply this rule to the given collection of nodes, using the given * context. - * + * * @param nodes * the nodes * @param ctx @@ -336,7 +336,7 @@ public interface Rule extends PropertySource { /** * End processing. Called once, after apply() is last called. - * + * * @param ctx * the rule context */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleChain.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleChain.java index cd5d26a085..fd86b9b8ae 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleChain.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleChain.java @@ -25,7 +25,7 @@ public class RuleChain { /** * Add all Rules from the given RuleSet which want to participate in the * RuleChain. - * + * * @param ruleSet * The RuleSet to add Rules from. */ @@ -37,7 +37,7 @@ public class RuleChain { /** * Add the given Rule if it wants to participate in the RuleChain. - * + * * @param ruleSet * The RuleSet to which the rule belongs. * @param rule @@ -53,7 +53,7 @@ public class RuleChain { /** * Apply the RuleChain to the given Nodes using the given RuleContext, for * those rules using the given Language. - * + * * @param nodes * The Nodes. * @param ctx diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java index ec0d207c4b..e9614c3885 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleContext.java @@ -46,7 +46,7 @@ public class RuleContext { /** * Constructor which shares attributes and report listeners with the given * RuleContext. - * + * * @param ruleContext * the context from which the values are shared */ @@ -57,7 +57,7 @@ public class RuleContext { /** * Get the Report to which Rule Violations are sent. - * + * * @return The Report. */ public Report getReport() { @@ -66,7 +66,7 @@ public class RuleContext { /** * Set the Report to which Rule Violations are sent. - * + * * @param report * The Report. */ @@ -76,7 +76,7 @@ public class RuleContext { /** * Get the File associated with the current source file. - * + * * @return The File. */ public File getSourceCodeFile() { @@ -87,7 +87,7 @@ public class RuleContext { * Set the File associated with the current source file. While this may be * set to null, the exclude/include facilities will not work * properly without a File. - * + * * @param sourceCodeFile * The File. */ @@ -97,7 +97,7 @@ public class RuleContext { /** * Get the file name associated with the current source file. - * + * * @return The file name. */ public String getSourceCodeFilename() { @@ -106,7 +106,7 @@ public class RuleContext { /** * Set the file name associated with the current source file. - * + * * @param filename * The file name. */ @@ -116,7 +116,7 @@ public class RuleContext { /** * Get the LanguageVersion associated with the current source file. - * + * * @return The LanguageVersion, null if unknown. */ public LanguageVersion getLanguageVersion() { @@ -224,7 +224,7 @@ public class RuleContext { * If set to false then the processing will be aborted with the * exception. This is especially useful during unit tests, in order to not * oversee any exceptions. - * + * * @param ignoreExceptions * if true simply skip failing rules (default). */ @@ -236,7 +236,7 @@ public class RuleContext { * Gets the configuration whether to skip failing rules (true) * or whether to throw a a RuntimeException and abort the processing for the * first failing rule. - * + * * @return true when failing rules are skipped, * false otherwise. */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RulePriority.java b/pmd-core/src/main/java/net/sourceforge/pmd/RulePriority.java index dfddd68fcb..4ef99b380e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RulePriority.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RulePriority.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd; /** * These are the possible Rule priority values. - * + * * For backward compatibility, priorities range in value from 1 to 5, with 5 * being the lowest priority. This means the ordinal value of the Enum should be * avoided in favor of {@link RulePriority#getPriority()} and @@ -43,7 +43,7 @@ public enum RulePriority { private final int priority; private final String name; - private RulePriority(int priority, String name) { + RulePriority(int priority, String name) { this.priority = priority; this.name = name; } @@ -69,7 +69,7 @@ public enum RulePriority { /** * Returns the descriptive name of the priority. - * + * * @return descriptive name of the priority * @see #getName() */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java index a5bca18091..af77d9e0bc 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSet.java @@ -524,7 +524,7 @@ public class RuleSet { private void patternsChanged() { filter = null; // ensure we start with one that reflects the current - // patterns + // patterns } /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java index b036318d76..899b6388cc 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java @@ -74,7 +74,7 @@ public class RuleSetFactory { /** * Set the minimum rule priority threshold for all Rules which are loaded * from RuleSets via reference. - * + * * @param minimumPriority * The minimum priority. */ @@ -85,7 +85,7 @@ public class RuleSetFactory { /** * Set whether warning messages should be logged for usage of deprecated * Rules. - * + * * @param warnDeprecated * true to log warning messages. */ @@ -105,7 +105,7 @@ public class RuleSetFactory { /** * Gets the compatibility filter in order to adjust it, e.g. add additional * filters. - * + * * @return the {@link RuleSetFactoryCompatibility} */ public RuleSetFactoryCompatibility getCompatibilityFilter() { @@ -244,7 +244,7 @@ public class RuleSetFactory { /** * Parse a ruleset node to construct a RuleSet. - * + * * @param ruleSetReferenceId * The RuleSetReferenceId of the RuleSet being parsed. * @param withDeprecatedRuleReferences @@ -309,7 +309,7 @@ public class RuleSetFactory { } } - private static RuleSet classNotFoundProblem(Exception ex) throws RuntimeException { + private static RuleSet classNotFoundProblem(Exception ex) { ex.printStackTrace(); throw new RuntimeException("Couldn't find the class " + ex.getMessage()); } @@ -563,12 +563,9 @@ public class RuleSetFactory { otherRuleSetReferenceId = new RuleSetReferenceId(ref, ruleSetReferenceId); isSameRuleSet = true; } - Rule referencedRule = ruleSetFactory.createRule(otherRuleSetReferenceId, true); // do - // not - // ignore - // deprecated - // rule - // references + // do not ignore deprecated rule references + Rule referencedRule = ruleSetFactory.createRule(otherRuleSetReferenceId, true); + if (referencedRule == null) { throw new IllegalArgumentException("Unable to find referenced rule " + otherRuleSetReferenceId.getRuleName() + "; perhaps the rule name is mispelled?"); @@ -646,7 +643,7 @@ public class RuleSetFactory { /** * Check whether the given ruleName is contained in the given ruleset. - * + * * @param ruleSetReferenceId * the ruleset to check * @param ruleName @@ -794,9 +791,8 @@ public class RuleSetFactory { for (Map.Entry entry : valueKeys.entrySet()) { String valueStr = propertyElement.getAttribute(entry.getKey()); if (entry.getValue() && StringUtil.isEmpty(valueStr)) { - System.out.println("Missing required value for: " + entry.getKey()); // debug - // pt - // TODO + // TODO debug pt + System.out.println("Missing required value for: " + entry.getKey()); } values.put(entry.getKey(), valueStr); } @@ -836,7 +832,7 @@ public class RuleSetFactory { /** * Determine if the specified rule element will represent a Rule with the * given name. - * + * * @param ruleElement * The rule element. * @param ruleName diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactoryCompatibility.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactoryCompatibility.java index 3b8ce5f918..3d89c3bb32 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactoryCompatibility.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactoryCompatibility.java @@ -28,7 +28,7 @@ import org.apache.commons.io.IOUtils; public class RuleSetFactoryCompatibility { private static final Logger LOG = Logger.getLogger(RuleSetFactoryCompatibility.class.getName()); - private List filters = new LinkedList(); + private List filters = new LinkedList<>(); /** * Creates a new instance of the compatibility filter with the built-in @@ -107,7 +107,7 @@ public class RuleSetFactoryCompatibility { /** * Determines the encoding of the given bytes, assuming this is a XML * document, which specifies the encoding in the first 1024 bytes. - * + * * @param bytes * the input bytes, might be more or less than 1024 bytes * @return the determined encoding, falls back to the default UTF-8 encoding @@ -185,8 +185,9 @@ public class RuleSetFactoryCompatibility { } } - if (exclusionPattern == null) + if (exclusionPattern == null) { return result; + } Matcher exclusions = exclusionPattern.matcher(result); if (exclusions.find()) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java index 10eac4ce3f..8e4e876c74 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetReferenceId.java @@ -24,27 +24,27 @@ import net.sourceforge.pmd.util.StringUtil; * RuleSet XML. The RuleSet reference can refer to either an external RuleSet or * the current RuleSet when used as a Rule 'ref' attribute value. An individual * Rule in the RuleSet can be indicated. - * + * * For an external RuleSet, referring to the entire RuleSet, the format is * ruleSetName, where the RuleSet name is either a resource file path to * a RuleSet that ends with '.xml'., or a simple RuleSet name. - * + * * A simple RuleSet name, is one which contains no path separators, and either * contains a '-' or is entirely numeric release number. A simple name of the * form [language]-[name] is short for the full RuleSet name * rulesets/[language]/[name].xml. A numeric release simple name of * the form [release] is short for the full PMD Release RuleSet * name rulesets/releases/[release].xml. - * + * * For an external RuleSet, referring to a single Rule, the format is * ruleSetName/ruleName, where the RuleSet name is as described above. A * Rule with the ruleName should exist in this external RuleSet. - * + * * For the current RuleSet, the format is ruleName, where the Rule name * is not RuleSet name (i.e. contains no path separators, '-' or '.xml' in it, * and is not all numeric). A Rule with the ruleName should exist in the * current RuleSet. - * + * * * * @@ -90,7 +90,7 @@ public class RuleSetReferenceId { /** * Construct a RuleSetReferenceId for the given single ID string. - * + * * @param id * The id string. * @throws IllegalArgumentException @@ -106,7 +106,7 @@ public class RuleSetReferenceId { * external RuleSetReferenceId is given, the ID must refer to a non-external * Rule. The external RuleSetReferenceId will be responsible for producing * the InputStream containing the Rule. - * + * * @param id * The id string. * @param externalRuleSetReferenceId @@ -219,7 +219,7 @@ public class RuleSetReferenceId { /** * Tries to load the given ruleset. - * + * * @param name * the ruleset name * @return true if the ruleset could be loaded, @@ -276,7 +276,7 @@ public class RuleSetReferenceId { * Extracts the rule name out of a ruleset path. E.g. for * "/my/ruleset.xml/MyRule" it would return "MyRule". If no single rule is * specified, null is returned. - * + * * @param rulesetName * the full rule set path * @return the rule name or null. @@ -334,7 +334,7 @@ public class RuleSetReferenceId { /** * Parse a String comma separated list of RuleSet reference IDs into a List * of RuleReferenceId instances. - * + * * @param referenceString * A comma separated list of RuleSet reference IDs. * @return The corresponding List of RuleSetReferenceId instances. @@ -356,7 +356,7 @@ public class RuleSetReferenceId { /** * Is this an external RuleSet reference? - * + * * @return true if this is an external reference, * false otherwise. */ @@ -366,7 +366,7 @@ public class RuleSetReferenceId { /** * Is this a reference to all Rules in a RuleSet, or a single Rule? - * + * * @return true if this is a reference to all Rules, * false otherwise. */ @@ -376,7 +376,7 @@ public class RuleSetReferenceId { /** * Get the RuleSet file name. - * + * * @return The RuleSet file name if this is an external reference, * null otherwise. */ @@ -386,7 +386,7 @@ public class RuleSetReferenceId { /** * Get the Rule name. - * + * * @return The Rule name. The Rule name. */ public String getRuleName() { @@ -423,12 +423,13 @@ public class RuleSetReferenceId { /** * Return the String form of this Rule reference. - * + * * @return Return the String form of this Rule reference, which is * ruleSetFileName for all Rule external references, * ruleSetFileName/ruleName, for a single Rule external * references, or ruleName otherwise. */ + @Override public String toString() { if (ruleSetFileName != null) { if (allRules) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java index dffdff315a..96bfefe61c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java @@ -267,20 +267,20 @@ public class RuleSetWriter { if (propertyDescriptors != null) { for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { // For - // each - // provided - // PropertyDescriptor + // each + // provided + // PropertyDescriptor if (propertyDescriptor instanceof PropertyDescriptorWrapper) { // Any - // wrapper - // property - // needs - // to - // go - // out - // as - // a - // definition. + // wrapper + // property + // needs + // to + // go + // out + // as + // a + // definition. if (propertiesElement == null) { propertiesElement = createPropertiesElement(); } @@ -290,16 +290,16 @@ public class RuleSetWriter { propertiesElement.appendChild(propertyElement); } else { if (propertiesByPropertyDescriptor != null) { // Otherwise, - // any - // property - // which has a - // value - // different - // than the - // default - // needs to go - // out as a - // value. + // any + // property + // which has a + // value + // different + // than the + // default + // needs to go + // out as a + // value. Object defaultValue = propertyDescriptor.defaultValue(); Object value = propertiesByPropertyDescriptor.get(propertyDescriptor); if (value != defaultValue && (value == null || !value.equals(defaultValue))) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java index abc1d3f98a..9255ec2fb9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java @@ -89,7 +89,7 @@ public class RuleSets { /** * Check if a given source file should be checked by rules in this RuleSets. - * + * * @param file * the source file to check * @return true if the file should be checked, @@ -165,7 +165,7 @@ public class RuleSets { * * Note: Since we support multiple languages, rule names are not expected to * be unique within any specific ruleset. - * + * * @param ruleName * the exact name of the rule to find * @return the rule or null if not found @@ -181,7 +181,7 @@ public class RuleSets { /** * Determines the total count of rules that are used in all rule sets. - * + * * @return the count */ public int ruleCount() { @@ -203,7 +203,7 @@ public class RuleSets { /** * Remove and collect any rules that report problems. - * + * * @param collector */ public void removeDysfunctionalRules(Collection collector) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java index 407963aab8..7267ab4e1e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolation.java @@ -7,28 +7,28 @@ package net.sourceforge.pmd; /** * A RuleViolation is created by a Rule when it identifies a violation of the * Rule constraints. - * + * * @see Rule */ public interface RuleViolation { /** * Get the Rule which identified this violation. - * + * * @return The identifying Rule. */ Rule getRule(); /** * Get the description of this violation. - * + * * @return The description. */ String getDescription(); /** * Indicates whether this violation has been suppressed. - * + * * @return true if this violation is suppressed, * false otherwise. */ @@ -36,7 +36,7 @@ public interface RuleViolation { /** * Get the source file name in which this violation was identified. - * + * * @return The source file name. */ String getFilename(); @@ -44,7 +44,7 @@ public interface RuleViolation { /** * Get the begin line number in the source file in which this violation was * identified. - * + * * @return Begin line number. */ int getBeginLine(); @@ -52,7 +52,7 @@ public interface RuleViolation { /** * Get the column number of the begin line in the source file in which this * violation was identified. - * + * * @return Begin column number. */ int getBeginColumn(); @@ -60,7 +60,7 @@ public interface RuleViolation { /** * Get the end line number in the source file in which this violation was * identified. - * + * * @return End line number. */ int getEndLine(); @@ -68,14 +68,14 @@ public interface RuleViolation { /** * Get the column number of the end line in the source file in which this * violation was identified. - * + * * @return End column number. */ int getEndColumn(); /** * Get the package name of the Class in which this violation was identified. - * + * * @return The package name. */ // TODO Isn't this Java specific? @@ -83,7 +83,7 @@ public interface RuleViolation { /** * Get the name of the Class in which this violation was identified. - * + * * @return The Class name. */ // TODO Isn't this Java specific? @@ -91,7 +91,7 @@ public interface RuleViolation { /** * Get the method name in which this violation was identified. - * + * * @return The method name. */ // TODO Isn't this Java specific? @@ -99,7 +99,7 @@ public interface RuleViolation { /** * Get the variable name on which this violation was identified. - * + * * @return The variable name. */ String getVariableName(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolationComparator.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolationComparator.java index 25eb306758..1947c7ddab 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolationComparator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleViolationComparator.java @@ -25,6 +25,7 @@ public final class RuleViolationComparator implements Comparator private RuleViolationComparator() { } + @Override public int compare(final RuleViolation r1, final RuleViolation r2) { int cmp = r1.getFilename().compareTo(r2.getFilename()); if (cmp == 0) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RulesetsFactoryUtils.java b/pmd-core/src/main/java/net/sourceforge/pmd/RulesetsFactoryUtils.java index 71f36b43e5..a52bcf6930 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RulesetsFactoryUtils.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RulesetsFactoryUtils.java @@ -20,7 +20,7 @@ public final class RulesetsFactoryUtils { /** * Creates a new rulesets with the given string. The resulting rulesets will * contain all referenced rulesets. - * + * * @param rulesets * the string with the rulesets to load * @param factory @@ -52,7 +52,7 @@ public final class RulesetsFactoryUtils { /** * See {@link #getRuleSets(String, RuleSetFactory)}. In addition, the * loading of the rules is benchmarked. - * + * * @param rulesets * the string with the rulesets to load * @param factory diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/SynchronizedReportListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/SynchronizedReportListener.java index 126e22ad01..10adbecf49 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/SynchronizedReportListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/SynchronizedReportListener.java @@ -16,7 +16,7 @@ public final class SynchronizedReportListener implements ReportListener { /** * Creates a new {@link SynchronizedReportListener} by wrapping the given * report listener. - * + * * @param listener * the listener to be synchronized */ @@ -27,6 +27,7 @@ public final class SynchronizedReportListener implements ReportListener { /** * {@inheritDoc} */ + @Override public synchronized void ruleViolationAdded(RuleViolation ruleViolation) { wrapped.ruleViolationAdded(ruleViolation); } @@ -34,6 +35,7 @@ public final class SynchronizedReportListener implements ReportListener { /** * {@inheritDoc} */ + @Override public synchronized void metricAdded(Metric metric) { wrapped.metricAdded(metric); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/ant/SourceLanguage.java b/pmd-core/src/main/java/net/sourceforge/pmd/ant/SourceLanguage.java index 3333e41482..6f0749535d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/ant/SourceLanguage.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/ant/SourceLanguage.java @@ -28,6 +28,7 @@ public class SourceLanguage { this.name = name; } + @Override public String toString() { return ""; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java b/pmd-core/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java index 4f4b71b27d..9bf65ffedf 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java @@ -157,15 +157,18 @@ public class PMDTaskImpl { configuration.setInputPaths(inputPaths); Renderer logRenderer = new AbstractRenderer("log", "Logging renderer") { + @Override public void start() { // Nothing to do } + @Override public void startFileAnalysis(DataSource dataSource) { project.log("Processing file " + dataSource.getNiceFileName(false, inputPaths), Project.MSG_VERBOSE); } + @Override public void renderFileReport(Report r) { int size = r.size(); if (size > 0) { @@ -173,10 +176,12 @@ public class PMDTaskImpl { } } + @Override public void end() { // Nothing to do } + @Override public String defaultFileExtension() { return null; } // not relevant diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/Benchmark.java b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/Benchmark.java index b6f9ffb5b7..6ed3b816f9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/Benchmark.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/Benchmark.java @@ -5,21 +5,30 @@ package net.sourceforge.pmd.benchmark; /** - * + * * @author Brian Remedios */ public enum Benchmark { - Rule(0, null), RuleChainRule(1, null), CollectFiles(2, "Collect files"), LoadRules(3, "Load rules"), Parser(4, - "Parser"), SymbolTable(5, "Symbol table"), DFA(6, "DFA"), TypeResolution(7, - "Type resolution"), RuleChainVisit(8, "RuleChain visit"), Reporting(9, "Reporting"), RuleTotal(10, - "Rule total"), RuleChainTotal(11, "Rule chain rule total"), MeasuredTotal(12, - "Measured total"), NonMeasuredTotal(13, - "Non-measured total"), TotalPMD(14, "Total PMD"); + Rule(0, null), + RuleChainRule(1, null), + CollectFiles(2, "Collect files"), + LoadRules(3, "Load rules"), + Parser(4, "Parser"), + SymbolTable(5, "Symbol table"), + DFA(6, "DFA"), + TypeResolution(7, "Type resolution"), + RuleChainVisit(8, "RuleChain visit"), + Reporting(9, "Reporting"), + RuleTotal(10, "Rule total"), + RuleChainTotal(11, "Rule chain rule total"), + MeasuredTotal(12, "Measured total"), + NonMeasuredTotal(13, "Non-measured total"), + TotalPMD(14, "Total PMD"); public final int index; public final String name; - private Benchmark(int idx, String theName) { + Benchmark(int idx, String theName) { index = idx; name = theName; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/BenchmarkReport.java b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/BenchmarkReport.java index 9a5aefd434..49f021cf40 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/BenchmarkReport.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/BenchmarkReport.java @@ -9,20 +9,20 @@ import java.util.Map; import java.util.Set; /** - * + * * @author Brian Remedios */ public interface BenchmarkReport { /** - * + * * @param stressResults * @param out */ void generate(Set stressResults, PrintStream out); /** - * + * * @param benchmarksByName * @param out */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/BenchmarkResult.java b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/BenchmarkResult.java index af471b5ffb..80ec47df53 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/BenchmarkResult.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/BenchmarkResult.java @@ -11,12 +11,12 @@ class BenchmarkResult implements Comparable { private long time; private long count; - public BenchmarkResult(Benchmark type, String name) { + BenchmarkResult(Benchmark type, String name) { this.type = type; this.name = name; } - public BenchmarkResult(Benchmark type, long time, long count) { + BenchmarkResult(Benchmark type, long time, long count) { this(type, type.name); this.time = time; this.count = count; @@ -35,6 +35,7 @@ class BenchmarkResult implements Comparable { this.count += count; } + @Override public int compareTo(BenchmarkResult benchmarkResult) { int cmp = type.index - benchmarkResult.type.index; if (cmp == 0) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/StringBuilderCR.java b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/StringBuilderCR.java index 6e47fd6c1c..a07840f606 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/StringBuilderCR.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/StringBuilderCR.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.benchmark; /** * A wrapped StringBuilder that appends a variable number of text segments * efficiently and always appends the specified carriage return terminator. - * + * * @author Brian Remedios */ public class StringBuilderCR { @@ -32,6 +32,7 @@ public class StringBuilderCR { sb.append(cr); } + @Override public String toString() { return sb.toString(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TextReport.java b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TextReport.java index 2ce19773c1..c9fe38555d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TextReport.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TextReport.java @@ -34,6 +34,7 @@ public class TextReport implements BenchmarkReport { * @see net.sourceforge.pmd.benchmark.BenchmarkReport#generate(Set, * PrintStream) */ + @Override public void generate(Set stressResults, PrintStream out) { out.println("========================================================="); @@ -70,6 +71,7 @@ public class TextReport implements BenchmarkReport { * @see net.sourceforge.pmd.benchmark.BenchmarkReport#generate(Map, * PrintStream) */ + @Override public void generate(Map benchmarksByName, PrintStream out) { List results = new ArrayList<>(benchmarksByName.values()); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDCommandLineInterface.java b/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDCommandLineInterface.java index 5e0e22e5ba..e1b280a541 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDCommandLineInterface.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDCommandLineInterface.java @@ -6,15 +6,15 @@ package net.sourceforge.pmd.cli; import java.util.Properties; -import com.beust.jcommander.JCommander; -import com.beust.jcommander.ParameterException; - import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.PropertyDescriptor; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.renderers.RendererFactory; +import com.beust.jcommander.JCommander; +import com.beust.jcommander.ParameterException; + /** * @author Romain Pelisse * @@ -81,7 +81,8 @@ public class PMDCommandLineInterface { fullText += "Available report formats and their configuration properties are:" + PMD.EOL + getReports() + PMD.EOL + getExamples() + PMD.EOL + PMD.EOL + PMD.EOL; - return fullText += usage.toString(); + fullText += usage.toString(); + return fullText; } private static String getExamples() { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDParameters.java b/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDParameters.java index 920055baed..4338774eb9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDParameters.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDParameters.java @@ -9,20 +9,20 @@ import java.util.ArrayList; import java.util.List; import java.util.Properties; -import com.beust.jcommander.IStringConverter; -import com.beust.jcommander.Parameter; -import com.beust.jcommander.ParameterException; -import com.beust.jcommander.validators.PositiveInteger; - import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersion; +import com.beust.jcommander.IStringConverter; +import com.beust.jcommander.Parameter; +import com.beust.jcommander.ParameterException; +import com.beust.jcommander.validators.PositiveInteger; + public class PMDParameters { - @Parameter(names = { "-rulesets", - "-R" }, description = "Comma separated list of ruleset names to use.", required = true) + @Parameter(names = { "-rulesets", "-R" }, description = "Comma separated list of ruleset names to use.", + required = true) private String rulesets; @Parameter(names = { "-uri", "-u" }, description = "Database URI for sources.", required = false) @@ -31,8 +31,8 @@ public class PMDParameters { @Parameter(names = { "-dir", "-d" }, description = "Root directory for sources.", required = false) private String sourceDir; - @Parameter(names = { - "-filelist" }, description = "Path to a file containing a list of files to analyze.", required = false) + @Parameter(names = { "-filelist" }, description = "Path to a file containing a list of files to analyze.", + required = false) private String fileListPath; @Parameter(names = { "-format", "-f" }, description = "Report format type.") @@ -44,16 +44,16 @@ public class PMDParameters { @Parameter(names = { "-help", "-h", "-H" }, description = "Display help on usage.", help = true) private boolean help = false; - @Parameter(names = { "-encoding", - "-e" }, description = "Specifies the character set encoding of the source code files PMD is reading (i.e., UTF-8).") + @Parameter(names = { "-encoding", "-e" }, + description = "Specifies the character set encoding of the source code files PMD is reading (i.e., UTF-8).") private String encoding = "UTF-8"; - @Parameter(names = { "-threads", - "-t" }, description = "Sets the number of threads used by PMD.", validateWith = PositiveInteger.class) + @Parameter(names = { "-threads", "-t" }, description = "Sets the number of threads used by PMD.", + validateWith = PositiveInteger.class) private Integer threads = 1; - @Parameter(names = { "-benchmark", - "-b" }, description = "Benchmark mode - output a benchmark report upon completion; default to System.err.") + @Parameter(names = { "-benchmark", "-b" }, + description = "Benchmark mode - output a benchmark report upon completion; default to System.err.") private boolean benchmark = false; @Parameter(names = { "-stress", "-S" }, description = "Performs a stress test.") @@ -65,15 +65,17 @@ public class PMDParameters { @Parameter(names = "-showsuppressed", description = "Report should show suppressed rule violations.") private boolean showsuppressed = false; - @Parameter(names = "-suppressmarker", description = "Specifies the string that marks the a line which PMD should ignore; default is NOPMD.") + @Parameter(names = "-suppressmarker", + description = "Specifies the string that marks the a line which PMD should ignore; default is NOPMD.") private String suppressmarker = "NOPMD"; - @Parameter(names = { "-minimumpriority", - "-min" }, description = "Rule priority threshold; rules with lower priority than configured here won't be used. Default is '5' which is the lowest priority.", converter = RulePriorityConverter.class) + @Parameter(names = { "-minimumpriority", "-min" }, + description = "Rule priority threshold; rules with lower priority than configured here won't be used. Default is '5' which is the lowest priority.", + converter = RulePriorityConverter.class) private RulePriority minimumPriority = RulePriority.LOW; - @Parameter(names = { "-property", - "-P" }, description = "{name}={value}: Define a property for the report format.", converter = PropertyConverter.class) + @Parameter(names = { "-property", "-P" }, description = "{name}={value}: Define a property for the report format.", + converter = PropertyConverter.class) private List properties = new ArrayList<>(); @Parameter(names = { "-reportfile", "-r" }, description = "Sends report output to a file; default to System.out.") @@ -85,14 +87,16 @@ public class PMDParameters { @Parameter(names = { "-language", "-l" }, description = "Specify a language PMD should use.") private String language = null; - @Parameter(names = "-auxclasspath", description = "Specifies the classpath for libraries used by the source code. This is used by the type resolution. Alternatively, a 'file://' URL to a text file containing path elements on consecutive lines can be specified.") + @Parameter(names = "-auxclasspath", + description = "Specifies the classpath for libraries used by the source code. This is used by the type resolution. Alternatively, a 'file://' URL to a text file containing path elements on consecutive lines can be specified.") private String auxclasspath; - @Parameter(names = { "-failOnViolation", - "--failOnViolation" }, arity = 1, description = "By default PMD exits with status 4 if violations are found. Disable this option with '-failOnViolation false' to exit with 0 instead and just write the report.") + @Parameter(names = { "-failOnViolation", "--failOnViolation" }, arity = 1, + description = "By default PMD exits with status 4 if violations are found. Disable this option with '-failOnViolation false' to exit with 0 instead and just write the report.") private boolean failOnViolation = true; - @Parameter(names = "-norulesetcompatibility", description = "Disable the ruleset compatibility filter. The filter is active by default and tries automatically 'fix' old ruleset files with old rule names") + @Parameter(names = "-norulesetcompatibility", + description = "Disable the ruleset compatibility filter. The filter is active by default and tries automatically 'fix' old ruleset files with old rule names") private boolean noRuleSetCompatibility = false; // this has to be a public static class, so that JCommander can use it! @@ -100,6 +104,7 @@ public class PMDParameters { private static final char SEPARATOR = '='; + @Override public Properties convert(String value) { int indexOfSeparator = value.indexOf(SEPARATOR); if (indexOfSeparator < 0) { @@ -126,6 +131,7 @@ public class PMDParameters { return minPriorityValue; } + @Override public RulePriority convert(String value) { return RulePriority.valueOf(validate(value)); } @@ -246,7 +252,7 @@ public class PMDParameters { public String getFileListPath() { return fileListPath; - }; + } public String getFormat() { return format; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AbstractLanguage.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AbstractLanguage.java index 261556f621..a6485062b5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AbstractLanguage.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AbstractLanguage.java @@ -26,26 +26,32 @@ public abstract class AbstractLanguage implements Language { this.extensions = Arrays.asList(extensions); } + @Override public FilenameFilter getFileFilter() { return fileFilter; } + @Override public Tokenizer getTokenizer() { return tokenizer; } + @Override public void setProperties(Properties properties) { // needs to be implemented by subclasses. } + @Override public String getName() { return name; } + @Override public String getTerseName() { return terseName; } + @Override public List getExtensions() { return extensions; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AbstractTokenizer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AbstractTokenizer.java index fc71c74b86..39c63357e4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AbstractTokenizer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AbstractTokenizer.java @@ -17,28 +17,29 @@ public abstract class AbstractTokenizer implements Tokenizer { // better to make private and setup via explicit hook methods protected List stringToken; // List, should be set by sub - // classes + // classes protected List ignorableCharacter; // List, should be set by - // sub classes - // FIXME:Maybe an array of 'char' - // would be better for - // performance ? + // sub classes + // FIXME:Maybe an array of 'char' + // would be better for + // performance ? protected List ignorableStmt; // List, should be set by sub - // classes + // classes protected char oneLineCommentChar = '#'; // Most script languages ( shell, - // ruby, python,...) use this - // symbol for comment line + // ruby, python,...) use this + // symbol for comment line private List code; private int lineNumber = 0; private String currentLine; protected boolean spanMultipleLinesString = true; // Most languages do, so - // default is true + // default is true protected Character spanMultipleLinesLineContinuationCharacter = null; private boolean downcaseString = true; + @Override public void tokenize(SourceCode tokens, Tokens tokenEntries) { code = tokens.getCode(); @@ -77,7 +78,7 @@ public abstract class AbstractTokenizer implements Tokenizer { } else if (isString(tok)) { if (token.length() > 0) { return j; // we need to now parse the string as a - // separate token. + // separate token. } else { // we are at the start of a string return parseString(token, j, tok); @@ -118,13 +119,13 @@ public abstract class AbstractTokenizer implements Tokenizer { // Handling multiple lines string if (!done && // ... we didn't find the end of the string loc >= currentLine.length() && // ... we have reach the end of - // the line ( the String is - // incomplete, for the moment at - // least) + // the line ( the String is + // incomplete, for the moment at + // least) spanMultipleLinesString && // ... the language allow multiple - // line span Strings + // line span Strings lineNumber < code.size() - 1 // ... there is still more lines to - // parse + // parse ) { // removes last character, if it is the line continuation (e.g. // backslash) character diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AnyTokenizer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AnyTokenizer.java index cee67b4da4..c3449f579c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AnyTokenizer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AnyTokenizer.java @@ -19,6 +19,7 @@ import org.apache.commons.io.IOUtils; public class AnyTokenizer implements Tokenizer { public static final String TOKENS = " \t!#$%^&*(){}-=+<>/\\`~;:"; + @Override public void tokenize(SourceCode sourceCode, Tokens tokenEntries) { StringBuilder sb = sourceCode.getCodeBuffer(); BufferedReader reader = new BufferedReader(new CharArrayReader(sb.toString().toCharArray())); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPD.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPD.java index fc8c12669d..b1ed3e7788 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPD.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPD.java @@ -157,7 +157,7 @@ public class CPD { /** * List names/paths of each source to be processed. - * + * * @return names of sources to be processed */ public List getSourcePaths() { @@ -166,7 +166,7 @@ public class CPD { /** * Get each Source to be processed. - * + * * @return all Sources to be processed */ public List getSources() { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDCommandLineInterface.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDCommandLineInterface.java index 7c3136672c..c97f01e89e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDCommandLineInterface.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDCommandLineInterface.java @@ -12,12 +12,12 @@ import java.util.Arrays; import java.util.List; import java.util.logging.Logger; -import com.beust.jcommander.JCommander; -import com.beust.jcommander.ParameterException; - import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.util.database.DBURI; +import com.beust.jcommander.JCommander; +import com.beust.jcommander.ParameterException; + public class CPDCommandLineInterface { private static final Logger LOGGER = Logger.getLogger(CPDCommandLineInterface.class.getName()); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java index e92ae4e99f..06480117af 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java @@ -20,14 +20,14 @@ import java.util.Map; import java.util.Properties; import java.util.Set; -import com.beust.jcommander.IStringConverter; -import com.beust.jcommander.Parameter; -import com.beust.jcommander.converters.FileConverter; - import net.sourceforge.pmd.AbstractConfiguration; import net.sourceforge.pmd.util.FileFinder; import net.sourceforge.pmd.util.FileUtil; +import com.beust.jcommander.IStringConverter; +import com.beust.jcommander.Parameter; +import com.beust.jcommander.converters.FileConverter; + /** * * @author Brian Remedios @@ -41,18 +41,20 @@ public class CPDConfiguration extends AbstractConfiguration { private static final Map> RENDERERS = new HashMap<>(); - @Parameter(names = "--language", description = "Sources code language. Default value is " - + DEFAULT_LANGUAGE, required = false, converter = LanguageConverter.class) + @Parameter(names = "--language", description = "Sources code language. Default value is " + DEFAULT_LANGUAGE, + required = false, converter = LanguageConverter.class) private Language language; - @Parameter(names = "--minimum-tokens", description = "The minimum token length which should be reported as a duplicate.", required = true) + @Parameter(names = "--minimum-tokens", + description = "The minimum token length which should be reported as a duplicate.", required = true) private int minimumTileSize; - @Parameter(names = "--skip-duplicate-files", description = "Ignore multiple copies of files of the same name and length in comparison", required = false) + @Parameter(names = "--skip-duplicate-files", + description = "Ignore multiple copies of files of the same name and length in comparison", required = false) private boolean skipDuplicates; - @Parameter(names = "--format", description = "Report format. Default value is " - + DEFAULT_RENDERER, required = false) + @Parameter(names = "--format", description = "Report format. Default value is " + DEFAULT_RENDERER, + required = false) private String rendererName; /** @@ -63,32 +65,43 @@ public class CPDConfiguration extends AbstractConfiguration { private String encoding; - @Parameter(names = "--ignore-literals", description = "Ignore number values and string contents when comparing text", required = false) + @Parameter(names = "--ignore-literals", + description = "Ignore number values and string contents when comparing text", required = false) private boolean ignoreLiterals; - @Parameter(names = "--ignore-identifiers", description = "Ignore constant and variable names when comparing text", required = false) + @Parameter(names = "--ignore-identifiers", description = "Ignore constant and variable names when comparing text", + required = false) private boolean ignoreIdentifiers; - @Parameter(names = "--ignore-annotations", description = "Ignore language annotations when comparing text", required = false) + @Parameter(names = "--ignore-annotations", description = "Ignore language annotations when comparing text", + required = false) private boolean ignoreAnnotations; @Parameter(names = "--ignore-usings", description = "Ignore using directives in C#", required = false) private boolean ignoreUsings; - @Parameter(names = "--skip-lexical-errors", description = "Skip files which can't be tokenized due to invalid characters instead of aborting CPD", required = false) + @Parameter(names = "--skip-lexical-errors", + description = "Skip files which can't be tokenized due to invalid characters instead of aborting CPD", + required = false) private boolean skipLexicalErrors = false; - @Parameter(names = "--no-skip-blocks", description = "Do not skip code blocks marked with --skip-blocks-pattern (e.g. #if 0 until #endif)", required = false) + @Parameter(names = "--no-skip-blocks", + description = "Do not skip code blocks marked with --skip-blocks-pattern (e.g. #if 0 until #endif)", + required = false) private boolean noSkipBlocks = false; - @Parameter(names = "--skip-blocks-pattern", description = "Pattern to find the blocks to skip. Start and End pattern separated by |. " - + "Default is \"" + Tokenizer.DEFAULT_SKIP_BLOCKS_PATTERN + "\".", required = false) + @Parameter(names = "--skip-blocks-pattern", + description = "Pattern to find the blocks to skip. Start and End pattern separated by |. " + "Default is \"" + + Tokenizer.DEFAULT_SKIP_BLOCKS_PATTERN + "\".", + required = false) private String skipBlocksPattern = Tokenizer.DEFAULT_SKIP_BLOCKS_PATTERN; - @Parameter(names = "--files", variableArity = true, description = "List of files and directories to process", required = false, converter = FileConverter.class) + @Parameter(names = "--files", variableArity = true, description = "List of files and directories to process", + required = false, converter = FileConverter.class) private List files; - @Parameter(names = "--exclude", variableArity = true, description = "Files to be excluded from CPD check", required = false, converter = FileConverter.class) + @Parameter(names = "--exclude", variableArity = true, description = "Files to be excluded from CPD check", + required = false, converter = FileConverter.class) private List excludes; @Parameter(names = "--non-recursive", description = "Don't scan subdirectiories", required = false) @@ -100,8 +113,8 @@ public class CPDConfiguration extends AbstractConfiguration { @Parameter(names = { "--help", "-h" }, description = "Print help text", required = false, help = true) private boolean help; - @Parameter(names = { "--failOnViolation", - "-failOnViolation" }, arity = 1, description = "By default CPD exits with status 4 if code duplications are found. Disable this option with '-failOnViolation false' to exit with 0 instead and just write the report.") + @Parameter(names = { "--failOnViolation", "-failOnViolation" }, arity = 1, + description = "By default CPD exits with status 4 if code duplications are found. Disable this option with '-failOnViolation false' to exit with 0 instead and just write the report.") private boolean failOnViolation = true; // this has to be a public static class, so that JCommander can use it! @@ -154,7 +167,7 @@ public class CPDConfiguration extends AbstractConfiguration { /** * Gets a renderer with the platform's default encoding. - * + * * @param name * renderer name * @return a fresh renderer instance diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDNullListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDNullListener.java index 49400052bc..dd0a132bf1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDNullListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDNullListener.java @@ -7,9 +7,11 @@ package net.sourceforge.pmd.cpd; import java.io.File; public class CPDNullListener implements CPDListener { + @Override public void addedFile(int fileCount, File file) { } + @Override public void phaseUpdate(int phase) { } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDTask.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDTask.java index 4d1eca5e09..8300e72465 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDTask.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDTask.java @@ -54,6 +54,7 @@ public class CPDTask extends Task { private String encoding = System.getProperty("file.encoding"); private List filesets = new ArrayList<>(); + @Override public void execute() throws BuildException { ClassLoader oldClassloader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(CPDTask.class.getClassLoader()); @@ -230,6 +231,7 @@ public class CPDTask extends Task { public static class FormatAttribute extends EnumeratedAttribute { private static final String[] FORMATS = new String[] { XML_FORMAT, TEXT_FORMAT, CSV_FORMAT }; + @Override public String[] getValues() { return FORMATS; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CSVRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CSVRenderer.java index 529673ab6d..197b39c6cd 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CSVRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CSVRenderer.java @@ -35,6 +35,7 @@ public class CSVRenderer implements Renderer { this.lineCountPerFile = lineCountPerFile; } + @Override public String render(Iterator matches) { StringBuilder csv = new StringBuilder(1000); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/GUI.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/GUI.java index bf3e652d09..7cfbaec817 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/GUI.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/GUI.java @@ -53,6 +53,7 @@ import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.KeyStroke; +import javax.swing.ScrollPaneConstants; import javax.swing.SwingConstants; import javax.swing.Timer; import javax.swing.event.ListSelectionEvent; @@ -75,24 +76,28 @@ public class GUI implements CPDListener { // } private static final Object[][] RENDERER_SETS = new Object[][] { { "Text", new Renderer() { + @Override public String render(Iterator items) { return new SimpleRenderer().render(items); } - } }, { "XML", new Renderer() { + }, }, { "XML", new Renderer() { + @Override public String render(Iterator items) { return new XMLRenderer().render(items); } - } }, { "CSV (comma)", new Renderer() { + }, }, { "CSV (comma)", new Renderer() { + @Override public String render(Iterator items) { return new CSVRenderer(',').render(items); } - } }, { "CSV (tab)", new Renderer() { + }, }, { "CSV (tab)", new Renderer() { + @Override public String render(Iterator items) { return new CSVRenderer('\t').render(items); } - } } }; + }, }, }; - private static abstract class LanguageConfig { + private abstract static class LanguageConfig { public abstract Language languageFor(Properties p); public boolean canIgnoreIdentifiers() { @@ -184,7 +189,7 @@ public class GUI implements CPDListener { private int width; private Comparator sorter; - public ColumnSpec(String aLabel, int anAlignment, int aWidth, Comparator aSorter) { + ColumnSpec(String aLabel, int anAlignment, int aWidth, Comparator aSorter) { label = aLabel; alignment = anAlignment; width = aWidth; @@ -209,9 +214,9 @@ public class GUI implements CPDListener { } private final ColumnSpec[] matchColumns = new ColumnSpec[] { - new ColumnSpec("Source", SwingConstants.LEFT, -1, Match.LABEL_COMPARATOR), - new ColumnSpec("Matches", SwingConstants.RIGHT, 60, Match.MATCHES_COMPARATOR), - new ColumnSpec("Lines", SwingConstants.RIGHT, 45, Match.LINES_COMPARATOR), }; + new ColumnSpec("Source", SwingConstants.LEFT, -1, Match.LABEL_COMPARATOR), + new ColumnSpec("Matches", SwingConstants.RIGHT, 60, Match.MATCHES_COMPARATOR), + new ColumnSpec("Lines", SwingConstants.RIGHT, 45, Match.LINES_COMPARATOR), }; static { for (int i = 0; i < LANGUAGE_SETS.length; i++) { @@ -224,14 +229,17 @@ public class GUI implements CPDListener { } private static class CancelListener implements ActionListener { + @Override public void actionPerformed(ActionEvent e) { System.exit(0); } } private class GoListener implements ActionListener { + @Override public void actionPerformed(ActionEvent e) { new Thread(new Runnable() { + @Override public void run() { tokenizingFilesBar.setValue(0); tokenizingFilesBar.setString(""); @@ -248,10 +256,11 @@ public class GUI implements CPDListener { final Renderer renderer; - public SaveListener(Renderer theRenderer) { + SaveListener(Renderer theRenderer) { renderer = theRenderer; } + @Override public void actionPerformed(ActionEvent evt) { JFileChooser fcSave = new JFileChooser(); int ret = fcSave.showSaveDialog(GUI.this.frame); @@ -287,6 +296,7 @@ public class GUI implements CPDListener { } private class BrowseListener implements ActionListener { + @Override public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(rootDirectoryField.getText()); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); @@ -301,10 +311,11 @@ public class GUI implements CPDListener { private static final long serialVersionUID = -2190382865483285032L; private int[] alignments; - public AlignmentRenderer(int[] theAlignments) { + AlignmentRenderer(int[] theAlignments) { alignments = theAlignments; } + @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); @@ -368,6 +379,7 @@ public class GUI implements CPDListener { fileMenu.setMnemonic('v'); JMenuItem trimItem = new JCheckBoxMenuItem("Trim leading whitespace"); trimItem.addItemListener(new ItemListener() { + @Override public void itemStateChanged(ItemEvent e) { AbstractButton button = (AbstractButton) e.getItem(); GUI.this.trimLeadingWhitespace = button.isSelected(); @@ -434,6 +446,7 @@ public class GUI implements CPDListener { languageBox.addItem(String.valueOf(LANGUAGE_SETS[i][0])); } languageBox.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { adjustLanguageControlsFor(languageConfigFor((String) languageBox.getSelectedItem())); } @@ -505,7 +518,7 @@ public class GUI implements CPDListener { resultsPanel.setLayout(new BorderLayout()); JScrollPane areaScrollPane = new JScrollPane(resultsTextArea); resultsTextArea.setEditable(false); - areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + areaScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setPreferredSize(new Dimension(600, 300)); resultsPanel.add(makeMatchList(), BorderLayout.WEST); @@ -562,18 +575,21 @@ public class GUI implements CPDListener { private JComponent makeMatchList() { resultsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override public void valueChanged(ListSelectionEvent e) { populateResultArea(); } }); resultsTable.registerKeyboardAction(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { copyMatchListSelectionsToClipboard(); } }, "Copy", COPY_KEY_STROKE, JComponent.WHEN_FOCUSED); resultsTable.registerKeyboardAction(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { deleteMatchlistSelections(); } @@ -588,6 +604,7 @@ public class GUI implements CPDListener { final JTableHeader header = resultsTable.getTableHeader(); header.addMouseListener(new MouseAdapter() { + @Override public void mouseClicked(MouseEvent e) { sortOnColumn(header.columnAtPoint(new Point(e.getX(), e.getY()))); } @@ -664,8 +681,8 @@ public class GUI implements CPDListener { tokenizingFilesBar.setMinimum(0); phaseLabel.setText(""); if (isLegalPath(dirPath.getPath(), conf)) { // should use the - // language file filter - // instead? + // language file filter + // instead? cpd.add(dirPath); } else { if (recurseCheckbox.isSelected()) { @@ -709,6 +726,7 @@ public class GUI implements CPDListener { final long start = System.currentTimeMillis(); Timer t = new Timer(1000, new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { long now = System.currentTimeMillis(); long elapsedMillis = now - start; @@ -754,6 +772,7 @@ public class GUI implements CPDListener { private int sortColumn; private boolean sortDescending; + @Override public Object getValueAt(int rowIndex, int columnIndex) { Match match = items.get(rowIndex); switch (columnIndex) { @@ -770,51 +789,64 @@ public class GUI implements CPDListener { } } + @Override public int getColumnCount() { return matchColumns.length; } + @Override public int getRowCount() { return items.size(); } + @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return false; } + @Override public Class getColumnClass(int columnIndex) { return Object.class; } + @Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { } + @Override public String getColumnName(int i) { return matchColumns[i].label(); } + @Override public void addTableModelListener(TableModelListener l) { } + @Override public void removeTableModelListener(TableModelListener l) { } + @Override public int sortColumn() { return sortColumn; } + @Override public void sortColumn(int column) { sortColumn = column; } + @Override public boolean sortDescending() { return sortDescending; } + @Override public void sortDescending(boolean flag) { sortDescending = flag; } + @Override public void sort(Comparator comparator) { Collections.sort(items, comparator); if (sortDescending) { @@ -859,6 +891,7 @@ public class GUI implements CPDListener { } // CPDListener + @Override public void phaseUpdate(int phase) { phaseLabel.setText(getPhaseText(phase)); } @@ -880,6 +913,7 @@ public class GUI implements CPDListener { } } + @Override public void addedFile(int fileCount, File file) { tokenizingFilesBar.setMaximum(fileCount); tokenizingFilesBar.setValue(tokenizingFilesBar.getValue() + 1); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/LanguageFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/LanguageFactory.java index 3bd9a1bd8a..2fbd961994 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/LanguageFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/LanguageFactory.java @@ -18,6 +18,7 @@ public final class LanguageFactory { private static LanguageFactory instance = new LanguageFactory(); public static String[] supportedLanguages; + static { supportedLanguages = instance.languages.keySet().toArray(new String[instance.languages.size()]); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Match.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Match.java index fb5524ad0f..4bb9b83af4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Match.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Match.java @@ -18,18 +18,21 @@ public class Match implements Comparable { private String label; public static final Comparator MATCHES_COMPARATOR = new Comparator() { + @Override public int compare(Match ma, Match mb) { return mb.getMarkCount() - ma.getMarkCount(); } }; public static final Comparator LINES_COMPARATOR = new Comparator() { + @Override public int compare(Match ma, Match mb) { return mb.getLineCount() - ma.getLineCount(); } }; public static final Comparator LABEL_COMPARATOR = new Comparator() { + @Override public int compare(Match ma, Match mb) { if (ma.getLabel() == null) { return 1; @@ -42,6 +45,7 @@ public class Match implements Comparable { }; public static final Comparator LENGTH_COMPARATOR = new Comparator() { + @Override public int compare(Match ma, Match mb) { return mb.getLineCount() - ma.getLineCount(); } @@ -77,6 +81,7 @@ public class Match implements Comparable { return markSet.iterator(); } + @Override public int compareTo(Match other) { int diff = other.getTokenCount() - getTokenCount(); if (diff != 0) { @@ -93,6 +98,7 @@ public class Match implements Comparable { return getMark(1); } + @Override public String toString() { return "Match: " + PMD.EOL + "tokenCount = " + tokenCount + PMD.EOL + "marks = " + markSet.size(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SimpleRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SimpleRenderer.java index 73918b1397..dc2d4ef38b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SimpleRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SimpleRenderer.java @@ -41,7 +41,7 @@ public class SimpleRenderer implements Renderer { } rpt.append(PMD.EOL); // add a line to separate the source from the desc - // above + // above String source = match.getSourceCodeSlice(); @@ -60,6 +60,7 @@ public class SimpleRenderer implements Renderer { rpt.append(source).append(PMD.EOL); } + @Override public String render(Iterator matches) { StringBuilder rpt = new StringBuilder(300); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java index bd6c222fdb..b9a8302e63 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java @@ -95,6 +95,7 @@ public class TokenEntry implements Comparable { return this.index; } + @Override public int hashCode() { return hashCode; } @@ -103,6 +104,7 @@ public class TokenEntry implements Comparable { this.hashCode = hashCode; } + @Override public boolean equals(Object o) { if (!(o instanceof TokenEntry)) { return false; @@ -111,6 +113,7 @@ public class TokenEntry implements Comparable { return other.hashCode == hashCode; } + @Override public int compareTo(TokenEntry other) { return getIndex() - other.getIndex(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Tokenizer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Tokenizer.java index 6041ec7d25..77e2de54d9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Tokenizer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Tokenizer.java @@ -19,7 +19,7 @@ public interface Tokenizer { /** * Enables or disabled skipping of blocks like a pre-processor. It is a * boolean property. The default value is true. - * + * * @see #OPTION_SKIP_BLOCKS_PATTERN */ String OPTION_SKIP_BLOCKS = "net.sourceforge.pmd.cpd.Tokenizer.skipBlocks"; @@ -28,7 +28,7 @@ public interface Tokenizer { * property and contains of two parts, separated by {@code |}. The first * part is the start pattern, the second part is the ending pattern. Default * value is "{@code #if 0|#endif}". - * + * * @see #DEFAULT_SKIP_BLOCKS_PATTERN */ String OPTION_SKIP_BLOCKS_PATTERN = "net.sourceforge.pmd.cpd.Tokenizer.skipBlocksPattern"; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/VSRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/VSRenderer.java index ddea976914..8e80a783b7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/VSRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/VSRenderer.java @@ -10,6 +10,7 @@ import net.sourceforge.pmd.PMD; public class VSRenderer implements Renderer { + @Override public String render(Iterator matches) { StringBuilder buffer = new StringBuilder(300); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java index b6cea67524..14c28f458c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java @@ -23,7 +23,7 @@ import org.w3c.dom.Element; /** * @author Philippe T'Seyen - original implementation * @author Romain Pelisse - javax.xml implementation - * + * */ public final class XMLRenderer implements Renderer { @@ -38,7 +38,7 @@ public final class XMLRenderer implements Renderer { /** * Creates a XML Renderer with a specific output encoding. - * + * * @param encoding * the encoding to use or null. If null, default (platform * dependent) encoding is used. @@ -85,6 +85,7 @@ public final class XMLRenderer implements Renderer { } } + @Override public String render(Iterator matches) { Document doc = createDocument(); Element root = doc.createElement("pmd-cpd"); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/DCD.java b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/DCD.java index 35366a531c..5f94569407 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/DCD.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/DCD.java @@ -95,6 +95,7 @@ public class DCD { // Basic filter FilenameFilter javaFilter = new FilenameFilter() { + @Override public boolean accept(File dir, String name) { // Recurse on directories if (new File(dir, name).isDirectory()) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/UsageNodeVisitor.java b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/UsageNodeVisitor.java index 0cba65d91a..9d543cb201 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/UsageNodeVisitor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/UsageNodeVisitor.java @@ -110,6 +110,7 @@ public class UsageNodeVisitor extends NodeVisitorAdapter { private final Options options = new Options(); + @Override public Object visit(UsageGraph usageGraph, Object data) { System.out.println("----------------------------------------"); super.visit(usageGraph, data); @@ -117,6 +118,7 @@ public class UsageNodeVisitor extends NodeVisitorAdapter { return data; } + @Override public Object visit(ClassNode classNode, Object data) { boolean log = true; if (options.isIgnoreClassAnonymous() && classNode.getType().isAnonymousClass()) { @@ -131,6 +133,7 @@ public class UsageNodeVisitor extends NodeVisitorAdapter { } } + @Override public Object visit(FieldNode fieldNode, Object data) { if (fieldNode.getUsers().isEmpty()) { boolean log = true; @@ -152,6 +155,7 @@ public class UsageNodeVisitor extends NodeVisitorAdapter { return super.visit(fieldNode, data); } + @Override public Object visit(ConstructorNode constructorNode, Object data) { if (constructorNode.getUsers().isEmpty()) { boolean log = true; @@ -190,6 +194,7 @@ public class UsageNodeVisitor extends NodeVisitorAdapter { && method.getParameterTypes()[0].getComponentType().equals(java.lang.String.class); } + @Override public Object visit(MethodNode methodNode, Object data) { if (methodNode.getUsers().isEmpty()) { boolean log = true; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/ClassNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/ClassNode.java index 2285430f7f..72b8ab5e70 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/ClassNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/ClassNode.java @@ -31,6 +31,7 @@ public class ClassNode implements NodeVisitorAcceptor, Comparable { this.name = name; } + @Override public Object accept(NodeVisitor visitor, Object data) { visitor.visitFields(this, data); visitor.visitConstructors(this, data); @@ -107,10 +108,12 @@ public class ClassNode implements NodeVisitorAcceptor, Comparable { return methodNodes != null ? methodNodes : Collections.emptyList(); } + @Override public int compareTo(ClassNode that) { return this.name.compareTo(that.name); } + @Override public boolean equals(Object obj) { if (obj instanceof ClassNode) { return this.name.equals(((ClassNode) obj).name); @@ -118,6 +121,7 @@ public class ClassNode implements NodeVisitorAcceptor, Comparable { return false; } + @Override public int hashCode() { return name.hashCode(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/ClassNodeComparator.java b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/ClassNodeComparator.java index e913ea538a..1053396d49 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/ClassNodeComparator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/ClassNodeComparator.java @@ -17,6 +17,7 @@ public final class ClassNodeComparator implements Comparator { private ClassNodeComparator() { } + @Override public int compare(Object obj1, Object obj2) { if (obj1 instanceof String && obj2 instanceof String) { return ((String) obj1).compareTo((String) obj2); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/ConstructorNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/ConstructorNode.java index c44d0db941..6f2c6b1319 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/ConstructorNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/ConstructorNode.java @@ -33,6 +33,7 @@ public class ConstructorNode extends MemberNode> return ClassLoaderUtil.INIT.equals(name); } + @Override public Constructor getMember() { if (ClassLoaderUtil.CLINIT.equals(name)) { return null; @@ -50,6 +51,7 @@ public class ConstructorNode extends MemberNode> } } + @Override public String toStringLong() { if (ClassLoaderUtil.CLINIT.equals(name)) { return name; @@ -58,6 +60,7 @@ public class ConstructorNode extends MemberNode> } } + @Override public int compareTo(ConstructorNode that) { // Order by name int cmp = this.getName().compareTo(that.getName()); @@ -78,6 +81,7 @@ public class ConstructorNode extends MemberNode> return cmp; } + @Override public boolean equals(Object obj) { if (obj instanceof ConstructorNode) { ConstructorNode that = (ConstructorNode) obj; @@ -85,4 +89,12 @@ public class ConstructorNode extends MemberNode> } return false; } + + /* (non-Javadoc) + * @see net.sourceforge.pmd.dcd.graph.MemberNode#hashCode() + */ + @Override + public int hashCode() { + return super.hashCode(); + } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/FieldNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/FieldNode.java index 0f9e5f2029..9722fbc6da 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/FieldNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/FieldNode.java @@ -22,6 +22,7 @@ public class FieldNode extends MemberNode { getMember(); } + @Override public Field getMember() { Field field = fieldReference == null ? null : fieldReference.get(); if (field == null) { @@ -31,10 +32,12 @@ public class FieldNode extends MemberNode { return field; } + @Override public int compareTo(FieldNode that) { return this.name.compareTo(that.name); } + @Override public boolean equals(Object obj) { if (obj instanceof FieldNode) { FieldNode that = (FieldNode) obj; @@ -42,4 +45,12 @@ public class FieldNode extends MemberNode { } return false; } + + /* (non-Javadoc) + * @see net.sourceforge.pmd.dcd.graph.MemberNode#hashCode() + */ + @Override + public int hashCode() { + return super.hashCode(); + } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/MemberNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/MemberNode.java index 32a784f2d6..2df26997ad 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/MemberNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/MemberNode.java @@ -13,7 +13,7 @@ import java.util.List; * Represents a Class Member in a UsageGraph. */ public abstract class MemberNode, T extends Member> - implements NodeVisitorAcceptor, Comparable { + implements NodeVisitorAcceptor, Comparable { protected final ClassNode classNode; protected final String name; @@ -32,6 +32,7 @@ public abstract class MemberNode, T extends Member> this.desc = desc; } + @Override public Object accept(NodeVisitor visitor, Object data) { visitor.visitUses(this, data); visitor.visitUsers(this, data); @@ -78,6 +79,7 @@ public abstract class MemberNode, T extends Member> return users != null ? users : Collections.emptyList(); } + @Override public String toString() { return name + " " + desc; } @@ -86,8 +88,6 @@ public abstract class MemberNode, T extends Member> return getMember().toString(); } - public abstract boolean equals(Object that); - @SuppressWarnings("PMD.SuspiciousEqualsMethodName") public boolean equals(S that) { return equals(that.name, that.desc); @@ -97,7 +97,47 @@ public abstract class MemberNode, T extends Member> return this.name.equals(name) && this.desc.equals(desc); } + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override public int hashCode() { - return name.hashCode() + desc.hashCode(); + final int prime = 31; + int result = 1; + result = prime * result + ((desc == null) ? 0 : desc.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + MemberNode other = (MemberNode) obj; + if (desc == null) { + if (other.desc != null) { + return false; + } + } else if (!desc.equals(other.desc)) { + return false; + } + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + return true; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/MemberNodeComparator.java b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/MemberNodeComparator.java index feff208922..23455143d8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/MemberNodeComparator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/MemberNodeComparator.java @@ -17,6 +17,7 @@ public final class MemberNodeComparator implements Comparator { private MemberNodeComparator() { } + @Override public int compare(MemberNode node1, MemberNode node2) { if (node1 instanceof FieldNode) { if (node2 instanceof FieldNode) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/MethodNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/MethodNode.java index 15b94faf2a..67a4c656b2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/MethodNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/MethodNode.java @@ -25,6 +25,7 @@ public class MethodNode extends MemberNode { // getMember(); } + @Override public Method getMember() { Method method = methodReference == null ? null : methodReference.get(); if (method == null) { @@ -37,6 +38,7 @@ public class MethodNode extends MemberNode { return method; } + @Override public int compareTo(MethodNode that) { // Order by method name int cmp = this.getName().compareTo(that.getName()); @@ -57,6 +59,7 @@ public class MethodNode extends MemberNode { return cmp; } + @Override public boolean equals(Object obj) { if (obj instanceof MethodNode) { MethodNode that = (MethodNode) obj; @@ -64,4 +67,12 @@ public class MethodNode extends MemberNode { } return false; } + + /* (non-Javadoc) + * @see net.sourceforge.pmd.dcd.graph.MemberNode#hashCode() + */ + @Override + public int hashCode() { + return super.hashCode(); + } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/NodeVisitorAdapter.java b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/NodeVisitorAdapter.java index 93e85a47e9..bbabb24f84 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/NodeVisitorAdapter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/NodeVisitorAdapter.java @@ -13,14 +13,17 @@ import java.util.List; */ public class NodeVisitorAdapter implements NodeVisitor { + @Override public Object visit(UsageGraph usageGraph, Object data) { return usageGraph.accept(this, data); } + @Override public Object visit(ClassNode classNode, Object data) { return classNode.accept(this, data); } + @Override public Object visitFields(ClassNode classNode, Object data) { for (FieldNode fieldNode : classNode.getFieldNodes()) { visit(fieldNode, data); @@ -28,10 +31,12 @@ public class NodeVisitorAdapter implements NodeVisitor { return data; } + @Override public Object visit(FieldNode fieldNode, Object data) { return fieldNode.accept(this, data); } + @Override public Object visitConstructors(ClassNode classNode, Object data) { for (ConstructorNode constructorNode : classNode.getConstructorNodes()) { visit(constructorNode, data); @@ -39,10 +44,12 @@ public class NodeVisitorAdapter implements NodeVisitor { return data; } + @Override public Object visit(ConstructorNode constructorNode, Object data) { return constructorNode.accept(this, data); } + @Override public Object visitMethods(ClassNode classNode, Object data) { for (MethodNode methodNode : classNode.getMethodNodes()) { visit(methodNode, data); @@ -50,10 +57,12 @@ public class NodeVisitorAdapter implements NodeVisitor { return data; } + @Override public Object visit(MethodNode methodNode, Object data) { return methodNode.accept(this, data); } + @Override public Object visitUses(MemberNode memberNode, Object data) { for (MemberNode use : (List) memberNode.getUses()) { this.visitUse(use, data); @@ -61,10 +70,12 @@ public class NodeVisitorAdapter implements NodeVisitor { return data; } + @Override public Object visitUse(MemberNode memberNode, Object data) { return data; } + @Override public Object visitUsers(MemberNode memberNode, Object data) { for (MemberNode user : (List) memberNode.getUsers()) { this.visitUser(user, data); @@ -72,6 +83,7 @@ public class NodeVisitorAdapter implements NodeVisitor { return data; } + @Override public Object visitUser(MemberNode memberNode, Object data) { return data; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/UsageGraph.java b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/UsageGraph.java index 33129e453a..544f62a226 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/UsageGraph.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/UsageGraph.java @@ -54,6 +54,7 @@ public class UsageGraph implements NodeVisitorAcceptor { this.classFilter = classFilter; } + @Override public Object accept(NodeVisitor visitor, Object data) { for (ClassNode classNode : classNodes) { visitor.visit(classNode, data); @@ -124,7 +125,7 @@ public class UsageGraph implements NodeVisitorAcceptor { user.addUse(use); } - private final void checkClassName(String className) { + private void checkClassName(String className) { // Make sure it's not in byte code internal format, or file system path. if (className.indexOf('/') >= 0 || className.indexOf('\\') >= 0) { throw new IllegalArgumentException("Invalid class name: " + className); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/UsageGraphBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/UsageGraphBuilder.java index af56adcfb8..5fbcd31c61 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/UsageGraphBuilder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/dcd/graph/UsageGraphBuilder.java @@ -80,7 +80,7 @@ public class UsageGraphBuilder { private final PrintVisitor p; private String className; - public MyClassVisitor() { + MyClassVisitor() { super(Opcodes.ASM5); p = new PrintVisitor(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractLanguageVersionHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractLanguageVersionHandler.java index bb9e437b93..cd702f081c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractLanguageVersionHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractLanguageVersionHandler.java @@ -10,27 +10,32 @@ import net.sourceforge.pmd.lang.dfa.DFAGraphRule; /** * This is a generic implementation of the LanguageVersionHandler interface. - * + * * @see LanguageVersionHandler */ public abstract class AbstractLanguageVersionHandler implements LanguageVersionHandler { + @Override public DataFlowHandler getDataFlowHandler() { return DataFlowHandler.DUMMY; } + @Override public XPathHandler getXPathHandler() { return XPathHandler.DUMMY; } + @Override public ParserOptions getDefaultParserOptions() { return new ParserOptions(); } + @Override public VisitorStarter getDataFlowFacade() { return VisitorStarter.DUMMY; } + @Override public VisitorStarter getSymbolFacade() { return VisitorStarter.DUMMY; } @@ -40,14 +45,17 @@ public abstract class AbstractLanguageVersionHandler implements LanguageVersionH return VisitorStarter.DUMMY; } + @Override public VisitorStarter getTypeResolutionFacade(ClassLoader classLoader) { return VisitorStarter.DUMMY; } + @Override public VisitorStarter getDumpFacade(final Writer writer, final String prefix, final boolean recurse) { return VisitorStarter.DUMMY; } + @Override public DFAGraphRule getDFAGraphRule() { return null; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractParser.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractParser.java index 85e22df6f7..93fa30f49e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractParser.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/AbstractParser.java @@ -8,7 +8,7 @@ import java.io.Reader; /** * This is a generic implementation of the Parser interface. - * + * * @see Parser */ public abstract class AbstractParser implements Parser { @@ -18,10 +18,12 @@ public abstract class AbstractParser implements Parser { this.parserOptions = parserOptions; } + @Override public ParserOptions getParserOptions() { return parserOptions; } + @Override public TokenManager getTokenManager(String fileName, Reader source) { TokenManager tokenManager = createTokenManager(source); tokenManager.setFileName(fileName); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/BaseLanguageModule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/BaseLanguageModule.java index 0d0c20d926..8b7827c247 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/BaseLanguageModule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/BaseLanguageModule.java @@ -84,6 +84,7 @@ public abstract class BaseLanguageModule implements Language { return versions != null && versions.containsKey(version); } + @Override public LanguageVersion getVersion(String versionName) { if (versions != null) { return versions.get(versionName); @@ -108,10 +109,12 @@ public abstract class BaseLanguageModule implements Language { @Override public boolean equals(Object obj) { - if (obj == null) + if (obj == null) { return false; - if (!(obj instanceof BaseLanguageModule)) + } + if (!(obj instanceof BaseLanguageModule)) { return false; + } BaseLanguageModule other = (BaseLanguageModule) obj; return name.equals(other.name); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/DataFlowHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/DataFlowHandler.java index e2420e729c..4ee375057a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/DataFlowHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/DataFlowHandler.java @@ -12,10 +12,12 @@ import net.sourceforge.pmd.lang.dfa.DataFlowNode; public interface DataFlowHandler { DataFlowHandler DUMMY = new DataFlowHandler() { + @Override public DataFlowNode createDataFlowNode(List dataFlow, Node node) { return null; } + @Override public Class getLabelStatementNodeClass() { return null; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/Language.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/Language.java index 1e5d0ac02e..b638af8998 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/Language.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/Language.java @@ -33,7 +33,7 @@ public interface Language extends Comparable { /** * Get the full name of this Language. This is generally the name of this * Language without the use of acronyms. - * + * * @return The full name of this Language. */ String getName(); @@ -41,21 +41,21 @@ public interface Language extends Comparable { /** * Get the short name of this Language. This is the commonly used short form * of this Language's name, perhaps an acronym. - * + * * @return The short name of this Language. */ String getShortName(); /** * Get the terse name of this Language. This is used for Rule configuration. - * + * * @return The terse name of this Language. */ String getTerseName(); /** * Get the list of file extensions associated with this Language. - * + * * @return List of file extensions. */ List getExtensions(); @@ -63,7 +63,7 @@ public interface Language extends Comparable { /** * Returns whether the given Language handles the given file extension. The * comparison is done ignoring case. - * + * * @param extension * A file extension. * @return true if this Language handles this extension, @@ -74,7 +74,7 @@ public interface Language extends Comparable { /** * Get the RuleChainVisitor implementation class used when visiting the AST * structure for this Rules for this Language. - * + * * @return The RuleChainVisitor class. * @see net.sourceforge.pmd.lang.rule.RuleChainVisitor */ @@ -82,7 +82,7 @@ public interface Language extends Comparable { /** * Gets the list of supported LanguageVersion for this Language. - * + * * @return The LanguageVersion for this Language. */ List getVersions(); @@ -91,7 +91,7 @@ public interface Language extends Comparable { /** * Get the LanguageVersion for the version string from this Language. - * + * * @param version * The language version string. * @return The corresponding LanguageVersion, null if the @@ -103,7 +103,7 @@ public interface Language extends Comparable { * Get the current PMD defined default LanguageVersion for this Language. * This is an arbitrary choice made by the PMD product, and can change * between PMD releases. Every Language has a default version. - * + * * @return The current default LanguageVersion for this Language. */ LanguageVersion getDefaultVersion(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageFilenameFilter.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageFilenameFilter.java index a546ff8696..7a7ca02169 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageFilenameFilter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageFilenameFilter.java @@ -23,7 +23,7 @@ public class LanguageFilenameFilter implements FilenameFilter { /** * Create a LanguageFilenameFilter for a single Language. - * + * * @param language * The Language. */ @@ -33,7 +33,7 @@ public class LanguageFilenameFilter implements FilenameFilter { /** * Create a LanguageFilenameFilter for a List of Languages. - * + * * @param languages * The List of Languages. */ @@ -44,6 +44,7 @@ public class LanguageFilenameFilter implements FilenameFilter { /** * Check if a file should be checked by PMD. {@inheritDoc} */ + @Override public boolean accept(File dir, String name) { // Any source file should have a '.' in its name... int lastDotIndex = name.lastIndexOf('.'); @@ -62,6 +63,7 @@ public class LanguageFilenameFilter implements FilenameFilter { return false; } + @Override public String toString() { StringBuilder buffer = new StringBuilder("(Extension is one of: "); for (Language language : languages) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageRegistry.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageRegistry.java index 34d4673256..8b91e25f0e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageRegistry.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageRegistry.java @@ -112,7 +112,7 @@ public final class LanguageRegistry { /** * A utility method to find the Languages which have Rule support. - * + * * @return A List of Languages with Rule support. */ public static List findWithRuleSupport() { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java index 32667c0fbc..2da37bc700 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java @@ -34,7 +34,7 @@ public class LanguageVersion implements Comparable { /** * Get the name of this LanguageVersion. This is Language name appended with * the LanguageVersion version if not an empty String. - * + * * @return The name of this LanguageVersion. */ public String getName() { @@ -44,7 +44,7 @@ public class LanguageVersion implements Comparable { /** * Get the short name of this LanguageVersion. This is Language short name * appended with the LanguageVersion version if not an empty String. - * + * * @return The short name of this LanguageVersion. */ public String getShortName() { @@ -54,7 +54,7 @@ public class LanguageVersion implements Comparable { /** * Get the terse name of this LanguageVersion. This is Language terse name * appended with the LanguageVersion version if not an empty String. - * + * * @return The terse name of this LanguageVersion. */ public String getTerseName() { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java index 4eef60d879..d0c1ec9b56 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java @@ -19,7 +19,7 @@ public class LanguageVersionDiscoverer { /** * Set the given LanguageVersion as the current default for it's Language. - * + * * @param languageVersion * The new default for the Language. * @return The previous default version for the language. @@ -35,7 +35,7 @@ public class LanguageVersionDiscoverer { /** * Get the current default LanguageVersion for the given Language. - * + * * @param language * The Language. * @return The current default version for the language. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionHandler.java index 33a2632ec9..4642ea7898 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionHandler.java @@ -34,7 +34,7 @@ public interface LanguageVersionHandler { /** * Get the default ParserOptions. - * + * * @return ParserOptions */ ParserOptions getDefaultParserOptions(); @@ -62,7 +62,7 @@ public interface LanguageVersionHandler { /** * Get the SymbolFacade. - * + * * @param classLoader * A ClassLoader to use for resolving Types. * @return VisitorStarter diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/Parser.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/Parser.java index 9238a77935..8cbd404a8a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/Parser.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/Parser.java @@ -23,7 +23,7 @@ public interface Parser { /** * Get a TokenManager for the given source. - * + * * @param fileName * The file name being parsed (may be null). * @param source diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/VisitorStarter.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/VisitorStarter.java index 023bea2ad2..56c1151ab2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/VisitorStarter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/VisitorStarter.java @@ -8,7 +8,7 @@ import net.sourceforge.pmd.lang.ast.Node; /** * Interface for starting an implementation of the visitors for ASTs. - * + * * @author pieter_van_raemdonck - Application Engineers NV/SA - www.ae.be */ public interface VisitorStarter { @@ -19,6 +19,7 @@ public interface VisitorStarter { * nothing. */ VisitorStarter DUMMY = new VisitorStarter() { + @Override public void start(Node rootNode) { // does nothing - dummy implementation. } @@ -26,7 +27,7 @@ public interface VisitorStarter { /** * Start the visitor, given the root-node of the AST. - * + * * @param rootNode * The root node of the AST */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/XPathHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/XPathHandler.java index 1603e17a19..323182f616 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/XPathHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/XPathHandler.java @@ -6,9 +6,10 @@ package net.sourceforge.pmd.lang; import org.jaxen.Navigator; -import net.sf.saxon.sxpath.IndependentContext; import net.sourceforge.pmd.lang.xpath.Initializer; +import net.sf.saxon.sxpath.IndependentContext; + /** * Interface for performing Language specific XPath handling, such as * initialization and navigation. @@ -16,12 +17,15 @@ import net.sourceforge.pmd.lang.xpath.Initializer; public interface XPathHandler { XPathHandler DUMMY = new XPathHandler() { + @Override public void initialize() { } + @Override public void initialize(IndependentContext context) { } + @Override public Navigator getNavigator() { return null; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AbstractNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AbstractNode.java index 86f4027f73..fec86b965a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AbstractNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AbstractNode.java @@ -395,7 +395,7 @@ public abstract class AbstractNode implements Node { } /** - * + * * @param types * @return boolean */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Node.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Node.java index 7a31753665..9c123b71bc 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Node.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Node.java @@ -45,7 +45,7 @@ public interface Node { /** * Sets the index of this node from the perspective of its parent. This * means: this.jjtGetParent().jjtGetChild(index) == this. - * + * * @param index * the child index */ @@ -197,7 +197,7 @@ public interface Node { /** * Get the user data associated with this node. By default there is no data, * unless it has been set via {@link #setUserData(Object)}. - * + * * @return The user data set on this node. */ Object getUserData(); @@ -212,7 +212,7 @@ public interface Node { * This API is most useful for external applications looking to leverage * PMD's robust support for AST structures, in which case application * specific annotations on the AST nodes can be quite useful. - * + * * @param userData * The data to set on this node. */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SourceCodePositioner.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SourceCodePositioner.java index cb1852f635..152185bd2f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SourceCodePositioner.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SourceCodePositioner.java @@ -10,7 +10,7 @@ import java.util.Arrays; * Calculates from an absolute offset in the source file the line/column * coordinate. This is needed as Rhino only offers absolute positions for each * node. Some other languages like XML and Apex use this, too. - * + * * Idea from: * http://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/javascript/jscomp/SourceFile.java */ @@ -49,7 +49,7 @@ public class SourceCodePositioner { insertionPoint += 1; insertionPoint *= -1; lineNumber = insertionPoint - 1; // take the insertion point one - // before + // before } return lineNumber + 1; // 1-based line numbers } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AbstractASTXPathHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AbstractASTXPathHandler.java index 720b9345ab..c645338204 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AbstractASTXPathHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AbstractASTXPathHandler.java @@ -6,12 +6,14 @@ package net.sourceforge.pmd.lang.ast.xpath; import org.jaxen.Navigator; -import net.sf.saxon.sxpath.IndependentContext; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.XPathHandler; +import net.sf.saxon.sxpath.IndependentContext; + public abstract class AbstractASTXPathHandler implements XPathHandler { + @Override public Navigator getNavigator() { return new DocumentNavigator(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/Attribute.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/Attribute.java index b7142abd2b..07a0eaa3cc 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/Attribute.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/Attribute.java @@ -73,6 +73,7 @@ public class Attribute { return parent; } + @Override public String toString() { return name + ":" + getValue() + ":" + parent; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIterator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIterator.java index 8cc4da92ab..71f8e3998d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIterator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIterator.java @@ -20,7 +20,7 @@ public class AttributeAxisIterator implements Iterator { public Method method; public String name; - public MethodWrapper(Method m) { + MethodWrapper(Method m) { this.method = m; this.name = truncateMethodName(m.getName()); } @@ -71,6 +71,7 @@ public class AttributeAxisIterator implements Iterator { this.currObj = getNextAttribute(); } + @Override public Attribute next() { if (currObj == null) { throw new IndexOutOfBoundsException(); @@ -80,10 +81,12 @@ public class AttributeAxisIterator implements Iterator { return ret; } + @Override public boolean hasNext() { return currObj != null; } + @Override public void remove() { throw new UnsupportedOperationException(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/NodeIterator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/NodeIterator.java index c85c3523f1..7f1cb1867a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/NodeIterator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/NodeIterator.java @@ -20,10 +20,12 @@ public abstract class NodeIterator implements Iterator { this.node = getFirstNode(contextNode); } + @Override public boolean hasNext() { return node != null; } + @Override public Node next() { if (node == null) { throw new NoSuchElementException(); @@ -33,6 +35,7 @@ public abstract class NodeIterator implements Iterator { return ret; } + @Override public void remove() { throw new UnsupportedOperationException(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AbstractNodeInfo.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AbstractNodeInfo.java index b13bd65b14..a04c381191 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AbstractNodeInfo.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AbstractNodeInfo.java @@ -126,6 +126,15 @@ public class AbstractNodeInfo implements VirtualNode, SiblingCountingNode { return false; } + @Override + public int hashCode() { + if (this.getUnderlyingNode() != null) { + return super.hashCode() + 31 * this.getUnderlyingNode().hashCode(); + } else { + return super.hashCode(); + } + } + /** * {@inheritDoc} */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeAxisIterator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeAxisIterator.java index 34e7735710..5062efbee4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeAxisIterator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeAxisIterator.java @@ -4,9 +4,10 @@ package net.sourceforge.pmd.lang.ast.xpath.saxon; +import net.sourceforge.pmd.lang.ast.xpath.Attribute; + import net.sf.saxon.om.Navigator; import net.sf.saxon.om.SequenceIterator; -import net.sourceforge.pmd.lang.ast.xpath.Attribute; /** * This is an Attribute axis iterator. @@ -18,7 +19,7 @@ public class AttributeAxisIterator extends Navigator.BaseEnumeration { /** * Create an iterator over the Attribute axis for the given ElementNode. - * + * * @see net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator */ public AttributeAxisIterator(ElementNode startNodeInfo) { @@ -29,6 +30,7 @@ public class AttributeAxisIterator extends Navigator.BaseEnumeration { /** * {@inheritDoc} */ + @Override public SequenceIterator getAnother() { return new AttributeAxisIterator(startNodeInfo); } @@ -36,6 +38,7 @@ public class AttributeAxisIterator extends Navigator.BaseEnumeration { /** * {@inheritDoc} */ + @Override public void advance() { if (this.iterator.hasNext()) { Attribute attribute = this.iterator.next(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeNode.java index 923ce1096b..624250ef3f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeNode.java @@ -4,6 +4,8 @@ package net.sourceforge.pmd.lang.ast.xpath.saxon; +import net.sourceforge.pmd.lang.ast.xpath.Attribute; + import net.sf.saxon.om.NodeInfo; import net.sf.saxon.om.SequenceIterator; import net.sf.saxon.trans.XPathException; @@ -13,7 +15,6 @@ import net.sf.saxon.value.EmptySequence; import net.sf.saxon.value.Int64Value; import net.sf.saxon.value.StringValue; import net.sf.saxon.value.Value; -import net.sourceforge.pmd.lang.ast.xpath.Attribute; /** * A Saxon OM Attribute node for an AST Node Attribute. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/DocumentNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/DocumentNode.java index 08d5be1c69..e1de476a16 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/DocumentNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/DocumentNode.java @@ -8,6 +8,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import net.sourceforge.pmd.lang.ast.Node; + import net.sf.saxon.om.Axis; import net.sf.saxon.om.AxisIterator; import net.sf.saxon.om.DocumentInfo; @@ -15,7 +17,6 @@ import net.sf.saxon.om.Navigator; import net.sf.saxon.om.NodeInfo; import net.sf.saxon.om.SingleNodeIterator; import net.sf.saxon.type.Type; -import net.sourceforge.pmd.lang.ast.Node; /** * A Saxon OM Document node for an AST Node. @@ -35,10 +36,10 @@ public class DocumentNode extends AbstractNodeInfo implements DocumentInfo { /** * Construct a DocumentNode, with the given AST Node serving as the root * ElementNode. - * + * * @param node * The root AST Node. - * + * * @see ElementNode */ public DocumentNode(Node node) { @@ -48,6 +49,7 @@ public class DocumentNode extends AbstractNodeInfo implements DocumentInfo { /** * {@inheritDoc} */ + @Override public String[] getUnparsedEntity(String name) { throw createUnsupportedOperationException("DocumentInfo.getUnparsedEntity(String)"); } @@ -55,6 +57,7 @@ public class DocumentNode extends AbstractNodeInfo implements DocumentInfo { /** * {@inheritDoc} */ + @Override public Iterator getUnparsedEntityNames() { throw createUnsupportedOperationException("DocumentInfo.getUnparsedEntityNames()"); } @@ -62,6 +65,7 @@ public class DocumentNode extends AbstractNodeInfo implements DocumentInfo { /** * {@inheritDoc} */ + @Override public NodeInfo selectID(String id) { throw createUnsupportedOperationException("DocumentInfo.selectID(String)"); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/ElementNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/ElementNode.java index 1813defa98..aa3d815a57 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/ElementNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/ElementNode.java @@ -4,6 +4,8 @@ package net.sourceforge.pmd.lang.ast.xpath.saxon; +import net.sourceforge.pmd.lang.ast.Node; + import net.sf.saxon.om.Axis; import net.sf.saxon.om.AxisIterator; import net.sf.saxon.om.DocumentInfo; @@ -13,7 +15,6 @@ import net.sf.saxon.om.NodeArrayIterator; import net.sf.saxon.om.NodeInfo; import net.sf.saxon.om.SingleNodeIterator; import net.sf.saxon.type.Type; -import net.sourceforge.pmd.lang.ast.Node; /** * A Saxon OM Element type node for an AST Node. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/AbstractDataFlowNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/AbstractDataFlowNode.java index 9406a312dd..f19a940a2e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/AbstractDataFlowNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/AbstractDataFlowNode.java @@ -44,6 +44,7 @@ public abstract class AbstractDataFlowNode implements DataFlowNode { this.line = node.getBeginLine(); } + @Override public void addPathToChild(DataFlowNode child) { DataFlowNode thisChild = child; // TODO - throw an exception if already contained in children list? @@ -53,12 +54,14 @@ public abstract class AbstractDataFlowNode implements DataFlowNode { } } + @Override public boolean removePathToChild(DataFlowNode child) { DataFlowNode thisChild = child; thisChild.getParents().remove(this); return this.children.remove(thisChild); } + @Override public void reverseParentPathsTo(DataFlowNode destination) { while (!parents.isEmpty()) { DataFlowNode parent = parents.get(0); @@ -67,14 +70,17 @@ public abstract class AbstractDataFlowNode implements DataFlowNode { } } + @Override public int getLine() { return this.line; } + @Override public void setType(int type) { this.type.set(type); } + @Override public boolean isType(int intype) { try { return type.get(intype); @@ -84,26 +90,32 @@ public abstract class AbstractDataFlowNode implements DataFlowNode { return false; } + @Override public Node getNode() { return this.node; } + @Override public List getChildren() { return this.children; } + @Override public List getParents() { return this.parents; } + @Override public List getFlow() { return this.dataFlow; } + @Override public int getIndex() { return this.dataFlow.indexOf(this); } + @Override public void setVariableAccess(List variableAccess) { if (this.variableAccess.isEmpty()) { this.variableAccess = variableAccess; @@ -112,6 +124,7 @@ public abstract class AbstractDataFlowNode implements DataFlowNode { } } + @Override public List getVariableAccess() { return this.variableAccess; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Linker.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Linker.java index 3feecf96e3..db043ce071 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Linker.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Linker.java @@ -159,18 +159,18 @@ public class Linker { /* * for(int i = cList.indexOf(node)-1;i>=0;i--) { IDataFlowNode n * = (IDataFlowNode)cList.get(i); - * + * * if(n.isType(NodeType.FOR_UPDATE) || * n.isType(NodeType.FOR_EXPR) || n.isType(NodeType.WHILE_EXPR)) * { */ /* * while(..) { while(...) { ... } continue; } - * + * * Without this Expression he continues the second WHILE loop. * The continue statement and the while loop have to be in * different scopes. - * + * * TODO An error occurs if "continue" is even nested in scopes * other than local loop scopes, like "if". The result is, that * the data flow isn't build right and the pathfinder runs in @@ -180,31 +180,30 @@ public class Linker { * if(n.getNode().getScope().equals(node.getNode().getScope())) * { System.err.println("equals"); continue; } else { * System.err.println("don't equals"); } - * + * * //remove all children (should contain only one child) * node.removePathToChild * ((IDataFlowNode)node.getChildren().get(0)); - * + * * node.addPathToChild(n); cbrStack.remove(0); break; - * + * * }else if(n.isType(NodeType.DO_BEFOR_FIRST_STATEMENT)) { - * + * * IDataFlowNode inode = * (IDataFlowNode)n.getFlow().get(n.getIndex()1); - * + * * for(int j=0;j stackList) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/LinkerException.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/LinkerException.java index 8dc63c2783..a1300d7f03 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/LinkerException.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/LinkerException.java @@ -11,10 +11,8 @@ public class LinkerException extends Exception { private static final long serialVersionUID = 3238380880636634352L; public LinkerException() { - super("An error occured by computing the data flow paths"); // TODO - // redefinition - // | - // accurate? + // TODO redefinition | accurate? + super("An error occured by computing the data flow paths"); } public LinkerException(String message) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/NodeType.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/NodeType.java index dc5a842d4a..3469ab02fb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/NodeType.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/NodeType.java @@ -47,6 +47,7 @@ public class NodeType { // Poor Man's Enum until we convert the class to real enum private static final Map TYPE_MAP = new HashMap<>(); + static { TYPE_MAP.put(NodeType.IF_EXPR, "IF_EXPR"); TYPE_MAP.put(NodeType.IF_LAST_STATEMENT, "IF_LAST_STATEMENT"); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/SequenceChecker.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/SequenceChecker.java index 95e4b1f0d8..3abc4f8947 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/SequenceChecker.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/SequenceChecker.java @@ -34,11 +34,11 @@ public class SequenceChecker { private int type; private boolean lastStep; - public Status(int type) { + Status(int type) { this(type, false); } - public Status(int type, boolean lastStep) { + Status(int type, boolean lastStep) { this.type = type; this.lastStep = lastStep; } @@ -48,7 +48,7 @@ public class SequenceChecker { } /** - * + * * @param type * candidate * @return valid Status or null if NodeType is not a valid transition @@ -180,7 +180,7 @@ public class SequenceChecker { /* * Walk through the bracesList attempting to identify the first * contiguous graph of Nodes from the initial Status to a final Status. - * + * * There are 2 loop indexes:- i which ranges through the bracesList: * this may be reset l serves as a control to cope with invalid lists of * StackObjects, preventing infinite loops within the SequenceChecker. @@ -211,9 +211,8 @@ public class SequenceChecker { LOGGER.finer("aktStatus is NULL (lookAhead): Invalid transition"); LOGGER.exiting(this.getClass().getCanonicalName(), "run", false); return false; - } - // Cope with incorrect bracesList contents - else if (l > maximumIterations) { + } else if (l > maximumIterations) { + // Cope with incorrect bracesList contents if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.severe("aktStatus is NULL: maximum Iterations exceeded, abort " + i); } @@ -229,10 +228,10 @@ public class SequenceChecker { } continue; } - } else { // This NodeType _is_ a valid transition from the previous - // State - if (aktStatus.isLastStep() && !aktStatus.hasMoreSteps()) { // Terminal - // State + } else { + // This NodeType _is_ a valid transition from the previous State + if (aktStatus.isLastStep() && !aktStatus.hasMoreSteps()) { + // Terminal State this.lastIndex = i; if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest("aktStatus is NOT NULL: lastStep reached and no moreSteps - firstIndex=" diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StackObject.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StackObject.java index 6bb65b60cb..92a1377391 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StackObject.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StackObject.java @@ -23,6 +23,7 @@ public class StackObject { return this.type; } + @Override public String toString() { return ("StackObject: type=" + NodeType.stringFromType(type) + "(" + type + "), node=" + node.toString()); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StartOrEndDataFlowNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StartOrEndDataFlowNode.java index cf50e8ce5e..0eb7f33f98 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StartOrEndDataFlowNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/StartOrEndDataFlowNode.java @@ -16,6 +16,7 @@ public class StartOrEndDataFlowNode extends AbstractDataFlowNode { this.isStartNode = isStartNode; } + @Override public String toString() { return isStartNode ? "Start node" : "End node"; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Structure.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Structure.java index d0d60ab1e5..2adfeac5c1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Structure.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/Structure.java @@ -95,7 +95,7 @@ public class Structure { } /** - * + * * @return formatted dump of the DFA Structure's */ public String dump() { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/VariableAccess.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/VariableAccess.java index 6b100b349d..dca5da4676 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/VariableAccess.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/VariableAccess.java @@ -48,6 +48,7 @@ public class VariableAccess { return variableName; } + @Override public String toString() { if (isDefinition()) { return "Definition(" + variableName + ")"; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/DAAPathFinder.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/DAAPathFinder.java index 47117a3018..e8dc4773a0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/DAAPathFinder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/DAAPathFinder.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.lang.dfa.NodeType; /** * Finds all paths of a data flow. Each loop will be 0 or 2 times traversed -> 2 * paths. This is special to the data flow anomaly analysis. - * + * * @since Created on 09.08.2004 * @author raik */ @@ -144,9 +144,8 @@ public class DAAPathFinder { } } else { DataFlowNode inode = currentPath.getLast(); - DataFlowNode child = inode.getChildren().get(0); // TODO ???? - // IMPORTANT - - // ERROR? + // TODO ???? IMPORTANT - ERROR? + DataFlowNode child = inode.getChildren().get(0); this.currentPath.addLast(child); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/Executable.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/Executable.java index 4a9f0bafb5..fefde71b15 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/Executable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/pathfinder/Executable.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.dfa.pathfinder; /** * Created on 09.08.2004 - * + * * @author raik *

    * Will be executed if PathFinder finds a path. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ClassNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ClassNode.java index 4bff911d37..747be9e52a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ClassNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ClassNode.java @@ -16,6 +16,7 @@ public class ClassNode extends AbstractReportNode { return className; } + @Override public boolean equalsNode(AbstractReportNode arg0) { if (!(arg0 instanceof ClassNode)) { return false; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/PackageNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/PackageNode.java index a6429550c9..24d2e9ac5a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/PackageNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/PackageNode.java @@ -16,6 +16,7 @@ public class PackageNode extends AbstractReportNode { return this.packageName; } + @Override public boolean equalsNode(AbstractReportNode arg0) { if (!(arg0 instanceof PackageNode)) { return false; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ReportHTMLPrintVisitor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ReportHTMLPrintVisitor.java index 7983fca6a7..dbee8e1e93 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ReportHTMLPrintVisitor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ReportHTMLPrintVisitor.java @@ -84,6 +84,7 @@ public class ReportHTMLPrintVisitor extends ReportVisitor { * contains the name of the class, Package - represents a package and * contains the name(s) of the package. */ + @Override public void visit(AbstractReportNode node) { /* diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ReportTree.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ReportTree.java index f2dc2ce480..18d58771d1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ReportTree.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ReportTree.java @@ -18,15 +18,18 @@ public class ReportTree implements Iterable { private AbstractReportNode iterNode = rootNode; private boolean hasNextFlag; + @Override public void remove() { throw new UnsupportedOperationException(); } + @Override public boolean hasNext() { hasNextFlag = true; return getNext() != null; } + @Override public RuleViolation next() { if (!hasNextFlag) { getNext(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ViolationNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ViolationNode.java index 1958b746bf..184d7d701c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ViolationNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/dfa/report/ViolationNode.java @@ -18,6 +18,7 @@ public class ViolationNode extends AbstractReportNode { return ruleViolation; } + @Override public boolean equalsNode(AbstractReportNode arg0) { if (!(arg0 instanceof ViolationNode)) { return false; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java index 351ab41dfc..a173fe43c5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractDelegateRule.java @@ -33,30 +33,37 @@ public abstract class AbstractDelegateRule implements Rule { return rule; } + @Override public Language getLanguage() { return rule.getLanguage(); } + @Override public void setLanguage(Language language) { rule.setLanguage(language); } + @Override public LanguageVersion getMinimumLanguageVersion() { return rule.getMinimumLanguageVersion(); } + @Override public void setMinimumLanguageVersion(LanguageVersion minimumlanguageVersion) { rule.setMinimumLanguageVersion(minimumlanguageVersion); } + @Override public void setMaximumLanguageVersion(LanguageVersion maximumlanguageVersion) { rule.setMaximumLanguageVersion(maximumlanguageVersion); } + @Override public LanguageVersion getMaximumLanguageVersion() { return rule.getMaximumLanguageVersion(); } + @Override public boolean isDeprecated() { return rule.isDeprecated(); } @@ -64,158 +71,197 @@ public abstract class AbstractDelegateRule implements Rule { /** * @see PropertySource#dysfunctionReason() */ + @Override public String dysfunctionReason() { return rule.dysfunctionReason(); } + @Override public Set> ignoredProperties() { return rule.ignoredProperties(); } + @Override public void setDeprecated(boolean deprecated) { rule.setDeprecated(deprecated); } + @Override public String getName() { return rule.getName(); } + @Override public void setName(String name) { rule.setName(name); } + @Override public String getSince() { return rule.getSince(); } + @Override public void setSince(String since) { rule.setSince(since); } + @Override public String getRuleClass() { return rule.getRuleClass(); } + @Override public void setRuleClass(String ruleClass) { rule.setRuleClass(ruleClass); } + @Override public String getRuleSetName() { return rule.getRuleSetName(); } + @Override public void setRuleSetName(String name) { rule.setRuleSetName(name); } + @Override public String getMessage() { return rule.getMessage(); } + @Override public void setMessage(String message) { rule.setMessage(message); } + @Override public String getDescription() { return rule.getDescription(); } + @Override public void setDescription(String description) { rule.setDescription(description); } + @Override public List getExamples() { return rule.getExamples(); } + @Override public void addExample(String example) { rule.addExample(example); } + @Override public String getExternalInfoUrl() { return rule.getExternalInfoUrl(); } + @Override public void setExternalInfoUrl(String url) { rule.setExternalInfoUrl(url); } + @Override public RulePriority getPriority() { return rule.getPriority(); } + @Override public void setPriority(RulePriority priority) { rule.setPriority(priority); } + @Override public ParserOptions getParserOptions() { return rule.getParserOptions(); } + @Override public void definePropertyDescriptor(PropertyDescriptor propertyDescriptor) throws IllegalArgumentException { rule.definePropertyDescriptor(propertyDescriptor); } + @Override public PropertyDescriptor getPropertyDescriptor(String name) { return rule.getPropertyDescriptor(name); } + @Override public List> getPropertyDescriptors() { return rule.getPropertyDescriptors(); } + @Override public T getProperty(PropertyDescriptor propertyDescriptor) { return rule.getProperty(propertyDescriptor); } + @Override public void setProperty(PropertyDescriptor propertyDescriptor, T value) { rule.setProperty(propertyDescriptor, value); } + @Override public Map, Object> getPropertiesByPropertyDescriptor() { return rule.getPropertiesByPropertyDescriptor(); } + @Override public void setUsesDFA() { rule.setUsesDFA(); } + @Override public boolean usesDFA() { return rule.usesDFA(); } + @Override public void setUsesTypeResolution() { rule.setUsesTypeResolution(); } + @Override public boolean usesTypeResolution() { return rule.usesTypeResolution(); } + @Override public boolean usesRuleChain() { return rule.usesRuleChain(); } + @Override public List getRuleChainVisits() { return rule.getRuleChainVisits(); } + @Override public void addRuleChainVisit(Class nodeClass) { rule.addRuleChainVisit(nodeClass); } + @Override public void addRuleChainVisit(String astNodeName) { rule.addRuleChainVisit(astNodeName); } + @Override public void start(RuleContext ctx) { rule.start(ctx); } + @Override public void apply(List nodes, RuleContext ctx) { rule.apply(nodes, ctx); } + @Override public void end(RuleContext ctx) { rule.end(ctx); } @@ -223,6 +269,7 @@ public abstract class AbstractDelegateRule implements Rule { /** * @see Rule#hasDescriptor(PropertyDescriptor) */ + @Override public boolean hasDescriptor(PropertyDescriptor descriptor) { return rule.hasDescriptor(descriptor); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java index 3cb8e42342..9f08f48f85 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java @@ -79,6 +79,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#getLanguage() */ + @Override public Language getLanguage() { return language; } @@ -86,6 +87,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#setLanguage(net.sourceforge.pmd.lang.Language) */ + @Override public void setLanguage(Language language) { if (this.language != null && this instanceof ImmutableLanguage && !this.language.equals(language)) { throw new UnsupportedOperationException("The Language for Rule class " + this.getClass().getName() @@ -97,6 +99,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#getMinimumLanguageVersion() */ + @Override public LanguageVersion getMinimumLanguageVersion() { return minimumLanguageVersion; } @@ -104,6 +107,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#setMinimumLanguageVersion(net.sourceforge.pmd.lang.LanguageVersion) */ + @Override public void setMinimumLanguageVersion(LanguageVersion minimumLanguageVersion) { this.minimumLanguageVersion = minimumLanguageVersion; } @@ -111,6 +115,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#getMaximumLanguageVersion() */ + @Override public LanguageVersion getMaximumLanguageVersion() { return maximumLanguageVersion; } @@ -118,6 +123,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#setMaximumLanguageVersion(net.sourceforge.pmd.lang.LanguageVersion) */ + @Override public void setMaximumLanguageVersion(LanguageVersion maximumLanguageVersion) { this.maximumLanguageVersion = maximumLanguageVersion; } @@ -125,6 +131,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#isDeprecated() */ + @Override public boolean isDeprecated() { return deprecated; } @@ -132,6 +139,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#setDeprecated(boolean) */ + @Override public void setDeprecated(boolean deprecated) { this.deprecated = deprecated; } @@ -139,6 +147,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#getName() */ + @Override public String getName() { return name; } @@ -146,6 +155,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#setName(String) */ + @Override public void setName(String name) { this.name = name; } @@ -153,6 +163,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#getSince() */ + @Override public String getSince() { return since; } @@ -160,6 +171,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#setSince(String) */ + @Override public void setSince(String since) { this.since = since; } @@ -167,6 +179,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#getRuleClass() */ + @Override public String getRuleClass() { return ruleClass; } @@ -174,6 +187,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#setRuleClass(String) */ + @Override public void setRuleClass(String ruleClass) { this.ruleClass = ruleClass; } @@ -181,6 +195,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#getRuleSetName() */ + @Override public String getRuleSetName() { return ruleSetName; } @@ -188,6 +203,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#setRuleSetName(String) */ + @Override public void setRuleSetName(String ruleSetName) { this.ruleSetName = ruleSetName; } @@ -195,6 +211,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#getMessage() */ + @Override public String getMessage() { return message; } @@ -202,6 +219,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#setMessage(String) */ + @Override public void setMessage(String message) { this.message = message; } @@ -209,6 +227,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#getDescription() */ + @Override public String getDescription() { return description; } @@ -216,6 +235,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#setDescription(String) */ + @Override public void setDescription(String description) { this.description = description; } @@ -223,6 +243,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#getExamples() */ + @Override public List getExamples() { // TODO Needs to be externally immutable return examples; @@ -231,6 +252,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#addExample(String) */ + @Override public void addExample(String example) { examples.add(example); } @@ -238,6 +260,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#getExternalInfoUrl() */ + @Override public String getExternalInfoUrl() { return externalInfoUrl; } @@ -245,6 +268,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#setExternalInfoUrl(String) */ + @Override public void setExternalInfoUrl(String externalInfoUrl) { this.externalInfoUrl = externalInfoUrl; } @@ -252,6 +276,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#getPriority() */ + @Override public RulePriority getPriority() { return priority; } @@ -259,6 +284,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#setPriority(RulePriority) */ + @Override public void setPriority(RulePriority priority) { this.priority = priority; } @@ -266,9 +292,10 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * This implementation returns a new instance of {@link ParserOptions} using * default settings. - * + * * @see Rule#setPriority(RulePriority) */ + @Override public ParserOptions getParserOptions() { return new ParserOptions(); } @@ -276,6 +303,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#setUsesDFA() */ + @Override public void setUsesDFA() { usesDFA = true; } @@ -283,6 +311,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#usesDFA() */ + @Override public boolean usesDFA() { return usesDFA; } @@ -290,6 +319,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#setUsesTypeResolution() */ + @Override public void setUsesTypeResolution() { usesTypeResolution = true; } @@ -297,6 +327,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#usesTypeResolution() */ + @Override public boolean usesTypeResolution() { return usesTypeResolution; } @@ -304,6 +335,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#usesRuleChain() */ + @Override public boolean usesRuleChain() { return !getRuleChainVisits().isEmpty(); } @@ -311,6 +343,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#getRuleChainVisits() */ + @Override public List getRuleChainVisits() { return ruleChainVisits; } @@ -318,6 +351,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#addRuleChainVisit(Class) */ + @Override public void addRuleChainVisit(Class nodeClass) { if (!nodeClass.getSimpleName().startsWith("AST")) { throw new IllegalArgumentException("Node class does not start with 'AST' prefix: " + nodeClass); @@ -328,6 +362,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#addRuleChainVisit(String) */ + @Override public void addRuleChainVisit(String astNodeName) { if (!ruleChainVisits.contains(astNodeName)) { ruleChainVisits.add(astNodeName); @@ -337,6 +372,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#start(RuleContext) */ + @Override public void start(RuleContext ctx) { // Override as needed } @@ -344,6 +380,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul /** * @see Rule#end(RuleContext) */ + @Override public void end(RuleContext ctx) { // Override as needed } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRuleChainVisitor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRuleChainVisitor.java index 65afadef04..f9122dacb4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRuleChainVisitor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRuleChainVisitor.java @@ -40,6 +40,7 @@ public abstract class AbstractRuleChainVisitor implements RuleChainVisitor { /** * @see RuleChainVisitor#add(RuleSet, Rule) */ + @Override public void add(RuleSet ruleSet, Rule rule) { if (!ruleSetRules.containsKey(ruleSet)) { @@ -51,6 +52,7 @@ public abstract class AbstractRuleChainVisitor implements RuleChainVisitor { /** * @see RuleChainVisitor#visitAll(List, RuleContext) */ + @Override public void visitAll(List nodes, RuleContext ctx) { initialize(); clear(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRuleViolationFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRuleViolationFactory.java index f2c5eef885..048304bb8b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRuleViolationFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRuleViolationFactory.java @@ -28,6 +28,7 @@ public abstract class AbstractRuleViolationFactory implements RuleViolationFacto } } + @Override public void addViolation(RuleContext ruleContext, Rule rule, Node node, String message, Object[] args) { String formattedMessage = cleanup(message, args); @@ -35,6 +36,7 @@ public abstract class AbstractRuleViolationFactory implements RuleViolationFacto ruleContext.getReport().addRuleViolation(createRuleViolation(rule, ruleContext, node, formattedMessage)); } + @Override public void addViolation(RuleContext ruleContext, Rule rule, Node node, String message, int beginLine, int endLine, Object[] args) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ImportWrapper.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ImportWrapper.java index e3122ccc29..adee83c793 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ImportWrapper.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ImportWrapper.java @@ -45,6 +45,7 @@ public class ImportWrapper { this.isStaticDemand = isStaticDemand; } + @Override public boolean equals(Object other) { if (other == null) { return false; @@ -74,6 +75,7 @@ public class ImportWrapper { return i.getName().equals(name); } + @Override public int hashCode() { if (name == null) { return fullname.hashCode(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/MockRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/MockRule.java index f64cfce39d..93c8239be9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/MockRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/MockRule.java @@ -39,6 +39,7 @@ public class MockRule extends AbstractRule { setRuleSetName(ruleSetName); } + @Override public void apply(List nodes, RuleContext ctx) { } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java index 1634603f93..7c34e20f60 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java @@ -113,50 +113,62 @@ public class ParametricRuleViolation implements RuleViolation { } } + @Override public Rule getRule() { return rule; } + @Override public String getDescription() { return expandVariables(description); } + @Override public boolean isSuppressed() { return suppressed; } + @Override public String getFilename() { return filename; } + @Override public int getBeginLine() { return beginLine; } + @Override public int getBeginColumn() { return beginColumn; } + @Override public int getEndLine() { return endLine; } + @Override public int getEndColumn() { return endColumn; } + @Override public String getPackageName() { return packageName; } + @Override public String getClassName() { return className; } + @Override public String getMethodName() { return methodName; } + @Override public String getVariableName() { return variableName; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleChainVisitor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleChainVisitor.java index 0fb583a0bd..f2425dbbcc 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleChainVisitor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleChainVisitor.java @@ -18,7 +18,7 @@ import net.sourceforge.pmd.lang.ast.Node; public interface RuleChainVisitor { /** * Add the given rule to the visitor. - * + * * @param ruleSet * The RuleSet to which the rule belongs. * @param rule @@ -29,7 +29,7 @@ public interface RuleChainVisitor { /** * Visit all the given Nodes provided using the given RuleContext. Every * Rule added will visit the AST as appropriate. - * + * * @param nodes * The Nodes to visit. * @param ctx diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleViolationFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleViolationFactory.java index 9ad7cf56dc..fb95d15ee0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleViolationFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleViolationFactory.java @@ -15,7 +15,7 @@ import net.sourceforge.pmd.lang.ast.Node; public interface RuleViolationFactory { /** * Adds a violation to the report. - * + * * @param ruleContext * the RuleContext * @param rule diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java index 1e7265f587..1f93807c80 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/XPathRule.java @@ -4,6 +4,10 @@ package net.sourceforge.pmd.lang.rule; +import static net.sourceforge.pmd.lang.rule.xpath.XPathRuleQuery.XPATH_1_0; +import static net.sourceforge.pmd.lang.rule.xpath.XPathRuleQuery.XPATH_1_0_COMPATIBILITY; +import static net.sourceforge.pmd.lang.rule.xpath.XPathRuleQuery.XPATH_2_0; + import java.util.List; import net.sourceforge.pmd.PropertySource; @@ -16,10 +20,6 @@ import net.sourceforge.pmd.lang.rule.xpath.SaxonXPathRuleQuery; import net.sourceforge.pmd.lang.rule.xpath.XPathRuleQuery; import net.sourceforge.pmd.util.StringUtil; -import static net.sourceforge.pmd.lang.rule.xpath.XPathRuleQuery.XPATH_1_0; -import static net.sourceforge.pmd.lang.rule.xpath.XPathRuleQuery.XPATH_1_0_COMPATIBILITY; -import static net.sourceforge.pmd.lang.rule.xpath.XPathRuleQuery.XPATH_2_0; - /** * Rule that tries to match an XPath expression against a DOM view of an AST. *

    @@ -55,6 +55,7 @@ public class XPathRule extends AbstractRule { /** * Apply the rule to all nodes. */ + @Override public void apply(List nodes, RuleContext ctx) { for (Node node : nodes) { evaluate(node, ctx); @@ -116,6 +117,7 @@ public class XPathRule extends AbstractRule { /** * @see PropertySource#dysfunctionReason() */ + @Override public String dysfunctionReason() { return hasXPathExpression() ? null : "Missing xPath expression"; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractEnumeratedProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractEnumeratedProperty.java index 6dddbc8c9c..2754396cf1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractEnumeratedProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractEnumeratedProperty.java @@ -42,7 +42,7 @@ public abstract class AbstractEnumeratedProperty extends AbstractProperty< /** * Method selectionsIn. - * + * * @param items * String[] * @param selectionIndices @@ -66,6 +66,7 @@ public abstract class AbstractEnumeratedProperty extends AbstractProperty< /** * @return String */ + @Override protected String defaultAsString() { return isMultiValue() ? (String) defaultValue() : asDelimitedString(defaultValue(), '|'); @@ -73,7 +74,7 @@ public abstract class AbstractEnumeratedProperty extends AbstractProperty< /** * Method nonLegalValueMsgFor. - * + * * @param value * Object * @return String @@ -84,7 +85,7 @@ public abstract class AbstractEnumeratedProperty extends AbstractProperty< /** * Method choiceFrom. - * + * * @param label * String * @return E @@ -100,6 +101,7 @@ public abstract class AbstractEnumeratedProperty extends AbstractProperty< /** * @see net.sourceforge.pmd.PropertyDescriptor#choices() */ + @Override public Object[][] choices() { if (choices != null) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractMultiNumericProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractMultiNumericProperty.java index 2c530ea616..e0eaeb0736 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractMultiNumericProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractMultiNumericProperty.java @@ -5,7 +5,7 @@ package net.sourceforge.pmd.lang.rule.properties; /** - * + * * @author Brian Remedios * @param */ @@ -13,7 +13,7 @@ public abstract class AbstractMultiNumericProperty extends AbstractNumericPro /** * Constructor for AbstractMultiNumericProperty. - * + * * @param theName * String * @param theDescription @@ -44,6 +44,7 @@ public abstract class AbstractMultiNumericProperty extends AbstractNumericPro /** * @return String */ + @Override protected String defaultAsString() { return asDelimitedString(defaultValue()); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractMultiPackagedProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractMultiPackagedProperty.java index b986172a32..63f1c1d6bc 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractMultiPackagedProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractMultiPackagedProperty.java @@ -5,7 +5,7 @@ package net.sourceforge.pmd.lang.rule.properties; /** - * + * * @author Brian Remedios * @param */ @@ -15,7 +15,7 @@ public abstract class AbstractMultiPackagedProperty extends AbstractPackagedP /** * Constructor for AbstractMultiPackagedProperty. - * + * * @param theName * String * @param theDescription @@ -44,6 +44,7 @@ public abstract class AbstractMultiPackagedProperty extends AbstractPackagedP /** * @return String */ + @Override protected String defaultAsString() { return asDelimitedString(defaultValue()); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractNumericProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractNumericProperty.java index 044114b420..7c2c22c2e2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractNumericProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractNumericProperty.java @@ -4,18 +4,18 @@ package net.sourceforge.pmd.lang.rule.properties; +import static net.sourceforge.pmd.PropertyDescriptorFields.MAX; +import static net.sourceforge.pmd.PropertyDescriptorFields.MIN; + import java.util.Map; import net.sourceforge.pmd.NumericPropertyDescriptor; import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescriptorFactory; -import static net.sourceforge.pmd.PropertyDescriptorFields.MAX; -import static net.sourceforge.pmd.PropertyDescriptorFields.MIN; - /** * Maintains a pair of boundary limit values between which all values managed by * the subclasses must fit. - * + * * @author Brian Remedios * @param */ @@ -29,7 +29,7 @@ public abstract class AbstractNumericProperty extends AbstractScalarProperty< .expectedFieldTypesWith(new String[] { MIN, MAX }, new Boolean[] { Boolean.TRUE, Boolean.TRUE }); /** - * + * * @param theName * @param theDescription * @param lower @@ -52,10 +52,11 @@ public abstract class AbstractNumericProperty extends AbstractScalarProperty< /** * Returns the minimum value that instances of the property can have - * + * * @return The minimum value. * @see net.sourceforge.pmd.NumericPropertyDescriptor#lowerLimit() */ + @Override public Number lowerLimit() { return lowerLimit; } @@ -63,16 +64,18 @@ public abstract class AbstractNumericProperty extends AbstractScalarProperty< /** * @return String */ + @Override protected String defaultAsString() { return defaultValue().toString(); } /** * Returns the maximum value that instances of the property can have - * + * * @return The maximum value. * @see net.sourceforge.pmd.NumericPropertyDescriptor#upperLimit() */ + @Override public Number upperLimit() { return upperLimit; } @@ -89,11 +92,12 @@ public abstract class AbstractNumericProperty extends AbstractScalarProperty< /** * Returns a string describing any error the value may have when * characterized by the receiver. - * + * * @param value * Object * @return String */ + @Override protected String valueErrorFor(Object value) { double number = ((Number) value).doubleValue(); @@ -107,10 +111,11 @@ public abstract class AbstractNumericProperty extends AbstractScalarProperty< /** * Method addAttributesTo. - * + * * @param attributes * Map */ + @Override protected void addAttributesTo(Map attributes) { super.addAttributesTo(attributes); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractPackagedProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractPackagedProperty.java index 7e603c06c4..77769b4642 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractPackagedProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractPackagedProperty.java @@ -4,20 +4,20 @@ package net.sourceforge.pmd.lang.rule.properties; +import static net.sourceforge.pmd.PropertyDescriptorFields.LEGAL_PACKAGES; + import java.util.HashSet; import java.util.Map; import java.util.Set; import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescriptorFactory; -import static net.sourceforge.pmd.PropertyDescriptorFields.LEGAL_PACKAGES; - /** * Concrete subclasses manage items that reside within namespaces per the design * of the Java language. Rule developers can limit the range of permissible * items by specifying portions of their package names in the constructor. If * the legalPackageNames value is set to null then no restrictions are made. - * + * * @author Brian Remedios * @param */ @@ -31,7 +31,7 @@ public abstract class AbstractPackagedProperty extends AbstractProperty { .expectedFieldTypesWith(new String[] { LEGAL_PACKAGES }, new Boolean[] { Boolean.FALSE }); /** - * + * * @param theName * @param theDescription * @param theDefault @@ -67,7 +67,7 @@ public abstract class AbstractPackagedProperty extends AbstractProperty { /** * @return String */ - private final String delimitedPackageNames() { + private String delimitedPackageNames() { if (legalPackageNames == null || legalPackageNames.length == 0) { return ""; @@ -87,7 +87,7 @@ public abstract class AbstractPackagedProperty extends AbstractProperty { /** * Evaluates the names of the items against the allowable name prefixes. If * one or more do not have valid prefixes then an exception will be thrown. - * + * * @param item * @param legalNamePrefixes * @throws IllegalArgumentException @@ -130,7 +130,7 @@ public abstract class AbstractPackagedProperty extends AbstractProperty { /** * Method itemTypeName. - * + * * @return String */ protected abstract String itemTypeName(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractProperty.java index c9fa1e90c8..5502a9b5e2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractProperty.java @@ -4,6 +4,10 @@ package net.sourceforge.pmd.lang.rule.properties; +import static net.sourceforge.pmd.PropertyDescriptorFields.DEFAULT_VALUE; +import static net.sourceforge.pmd.PropertyDescriptorFields.DESCRIPTION; +import static net.sourceforge.pmd.PropertyDescriptorFields.NAME; + import java.util.HashMap; import java.util.Map; @@ -12,10 +16,6 @@ import net.sourceforge.pmd.PropertyDescriptorFields; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.util.StringUtil; -import static net.sourceforge.pmd.PropertyDescriptorFields.DEFAULT_VALUE; -import static net.sourceforge.pmd.PropertyDescriptorFields.DESCRIPTION; -import static net.sourceforge.pmd.PropertyDescriptorFields.NAME; - /** * * @author Brian Remedios @@ -47,7 +47,7 @@ public abstract class AbstractProperty implements PropertyDescriptor { /** * Constructor for AbstractPMDProperty. - * + * * @param theName * String * @param theDescription @@ -102,6 +102,7 @@ public abstract class AbstractProperty implements PropertyDescriptor { /** * {@inheritDoc} */ + @Override public char multiValueDelimiter() { return multiValueDelimiter; } @@ -109,6 +110,7 @@ public abstract class AbstractProperty implements PropertyDescriptor { /** * {@inheritDoc} */ + @Override public String name() { return name; } @@ -116,6 +118,7 @@ public abstract class AbstractProperty implements PropertyDescriptor { /** * {@inheritDoc} */ + @Override public String description() { return description; } @@ -123,13 +126,14 @@ public abstract class AbstractProperty implements PropertyDescriptor { /** * {@inheritDoc} */ + @Override public T defaultValue() { return defaultValue; } /** * Method defaultHasNullValue. - * + * * @return boolean */ protected boolean defaultHasNullValue() { @@ -153,6 +157,7 @@ public abstract class AbstractProperty implements PropertyDescriptor { /** * {@inheritDoc} */ + @Override public boolean isMultiValue() { return false; } @@ -160,6 +165,7 @@ public abstract class AbstractProperty implements PropertyDescriptor { /** * {@inheritDoc} */ + @Override public boolean isRequired() { return isRequired; } @@ -167,6 +173,7 @@ public abstract class AbstractProperty implements PropertyDescriptor { /** * {@inheritDoc} */ + @Override public float uiOrder() { return uiOrder; } @@ -186,13 +193,14 @@ public abstract class AbstractProperty implements PropertyDescriptor { /** * {@inheritDoc} */ + @Override public String asDelimitedString(T values) { return asDelimitedString(values, multiValueDelimiter()); } /** * Return the specified values as a single string using the delimiter. - * + * * @param values * Object * @param delimiter @@ -229,6 +237,7 @@ public abstract class AbstractProperty implements PropertyDescriptor { /** * {@inheritDoc} */ + @Override public int compareTo(PropertyDescriptor otherProperty) { float otherOrder = otherProperty.uiOrder(); return (int) (otherOrder - uiOrder); @@ -237,6 +246,7 @@ public abstract class AbstractProperty implements PropertyDescriptor { /** * {@inheritDoc} */ + @Override public String errorFor(Object value) { String typeError = typeErrorFor(value); @@ -328,6 +338,7 @@ public abstract class AbstractProperty implements PropertyDescriptor { /** * {@inheritDoc} */ + @Override public String propertyErrorFor(Rule rule) { Object realValue = rule.getProperty(this); if (realValue == null && !isRequired()) { @@ -339,6 +350,7 @@ public abstract class AbstractProperty implements PropertyDescriptor { /** * {@inheritDoc} */ + @Override public Object[][] choices() { return null; } @@ -346,6 +358,7 @@ public abstract class AbstractProperty implements PropertyDescriptor { /** * {@inheritDoc} */ + @Override public int preferredRowCount() { return 1; } @@ -419,6 +432,7 @@ public abstract class AbstractProperty implements PropertyDescriptor { /** * @return Map */ + @Override public Map attributeValuesById() { Map values = new HashMap<>(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractScalarProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractScalarProperty.java index 93a4447639..66fdc1c67e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractScalarProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/AbstractScalarProperty.java @@ -9,7 +9,7 @@ import net.sourceforge.pmd.util.StringUtil; /** * No, subclasses are not necessarily scalar per se, they're just easy to parse * without error. If you can come up with a better name... - * + * * @author Brian Remedios * @param */ @@ -17,7 +17,7 @@ public abstract class AbstractScalarProperty extends AbstractProperty { /** * Constructor for AbstractScalarProperty. - * + * * @param theName * String * @param theDescription @@ -58,6 +58,7 @@ public abstract class AbstractScalarProperty extends AbstractProperty { * @throws IllegalArgumentException * @see net.sourceforge.pmd.PropertyDescriptor#valueFrom(String) */ + @Override @SuppressWarnings("unchecked") public T valueFrom(String valueString) throws IllegalArgumentException { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/BooleanMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/BooleanMultiProperty.java index eb9efe3a4b..27a71b6f7f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/BooleanMultiProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/BooleanMultiProperty.java @@ -11,13 +11,14 @@ import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescripto /** * Defines a property type that supports multiple Boolean values. - * + * * @author Brian Remedios */ public class BooleanMultiProperty extends AbstractScalarProperty { public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( String[].class) { + @Override public BooleanMultiProperty createWith(Map valuesById) { char delimiter = delimiterIn(valuesById); return new BooleanMultiProperty(nameIn(valuesById), descriptionIn(valuesById), @@ -27,7 +28,7 @@ public class BooleanMultiProperty extends AbstractScalarProperty { /** * Constructor for BooleanMultiProperty that allows for multiple values. - * + * * @param theName * String * @param theDescription @@ -45,6 +46,7 @@ public class BooleanMultiProperty extends AbstractScalarProperty { * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return Boolean[].class; } @@ -60,11 +62,12 @@ public class BooleanMultiProperty extends AbstractScalarProperty { /** * Creates and returns a Boolean instance from a raw string - * + * * @param value * String * @return Object */ + @Override protected Object createFrom(String value) { return Boolean.valueOf(value); } @@ -74,6 +77,7 @@ public class BooleanMultiProperty extends AbstractScalarProperty { * int * @return Object[] */ + @Override protected Boolean[] arrayFor(int size) { return new Boolean[size]; } @@ -81,6 +85,7 @@ public class BooleanMultiProperty extends AbstractScalarProperty { /** * @return String */ + @Override protected String defaultAsString() { return asDelimitedString(defaultValue()); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/BooleanProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/BooleanProperty.java index ef5022e070..6a03a0fc93 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/BooleanProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/BooleanProperty.java @@ -11,7 +11,7 @@ import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescripto /** * Defines a property type that supports single Boolean values. - * + * * @author Brian Remedios */ public class BooleanProperty extends AbstractScalarProperty { @@ -19,6 +19,7 @@ public class BooleanProperty extends AbstractScalarProperty { public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( Boolean.class) { + @Override public BooleanProperty createWith(Map valuesById) { return new BooleanProperty(nameIn(valuesById), descriptionIn(valuesById), Boolean.valueOf(defaultValueIn(valuesById)), 0f); @@ -27,7 +28,7 @@ public class BooleanProperty extends AbstractScalarProperty { /** * Constructor for BooleanProperty limited to a single value. - * + * * @param theName * String * @param theDescription @@ -44,7 +45,7 @@ public class BooleanProperty extends AbstractScalarProperty { /** * Constructor for BooleanProperty limited to a single value. Converts * default argument string into a boolean. - * + * * @param theName * String * @param theDescription @@ -62,6 +63,7 @@ public class BooleanProperty extends AbstractScalarProperty { * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return Boolean.class; } @@ -69,17 +71,19 @@ public class BooleanProperty extends AbstractScalarProperty { /** * @return String */ + @Override protected String defaultAsString() { return Boolean.toString(defaultValue()); } /** * Creates and returns a Boolean instance from a raw string - * + * * @param value * String * @return Object */ + @Override protected Object createFrom(String value) { return Boolean.valueOf(value); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/CharacterMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/CharacterMultiProperty.java index afc51b1890..cf89bffb85 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/CharacterMultiProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/CharacterMultiProperty.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.util.StringUtil; /** * Defines a property type that supports multiple Character values. - * + * * @author Brian Remedios */ public class CharacterMultiProperty extends AbstractProperty { @@ -20,6 +20,7 @@ public class CharacterMultiProperty extends AbstractProperty { public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( Character[].class) { + @Override public CharacterMultiProperty createWith(Map valuesById) { char delimiter = delimiterIn(valuesById); return new CharacterMultiProperty(nameIn(valuesById), descriptionIn(valuesById), @@ -29,7 +30,7 @@ public class CharacterMultiProperty extends AbstractProperty { /** * Constructor for CharacterProperty. - * + * * @param theName * String * @param theDescription @@ -59,6 +60,7 @@ public class CharacterMultiProperty extends AbstractProperty { * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return Character[].class; } @@ -70,6 +72,7 @@ public class CharacterMultiProperty extends AbstractProperty { * @throws IllegalArgumentException * @see net.sourceforge.pmd.PropertyDescriptor#valueFrom(String) */ + @Override public Character[] valueFrom(String valueString) throws IllegalArgumentException { String[] values = StringUtil.substringsOf(valueString, multiValueDelimiter()); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/CharacterProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/CharacterProperty.java index db38be5cb8..2c86ae36e5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/CharacterProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/CharacterProperty.java @@ -11,7 +11,7 @@ import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescripto /** * Defines a property type that supports single Character values. - * + * * @author Brian Remedios */ public class CharacterProperty extends AbstractProperty { @@ -19,6 +19,7 @@ public class CharacterProperty extends AbstractProperty { public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( Character.class) { + @Override public CharacterProperty createWith(Map valuesById) { return new CharacterProperty(nameIn(valuesById), descriptionIn(valuesById), defaultValueIn(valuesById) != null ? new Character(defaultValueIn(valuesById).charAt(0)) : null, @@ -28,7 +29,7 @@ public class CharacterProperty extends AbstractProperty { /** * Constructor for CharacterProperty. - * + * * @param theName * String * @param theDescription @@ -44,7 +45,7 @@ public class CharacterProperty extends AbstractProperty { /** * Constructor for CharacterProperty. - * + * * @param theName * String * @param theDescription @@ -76,6 +77,7 @@ public class CharacterProperty extends AbstractProperty { * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return Character.class; } @@ -87,15 +89,17 @@ public class CharacterProperty extends AbstractProperty { * @throws IllegalArgumentException * @see net.sourceforge.pmd.PropertyDescriptor#valueFrom(String) */ + @Override public Character valueFrom(String valueString) throws IllegalArgumentException { return charFrom(valueString); } /** * Method defaultAsString. - * + * * @return String */ + @Override protected String defaultAsString() { return Character.toString(defaultValue()); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/DoubleMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/DoubleMultiProperty.java index 5d0c74573c..44766f877f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/DoubleMultiProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/DoubleMultiProperty.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescripto /** * Defines a property type that supports multiple double-type property values * within an upper and lower boundary. - * + * * @author Brian Remedios */ public class DoubleMultiProperty extends AbstractMultiNumericProperty { @@ -20,6 +20,7 @@ public class DoubleMultiProperty extends AbstractMultiNumericProperty public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( Double[].class, NUMBER_FIELD_TYPES_BY_KEY) { + @Override public DoubleMultiProperty createWith(Map valuesById) { String[] minMax = minMaxFrom(valuesById); char delimiter = delimiterIn(valuesById, DEFAULT_NUMERIC_DELIMITER); @@ -31,7 +32,7 @@ public class DoubleMultiProperty extends AbstractMultiNumericProperty /** * Constructor for DoubleProperty. - * + * * @param theName * String * @param theDescription @@ -54,6 +55,7 @@ public class DoubleMultiProperty extends AbstractMultiNumericProperty * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return Double[].class; } @@ -63,6 +65,7 @@ public class DoubleMultiProperty extends AbstractMultiNumericProperty * String * @return Object */ + @Override protected Object createFrom(String value) { return Double.valueOf(value); } @@ -72,6 +75,7 @@ public class DoubleMultiProperty extends AbstractMultiNumericProperty * int * @return Object[] */ + @Override protected Object[] arrayFor(int size) { return new Double[size]; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/DoubleProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/DoubleProperty.java index a65cad010a..b6a01d270e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/DoubleProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/DoubleProperty.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescripto /** * Defines a property type that support single double-type property values * within an upper and lower boundary. - * + * * @author Brian Remedios */ public class DoubleProperty extends AbstractNumericProperty { @@ -20,6 +20,7 @@ public class DoubleProperty extends AbstractNumericProperty { public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( Double.class, NUMBER_FIELD_TYPES_BY_KEY) { + @Override public DoubleProperty createWith(Map valuesById) { final String[] minMax = minMaxFrom(valuesById); return new DoubleProperty(nameIn(valuesById), descriptionIn(valuesById), Double.valueOf(minMax[0]), @@ -29,7 +30,7 @@ public class DoubleProperty extends AbstractNumericProperty { /** * Constructor for DoubleProperty. - * + * * @param theName * String * @param theDescription @@ -51,7 +52,7 @@ public class DoubleProperty extends AbstractNumericProperty { /** * Constructor for DoubleProperty. - * + * * @param theName * String * @param theDescription @@ -84,17 +85,19 @@ public class DoubleProperty extends AbstractNumericProperty { * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return Double.class; } /** * Deserializes a string into its Double form. - * + * * @param value * String * @return Object */ + @Override protected Object createFrom(String value) { return doubleFrom(value); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/EnumeratedMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/EnumeratedMultiProperty.java index 3bd975dd21..fd2e02f665 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/EnumeratedMultiProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/EnumeratedMultiProperty.java @@ -16,7 +16,7 @@ import net.sourceforge.pmd.util.StringUtil; * pair of maps. While the values are not serialized out, the labels are and * serve as keys to obtain the values. The choices() method provides the ordered * selections to be used in an editor widget. - * + * * @author Brian Remedios * @param */ @@ -25,6 +25,7 @@ public class EnumeratedMultiProperty extends AbstractEnumeratedProperty( Enumeration[].class) { + @Override public EnumeratedMultiProperty createWith(Map valuesById) { return new EnumeratedMultiProperty(nameIn(valuesById), descriptionIn(valuesById), labelsIn(valuesById), @@ -34,7 +35,7 @@ public class EnumeratedMultiProperty extends AbstractEnumeratedProperty extends AbstractEnumeratedProperty type() { return Object[].class; } @@ -89,13 +91,14 @@ public class EnumeratedMultiProperty extends AbstractEnumeratedProperty extends AbstractEnumeratedProperty */ @@ -24,6 +24,7 @@ public class EnumeratedProperty extends AbstractEnumeratedProperty public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( Enumeration.class) { + @Override public EnumeratedProperty createWith(Map valuesById) { return new EnumeratedProperty(nameIn(valuesById), descriptionIn(valuesById), labelsIn(valuesById), @@ -33,7 +34,7 @@ public class EnumeratedProperty extends AbstractEnumeratedProperty /** * Constructor for EnumeratedProperty. - * + * * @param theName * String * @param theDescription @@ -57,6 +58,7 @@ public class EnumeratedProperty extends AbstractEnumeratedProperty * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return Object.class; } @@ -79,6 +81,7 @@ public class EnumeratedProperty extends AbstractEnumeratedProperty * @throws IllegalArgumentException * @see net.sourceforge.pmd.PropertyDescriptor#valueFrom(String) */ + @Override public Object valueFrom(String value) throws IllegalArgumentException { return choiceFrom(value); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/FileProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/FileProperty.java index c5249eac14..455085ae19 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/FileProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/FileProperty.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescripto import net.sourceforge.pmd.util.StringUtil; /** - * + * * @author Brian Remedios */ public class FileProperty extends AbstractProperty { @@ -20,6 +20,7 @@ public class FileProperty extends AbstractProperty { public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( File.class) { + @Override public FileProperty createWith(Map valuesById) { return new FileProperty(nameIn(valuesById), descriptionIn(valuesById), null, 0f); } @@ -29,10 +30,12 @@ public class FileProperty extends AbstractProperty { super(theName, theDescription, theDefault, theUIOrder); } + @Override public Class type() { return File.class; } + @Override public File valueFrom(String propertyString) throws IllegalArgumentException { return StringUtil.isEmpty(propertyString) ? null : new File(propertyString); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/FloatMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/FloatMultiProperty.java index d19f56c01e..537ff25633 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/FloatMultiProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/FloatMultiProperty.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescripto /** * Defines a property type that support float property values within an upper * and lower boundary. - * + * * @author Brian Remedios */ public class FloatMultiProperty extends AbstractMultiNumericProperty { @@ -20,6 +20,7 @@ public class FloatMultiProperty extends AbstractMultiNumericProperty { public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( Float[].class, NUMBER_FIELD_TYPES_BY_KEY) { + @Override public FloatMultiProperty createWith(Map valuesById) { String[] minMax = minMaxFrom(valuesById); char delimiter = delimiterIn(valuesById, DEFAULT_NUMERIC_DELIMITER); @@ -32,7 +33,7 @@ public class FloatMultiProperty extends AbstractMultiNumericProperty { /** * Constructor for FloatProperty that configures it to accept multiple * values and any number of defaults. - * + * * @param theName * String * @param theDescription @@ -56,28 +57,31 @@ public class FloatMultiProperty extends AbstractMultiNumericProperty { * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return Float[].class; } /** * Creates an property value of the right type from a raw string. - * + * * @param value * String * @return Object */ + @Override protected Object createFrom(String value) { return Float.valueOf(value); } /** * Returns an array of the correct type for the receiver. - * + * * @param size * int * @return Object[] */ + @Override protected Object[] arrayFor(int size) { return new Float[size]; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/FloatProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/FloatProperty.java index f33459c31f..69c9aa3648 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/FloatProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/FloatProperty.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescripto /** * Defines a property type that supports single float property values within an * upper and lower boundary. - * + * * @author Brian Remedios */ public class FloatProperty extends AbstractNumericProperty { @@ -20,6 +20,7 @@ public class FloatProperty extends AbstractNumericProperty { public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( float.class, NUMBER_FIELD_TYPES_BY_KEY) { + @Override public FloatProperty createWith(Map valuesById) { final String[] minMax = minMaxFrom(valuesById); return new FloatProperty(nameIn(valuesById), descriptionIn(valuesById), Float.valueOf(minMax[0]), @@ -30,7 +31,7 @@ public class FloatProperty extends AbstractNumericProperty { /** * Constructor for FloatProperty that limits itself to a single value within * the specified limits. - * + * * @param theName * String * @param theDescription @@ -53,7 +54,7 @@ public class FloatProperty extends AbstractNumericProperty { /** * Constructor for FloatProperty that limits itself to a single value within * the specified limits. Converts string arguments into the Float values. - * + * * @param theName * String * @param theDescription @@ -86,17 +87,19 @@ public class FloatProperty extends AbstractNumericProperty { * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return Float.class; } /** * Creates an property value of the right type from a raw string. - * + * * @param value * String * @return Object */ + @Override protected Object createFrom(String value) { return floatFrom(value); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/IntegerMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/IntegerMultiProperty.java index 81bdffbed1..09bbe0b9a4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/IntegerMultiProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/IntegerMultiProperty.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescripto /** * Defines a datatype that supports multiple Integer property values within an * upper and lower boundary. - * + * * @author Brian Remedios */ public class IntegerMultiProperty extends AbstractMultiNumericProperty { @@ -20,6 +20,7 @@ public class IntegerMultiProperty extends AbstractMultiNumericProperty( Integer[].class, NUMBER_FIELD_TYPES_BY_KEY) { + @Override public IntegerMultiProperty createWith(Map valuesById) { String[] minMax = minMaxFrom(valuesById); char delimiter = delimiterIn(valuesById, DEFAULT_NUMERIC_DELIMITER); @@ -31,7 +32,7 @@ public class IntegerMultiProperty extends AbstractMultiNumericProperty type() { return Integer[].class; } @@ -64,6 +66,7 @@ public class IntegerMultiProperty extends AbstractMultiNumericProperty { @@ -20,6 +20,7 @@ public class IntegerProperty extends AbstractNumericProperty { public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( Integer.class, NUMBER_FIELD_TYPES_BY_KEY) { + @Override public IntegerProperty createWith(Map valuesById) { final String[] minMax = minMaxFrom(valuesById); return new IntegerProperty(nameIn(valuesById), descriptionIn(valuesById), Integer.valueOf(minMax[0]), @@ -30,7 +31,7 @@ public class IntegerProperty extends AbstractNumericProperty { /** * Constructor for IntegerProperty that limits itself to a single value * within the specified limits. - * + * * @param theName * String * @param theDescription @@ -54,7 +55,7 @@ public class IntegerProperty extends AbstractNumericProperty { * Constructor for IntegerProperty that limits itself to a single value * within the specified limits. Converts string arguments into the Float * values. - * + * * @param theName * String * @param theDescription @@ -86,6 +87,7 @@ public class IntegerProperty extends AbstractNumericProperty { * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return Integer.class; } @@ -95,6 +97,7 @@ public class IntegerProperty extends AbstractNumericProperty { * String * @return Object */ + @Override protected Object createFrom(String value) { return intFrom(value); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/LongMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/LongMultiProperty.java index 5ffc5b70ca..879f0d83f5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/LongMultiProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/LongMultiProperty.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescripto /** * Defines a datatype that supports multiple Long property values within an * upper and lower boundary. - * + * * @author Brian Remedios */ public class LongMultiProperty extends AbstractMultiNumericProperty { @@ -20,6 +20,7 @@ public class LongMultiProperty extends AbstractMultiNumericProperty { public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( Long[].class, NUMBER_FIELD_TYPES_BY_KEY) { + @Override public LongMultiProperty createWith(Map valuesById) { String[] minMax = minMaxFrom(valuesById); char delimiter = delimiterIn(valuesById, DEFAULT_NUMERIC_DELIMITER); @@ -31,7 +32,7 @@ public class LongMultiProperty extends AbstractMultiNumericProperty { /** * Constructor for LongProperty. - * + * * @param theName * String * @param theDescription @@ -55,6 +56,7 @@ public class LongMultiProperty extends AbstractMultiNumericProperty { * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return Long[].class; } @@ -64,17 +66,19 @@ public class LongMultiProperty extends AbstractMultiNumericProperty { * String * @return Object */ + @Override protected Object createFrom(String value) { return Long.valueOf(value); } /** * Returns an array of the correct type for the receiver. - * + * * @param size * int * @return Object[] */ + @Override protected Object[] arrayFor(int size) { return new Long[size]; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/LongProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/LongProperty.java index bd54a7a612..7f8a75f724 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/LongProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/LongProperty.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescripto /** * Defines a datatype that supports the single Long property values within an * upper and lower boundary. - * + * * @author Brian Remedios */ public class LongProperty extends AbstractNumericProperty { @@ -20,6 +20,7 @@ public class LongProperty extends AbstractNumericProperty { public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory(Long.class, NUMBER_FIELD_TYPES_BY_KEY) { + @Override public LongProperty createWith(Map valuesById) { final String[] minMax = minMaxFrom(valuesById); return new LongProperty(nameIn(valuesById), descriptionIn(valuesById), Long.valueOf(minMax[0]), @@ -29,7 +30,7 @@ public class LongProperty extends AbstractNumericProperty { /** * Constructor for LongProperty. - * + * * @param theName * String * @param theDescription @@ -51,7 +52,7 @@ public class LongProperty extends AbstractNumericProperty { /** * Constructor for LongProperty that limits itself to a single value within * the specified limits. Converts string arguments into the Long values. - * + * * @param theName * String * @param theDescription @@ -84,6 +85,7 @@ public class LongProperty extends AbstractNumericProperty { * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return Long.class; } @@ -93,6 +95,7 @@ public class LongProperty extends AbstractNumericProperty { * String * @return Object */ + @Override protected Object createFrom(String value) { return longFrom(value); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/MethodMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/MethodMultiProperty.java index 6cb845833c..74bd7bd92c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/MethodMultiProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/MethodMultiProperty.java @@ -26,6 +26,7 @@ public class MethodMultiProperty extends AbstractMultiPackagedProperty public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( Method[].class, PACKAGED_FIELD_TYPES_BY_KEY) { + @Override public MethodMultiProperty createWith(Map valuesById) { char delimiter = delimiterIn(valuesById); return new MethodMultiProperty(nameIn(valuesById), descriptionIn(valuesById), defaultValueIn(valuesById), @@ -148,6 +149,7 @@ public class MethodMultiProperty extends AbstractMultiPackagedProperty * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return Method[].class; } @@ -159,6 +161,7 @@ public class MethodMultiProperty extends AbstractMultiPackagedProperty * @throws IllegalArgumentException * @see net.sourceforge.pmd.PropertyDescriptor#valueFrom(String) */ + @Override public Method[] valueFrom(String valueString) throws IllegalArgumentException { return methodsFrom(valueString); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/MethodProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/MethodProperty.java index e479924e25..11cf9ffd08 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/MethodProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/MethodProperty.java @@ -196,8 +196,8 @@ public class MethodProperty extends AbstractPackagedProperty { String arrayTypeName = typeName.substring(0, typeName.length() - ARRAY_FLAG.length()); type = typeFor(arrayTypeName); // recurse return Array.newInstance(type, 0).getClass(); // TODO is there a - // better way to get - // an array type? + // better way to get + // an array type? } type = ClassUtil.getTypeFor(typeName); // try shortcut first diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/PropertyDescriptorFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/PropertyDescriptorFactory.java index 05582ffec9..a320a61009 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/PropertyDescriptorFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/PropertyDescriptorFactory.java @@ -16,12 +16,8 @@ public class PropertyDescriptorFactory { public static String getPropertyDescriptorType(PropertyDescriptor propertyDescriptor) { Class type = propertyDescriptor.type(); String typeName = null; - if (propertyDescriptor instanceof EnumeratedProperty || propertyDescriptor instanceof MethodProperty // TODO - // - - // yes - // we - // can, - // investigate + // TODO - yes we can, investigate + if (propertyDescriptor instanceof EnumeratedProperty || propertyDescriptor instanceof MethodProperty || propertyDescriptor instanceof TypeProperty) { // Cannot serialize these kinds of PropertyDescriptors } else if ("java.lang".equals(type.getPackage().getName())) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/PropertyDescriptorWrapper.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/PropertyDescriptorWrapper.java index f39087e4ed..0f34d0bca7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/PropertyDescriptorWrapper.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/PropertyDescriptorWrapper.java @@ -15,7 +15,7 @@ import net.sourceforge.pmd.Rule; * properties it has created, versus those created by Rule classes. This is used * in the encoding of a Rule to XML format to distinguish Rule defined * PropertyDescriptors and those which were originally defined in XML. - * + * * @param * The type of the underlying PropertyDescriptor. */ @@ -33,66 +33,82 @@ public class PropertyDescriptorWrapper implements PropertyDescriptor { return propertyDescriptor; } + @Override public String asDelimitedString(T value) { return propertyDescriptor.asDelimitedString(value); } + @Override public Object[][] choices() { return propertyDescriptor.choices(); } + @Override public int compareTo(PropertyDescriptor o) { return propertyDescriptor.compareTo(o); } + @Override public T defaultValue() { return propertyDescriptor.defaultValue(); } + @Override public String description() { return propertyDescriptor.description(); } + @Override public String errorFor(Object value) { return propertyDescriptor.errorFor(value); } + @Override public boolean isMultiValue() { return propertyDescriptor.isMultiValue(); } + @Override public boolean isRequired() { return propertyDescriptor.isRequired(); } + @Override public char multiValueDelimiter() { return propertyDescriptor.multiValueDelimiter(); } + @Override public String name() { return propertyDescriptor.name(); } + @Override public int preferredRowCount() { return propertyDescriptor.preferredRowCount(); } + @Override public String propertyErrorFor(Rule rule) { return propertyDescriptor.propertyErrorFor(rule); } + @Override public Class type() { return propertyDescriptor.type(); } + @Override public float uiOrder() { return propertyDescriptor.uiOrder(); } + @Override public T valueFrom(String propertyString) throws IllegalArgumentException { return propertyDescriptor.valueFrom(propertyString); } + @Override public Map attributeValuesById() { return propertyDescriptor.attributeValuesById(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/StringMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/StringMultiProperty.java index 17f6730e85..49920fe574 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/StringMultiProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/StringMultiProperty.java @@ -13,7 +13,7 @@ import net.sourceforge.pmd.util.StringUtil; /** * Defines a datatype that supports multiple String values. Note that all * strings must be filtered by the delimiter character. - * + * * @author Brian Remedios */ public class StringMultiProperty extends AbstractProperty { @@ -21,6 +21,7 @@ public class StringMultiProperty extends AbstractProperty { public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( String[].class) { + @Override public StringMultiProperty createWith(Map valuesById) { char delimiter = delimiterIn(valuesById); return new StringMultiProperty(nameIn(valuesById), descriptionIn(valuesById), @@ -30,7 +31,7 @@ public class StringMultiProperty extends AbstractProperty { /** * Constructor for StringProperty. - * + * * @param theName * String * @param theDescription @@ -72,6 +73,7 @@ public class StringMultiProperty extends AbstractProperty { * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return String[].class; } @@ -82,6 +84,7 @@ public class StringMultiProperty extends AbstractProperty { * @return Object * @see net.sourceforge.pmd.PropertyDescriptor#valueFrom(String) */ + @Override public String[] valueFrom(String valueString) { return StringUtil.substringsOf(valueString, multiValueDelimiter()); } @@ -98,16 +101,17 @@ public class StringMultiProperty extends AbstractProperty { /** * @return String */ - private final String illegalCharMsg() { + private String illegalCharMsg() { return "Value cannot contain the '" + multiValueDelimiter() + "' character"; } /** - * + * * @param value * Object * @return String */ + @Override protected String valueErrorFor(Object value) { if (value == null) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/StringProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/StringProperty.java index 347b2abd98..9d0e1e0c76 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/StringProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/StringProperty.java @@ -11,7 +11,7 @@ import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescripto /** * Defines a datatype that supports single String values. - * + * * @author Brian Remedios */ public class StringProperty extends AbstractProperty { @@ -19,6 +19,7 @@ public class StringProperty extends AbstractProperty { public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( String.class) { + @Override public StringProperty createWith(Map valuesById) { return new StringProperty(nameIn(valuesById), descriptionIn(valuesById), defaultValueIn(valuesById), 0f); } @@ -26,7 +27,7 @@ public class StringProperty extends AbstractProperty { /** * Constructor for StringProperty. - * + * * @param theName * String * @param theDescription @@ -43,6 +44,7 @@ public class StringProperty extends AbstractProperty { /** * @return String */ + @Override protected String defaultAsString() { return defaultValue(); } @@ -52,6 +54,7 @@ public class StringProperty extends AbstractProperty { * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return String.class; } @@ -63,6 +66,7 @@ public class StringProperty extends AbstractProperty { * @return Object * @see net.sourceforge.pmd.PropertyDescriptor#valueFrom(String) */ + @Override public String valueFrom(String valueString) { return valueString; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/TypeMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/TypeMultiProperty.java index 81847cb4c3..c9bfcfb74b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/TypeMultiProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/TypeMultiProperty.java @@ -13,7 +13,7 @@ import net.sourceforge.pmd.util.StringUtil; /** * Defines a property that supports multiple class types, even for primitive * values! - * + * * TODO - untested for array types * * @author Brian Remedios @@ -23,6 +23,7 @@ public class TypeMultiProperty extends AbstractMultiPackagedProperty { public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( Class[].class, PACKAGED_FIELD_TYPES_BY_KEY) { + @Override public TypeMultiProperty createWith(Map valuesById) { char delimiter = delimiterIn(valuesById); return new TypeMultiProperty(nameIn(valuesById), descriptionIn(valuesById), defaultValueIn(valuesById), @@ -32,7 +33,7 @@ public class TypeMultiProperty extends AbstractMultiPackagedProperty { /** * Constructor for TypeProperty. - * + * * @param theName * String * @param theDescription @@ -53,7 +54,7 @@ public class TypeMultiProperty extends AbstractMultiPackagedProperty { /** * Constructor for TypeProperty. - * + * * @param theName * String * @param theDescription @@ -74,7 +75,7 @@ public class TypeMultiProperty extends AbstractMultiPackagedProperty { /** * Constructor for TypeProperty. - * + * * @param theName * String * @param theDescription @@ -121,6 +122,7 @@ public class TypeMultiProperty extends AbstractMultiPackagedProperty { * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return Class[].class; } @@ -149,6 +151,7 @@ public class TypeMultiProperty extends AbstractMultiPackagedProperty { * @return Object * @see net.sourceforge.pmd.PropertyDescriptor#valueFrom(String) */ + @Override public Class[] valueFrom(String valueString) { return typesFrom(valueString); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/TypeProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/TypeProperty.java index e50271a94a..9cb0e0a496 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/TypeProperty.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/TypeProperty.java @@ -14,7 +14,7 @@ import net.sourceforge.pmd.util.StringUtil; /** * Defines a property that supports single class types, even for primitive * values! - * + * * TODO - untested for array types * * @author Brian Remedios @@ -24,6 +24,7 @@ public class TypeProperty extends AbstractPackagedProperty { public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory( Class.class, PACKAGED_FIELD_TYPES_BY_KEY) { + @Override public TypeProperty createWith(Map valuesById) { char delimiter = delimiterIn(valuesById); return new TypeProperty(nameIn(valuesById), descriptionIn(valuesById), defaultValueIn(valuesById), @@ -33,7 +34,7 @@ public class TypeProperty extends AbstractPackagedProperty { /** * Constructor for TypeProperty. - * + * * @param theName * String * @param theDescription @@ -52,7 +53,7 @@ public class TypeProperty extends AbstractPackagedProperty { } /** - * + * * @param theName * String * @param theDescription @@ -71,7 +72,7 @@ public class TypeProperty extends AbstractPackagedProperty { } /** - * + * * @param theName * String * @param theDescription @@ -92,13 +93,14 @@ public class TypeProperty extends AbstractPackagedProperty { /** * @return String */ + @Override protected String defaultAsString() { return asString(defaultValue()); } /** * Method packageNameOf. - * + * * @param item * Object * @return String @@ -112,6 +114,7 @@ public class TypeProperty extends AbstractPackagedProperty { * @return Class * @see net.sourceforge.pmd.PropertyDescriptor#type() */ + @Override public Class type() { return Class.class; } @@ -163,6 +166,7 @@ public class TypeProperty extends AbstractPackagedProperty { * @return Object * @see net.sourceforge.pmd.PropertyDescriptor#valueFrom(String) */ + @Override public Class valueFrom(String valueString) { return classFrom(valueString); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/factories/BasicPropertyDescriptorFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/factories/BasicPropertyDescriptorFactory.java index a367733483..45979ea1e3 100755 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/factories/BasicPropertyDescriptorFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/factories/BasicPropertyDescriptorFactory.java @@ -4,6 +4,14 @@ package net.sourceforge.pmd.lang.rule.properties.factories; +import static net.sourceforge.pmd.PropertyDescriptorFields.DEFAULT_VALUE; +import static net.sourceforge.pmd.PropertyDescriptorFields.DELIMITER; +import static net.sourceforge.pmd.PropertyDescriptorFields.DESC; +import static net.sourceforge.pmd.PropertyDescriptorFields.LEGAL_PACKAGES; +import static net.sourceforge.pmd.PropertyDescriptorFields.MAX; +import static net.sourceforge.pmd.PropertyDescriptorFields.MIN; +import static net.sourceforge.pmd.PropertyDescriptorFields.NAME; + import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -16,16 +24,8 @@ import net.sourceforge.pmd.lang.rule.properties.AbstractProperty; import net.sourceforge.pmd.util.CollectionUtil; import net.sourceforge.pmd.util.StringUtil; -import static net.sourceforge.pmd.PropertyDescriptorFields.DEFAULT_VALUE; -import static net.sourceforge.pmd.PropertyDescriptorFields.DELIMITER; -import static net.sourceforge.pmd.PropertyDescriptorFields.DESC; -import static net.sourceforge.pmd.PropertyDescriptorFields.LEGAL_PACKAGES; -import static net.sourceforge.pmd.PropertyDescriptorFields.MAX; -import static net.sourceforge.pmd.PropertyDescriptorFields.MIN; -import static net.sourceforge.pmd.PropertyDescriptorFields.NAME; - /** - * + * * @author Brian Remedios * * @param @@ -64,14 +64,17 @@ public class BasicPropertyDescriptorFactory implements PropertyDescriptorFact fieldTypesByKey = Collections.unmodifiableMap(temp); } + @Override public Class valueType() { return valueType; } + @Override public PropertyDescriptor createWith(Map valuesById) { throw new RuntimeException("Unimplemented createWith() method in subclass"); } + @Override public Map expectedFields() { return fieldTypesByKey; } @@ -91,8 +94,8 @@ public class BasicPropertyDescriptorFactory implements PropertyDescriptorFact protected String numericDefaultValueIn(Map valuesById) { String number = defaultValueIn(valuesById); return StringUtil.isEmpty(number) ? "0" : number; // TODO is 0 - // reasonable if - // undefined? + // reasonable if + // undefined? } protected static String minValueIn(Map valuesById) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/factories/PropertyDescriptorUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/factories/PropertyDescriptorUtil.java index af7eb1bccb..f5a69c89bb 100755 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/factories/PropertyDescriptorUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/properties/factories/PropertyDescriptorUtil.java @@ -34,18 +34,20 @@ import net.sourceforge.pmd.lang.rule.properties.TypeMultiProperty; import net.sourceforge.pmd.lang.rule.properties.TypeProperty; /** - * + * * @author Brian Remedios */ public class PropertyDescriptorUtil { public static final Comparator> COMPARATOR_BY_ORDER = new Comparator>() { + @Override public int compare(PropertyDescriptor pd1, PropertyDescriptor pd2) { return pd2.uiOrder() > pd1.uiOrder() ? -1 : 1; } }; private static final Map DESCRIPTOR_FACTORIES_BY_TYPE; + static { Map temp = new HashMap<>(18); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/stat/StatisticalRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/stat/StatisticalRule.java index f5a65e921f..7eaad0ce74 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/stat/StatisticalRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/stat/StatisticalRule.java @@ -13,7 +13,7 @@ import net.sourceforge.pmd.stat.Metric; /** * This interface tags a Rule as being a Statistical rule, producing various * metrics from data points. - * + * * @see DataPoint * @see Metric * @see StatisticalRuleHelper diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/stat/StatisticalRuleHelper.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/stat/StatisticalRuleHelper.java index 4b464727e9..3df136061e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/stat/StatisticalRuleHelper.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/stat/StatisticalRuleHelper.java @@ -4,6 +4,10 @@ package net.sourceforge.pmd.lang.rule.stat; +import static net.sourceforge.pmd.lang.rule.stat.StatisticalRule.MINIMUM_DESCRIPTOR; +import static net.sourceforge.pmd.lang.rule.stat.StatisticalRule.SIGMA_DESCRIPTOR; +import static net.sourceforge.pmd.lang.rule.stat.StatisticalRule.TOP_SCORE_DESCRIPTOR; + import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -13,14 +17,10 @@ import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.stat.DataPoint; import net.sourceforge.pmd.stat.Metric; -import static net.sourceforge.pmd.lang.rule.stat.StatisticalRule.MINIMUM_DESCRIPTOR; -import static net.sourceforge.pmd.lang.rule.stat.StatisticalRule.SIGMA_DESCRIPTOR; -import static net.sourceforge.pmd.lang.rule.stat.StatisticalRule.TOP_SCORE_DESCRIPTOR; - /** * This class is used to implement the core logic of a StatisticalRule. Concrete * Rule implementations should delegate to an instance of this class. - * + * * @author David Dixon-Peugh Aug 8, 2002 StatisticalRule.java */ public class StatisticalRuleHelper { @@ -53,17 +53,17 @@ public class StatisticalRuleHelper { double minimum = 0.0; if (rule.getProperty(SIGMA_DESCRIPTOR) != null) { // TODO - need to come - // up with a good - // default value + // up with a good + // default value deviation = getStdDev(); double sigma = rule.getProperty(SIGMA_DESCRIPTOR); minimum = getMean() + (sigma * deviation); } if (rule.getProperty(MINIMUM_DESCRIPTOR) != null) { // TODO - need to - // come up with a - // good default - // value + // come up with a + // good default + // value double mMin = rule.getProperty(MINIMUM_DESCRIPTOR); if (mMin > minimum) { minimum = mMin; @@ -73,9 +73,9 @@ public class StatisticalRuleHelper { SortedSet newPoints = applyMinimumValue(dataPoints, minimum); if (rule.getProperty(TOP_SCORE_DESCRIPTOR) != null) { // TODO - need to - // come up with a - // good default - // value + // come up with a + // good default + // value int topScore = rule.getProperty(TOP_SCORE_DESCRIPTOR); if (newPoints.size() >= topScore) { newPoints = applyTopScore(newPoints, topScore); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/AbstractXPathRuleQuery.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/AbstractXPathRuleQuery.java index 9987306f47..27c78bb5b6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/AbstractXPathRuleQuery.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/AbstractXPathRuleQuery.java @@ -40,6 +40,7 @@ public abstract class AbstractXPathRuleQuery implements XPathRuleQuery { /** * {@inheritDoc} */ + @Override public void setXPath(String xpath) { this.xpath = xpath; } @@ -47,6 +48,7 @@ public abstract class AbstractXPathRuleQuery implements XPathRuleQuery { /** * {@inheritDoc} */ + @Override public void setVersion(String version) throws UnsupportedOperationException { if (!isSupportedVersion(version)) { throw new UnsupportedOperationException( @@ -58,7 +60,7 @@ public abstract class AbstractXPathRuleQuery implements XPathRuleQuery { /** * Subclasses should implement to indicate whether an XPath version is * supported. - * + * * @param version * The XPath version. * @return true if the XPath version is supported, @@ -69,6 +71,7 @@ public abstract class AbstractXPathRuleQuery implements XPathRuleQuery { /** * {@inheritDoc} */ + @Override public void setProperties(Map, Object> properties) { this.properties = properties; } @@ -76,6 +79,7 @@ public abstract class AbstractXPathRuleQuery implements XPathRuleQuery { /** * {@inheritDoc} */ + @Override public List getRuleChainVisits() { return ruleChainVisits; } @@ -83,5 +87,6 @@ public abstract class AbstractXPathRuleQuery implements XPathRuleQuery { /** * {@inheritDoc} */ + @Override public abstract List evaluate(Node node, RuleContext data); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/JaxenXPathRuleQuery.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/JaxenXPathRuleQuery.java index 930f87303b..546a613ef5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/JaxenXPathRuleQuery.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/JaxenXPathRuleQuery.java @@ -42,7 +42,7 @@ public class JaxenXPathRuleQuery extends AbstractXPathRuleQuery { private static final Logger LOG = Logger.getLogger(JaxenXPathRuleQuery.class.getName()); - private static enum InitializationStatus { + private enum InitializationStatus { NONE, PARTIAL, FULL } @@ -180,8 +180,8 @@ public class JaxenXPathRuleQuery extends AbstractXPathRuleQuery { } } } else if (node instanceof UnionExpr) { // Or a UnionExpr, that is - // something like //TypeA | - // //TypeB + // something like //TypeA | + // //TypeB UnionExpr unionExpr = (UnionExpr) node; pending.push(unionExpr.getLHS()); pending.push(unionExpr.getRHS()); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/SaxonXPathRuleQuery.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/SaxonXPathRuleQuery.java index be3311c1ee..ffca2b672c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/SaxonXPathRuleQuery.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/SaxonXPathRuleQuery.java @@ -9,6 +9,18 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import net.sourceforge.pmd.PropertyDescriptor; +import net.sourceforge.pmd.RuleContext; +import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.ast.xpath.saxon.DocumentNode; +import net.sourceforge.pmd.lang.ast.xpath.saxon.ElementNode; +import net.sourceforge.pmd.lang.rule.properties.BooleanProperty; +import net.sourceforge.pmd.lang.rule.properties.EnumeratedProperty; +import net.sourceforge.pmd.lang.rule.properties.IntegerProperty; +import net.sourceforge.pmd.lang.rule.properties.PropertyDescriptorWrapper; +import net.sourceforge.pmd.lang.rule.properties.StringProperty; +import net.sourceforge.pmd.lang.xpath.Initializer; + import net.sf.saxon.om.ValueRepresentation; import net.sf.saxon.sxpath.AbstractStaticContext; import net.sf.saxon.sxpath.IndependentContext; @@ -21,17 +33,6 @@ import net.sf.saxon.trans.XPathException; import net.sf.saxon.value.BooleanValue; import net.sf.saxon.value.Int64Value; import net.sf.saxon.value.StringValue; -import net.sourceforge.pmd.PropertyDescriptor; -import net.sourceforge.pmd.RuleContext; -import net.sourceforge.pmd.lang.ast.Node; -import net.sourceforge.pmd.lang.ast.xpath.saxon.DocumentNode; -import net.sourceforge.pmd.lang.ast.xpath.saxon.ElementNode; -import net.sourceforge.pmd.lang.rule.properties.BooleanProperty; -import net.sourceforge.pmd.lang.rule.properties.EnumeratedProperty; -import net.sourceforge.pmd.lang.rule.properties.IntegerProperty; -import net.sourceforge.pmd.lang.rule.properties.PropertyDescriptorWrapper; -import net.sourceforge.pmd.lang.rule.properties.StringProperty; -import net.sourceforge.pmd.lang.xpath.Initializer; /** * This is a Saxon based XPathRule query. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRuleQuery.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRuleQuery.java index f8065f8a41..c665d3764b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRuleQuery.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRuleQuery.java @@ -40,7 +40,7 @@ public interface XPathRuleQuery { /** * Set the XPath query string to be used. - * + * * @param xpath * The XPath query string. */ @@ -48,7 +48,7 @@ public interface XPathRuleQuery { /** * Set the XPath version to be used. - * + * * @param version * The XPath version. * @throws UnsupportedOperationException @@ -71,7 +71,7 @@ public interface XPathRuleQuery { /** * Evaluate the XPath query against the given Node. - * + * * @param node * The Node. * @param data diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/AbstractScope.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/AbstractScope.java index 0b5a09f080..8f890921f9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/AbstractScope.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/AbstractScope.java @@ -86,7 +86,7 @@ public abstract class AbstractScope implements Scope { @Override public Set addNameOccurrence(NameOccurrence occurrence) { - Set result = new HashSet(); + Set result = new HashSet<>(); for (Map.Entry> e : getDeclarations().entrySet()) { if (e.getKey().getImage().equals(occurrence.getImage())) { result.add(e.getKey()); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/NameDeclaration.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/NameDeclaration.java index 93ba39d317..ffe9e23ac7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/NameDeclaration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/NameDeclaration.java @@ -12,7 +12,7 @@ public interface NameDeclaration { /** * Gets the node which manifests the declaration. - * + * * @return the node */ ScopedNode getNode(); @@ -20,7 +20,7 @@ public interface NameDeclaration { /** * Gets the image of the node. This is usually the name of the declaration * such as the variable name. - * + * * @return the image * @see #getName() */ @@ -28,14 +28,14 @@ public interface NameDeclaration { /** * Gets the scope in which this name has been declared. - * + * * @return the scope */ Scope getScope(); /** * Gets the name of the declaration, such as the variable name. - * + * * @return */ String getName(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/NameOccurrence.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/NameOccurrence.java index c7938ce9c3..dc8376426a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/NameOccurrence.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/NameOccurrence.java @@ -11,14 +11,14 @@ package net.sourceforge.pmd.lang.symboltable; public interface NameOccurrence { /** * Gets the location where the usage occurred. - * + * * @return the node */ ScopedNode getLocation(); /** * Gets the image of the used declaration, such as the variable name. - * + * * @return the image */ String getImage(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/Scope.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/Scope.java index f217626303..5c60139573 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/Scope.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/Scope.java @@ -32,7 +32,7 @@ public interface Scope { /** * Helper method that goes up the parent scopes to find a scope of the * specified type - * + * * @param clazz * the type of the Scope to search for * @return the found scope of the specified type or null if no @@ -42,7 +42,7 @@ public interface Scope { /** * Gets all the declaration with the occurrences in this scope. - * + * * @return map of declarations with occurrences. */ Map> getDeclarations(); @@ -51,7 +51,7 @@ public interface Scope { * Helper method to get only a specific type of name declarations. The * return map elemens have already been casted to the correct type. This * method usually returns a subset of {@link #getDeclarations()}. - * + * * @param clazz * the type of name declarations to use * @return map of declarations with occurrences. @@ -71,7 +71,7 @@ public interface Scope { * Adds a new declaration to this scope. Only after the declaration has been * added, {@link #contains(NameOccurrence)} and * {@link #addNameOccurrence(NameOccurrence)} can be used correctly. - * + * * @param declaration * the declaration to add */ @@ -80,7 +80,7 @@ public interface Scope { /** * Adds a {@link NameOccurrence} to this scope - only call this after * getting a true back from {@link #contains(NameOccurrence)}. - * + * * @return the {@link NameDeclaration}s that are referenced by the given * {@link NameOccurrence}, if the {@link NameOccurrence} could be * added. Otherwise an empty set is returned. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/Initializer.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/Initializer.java index 362b2173da..d0a5f6e77d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/Initializer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/Initializer.java @@ -4,12 +4,13 @@ package net.sourceforge.pmd.lang.xpath; -import net.sf.saxon.sxpath.IndependentContext; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.LanguageVersionHandler; +import net.sf.saxon.sxpath.IndependentContext; + /** * This class serves as the means to perform XPath related static * initialization. For example, initializing custom Jaxen Functions. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/MatchesFunction.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/MatchesFunction.java index 5c9912ae4e..67493ca9c5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/MatchesFunction.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/MatchesFunction.java @@ -25,6 +25,7 @@ public class MatchesFunction implements Function { new MatchesFunction()); } + @Override public Object call(Context context, List args) throws FunctionCallException { if (args.isEmpty()) { return Boolean.FALSE; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/processor/AbstractPMDProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/processor/AbstractPMDProcessor.java index 2bc043d661..5708f83e7b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/processor/AbstractPMDProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/processor/AbstractPMDProcessor.java @@ -54,7 +54,7 @@ public abstract class AbstractPMDProcessor { * not be used by different threads. Each thread must create its * own copy of the rules (see * {@link PmdRunnable.PmdThread#getRuleSets(String)}). - * + * * @param factory * @return the rules within a rulesets */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/processor/MultiThreadProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/processor/MultiThreadProcessor.java index 1c6cac313a..a3ed4349d7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/processor/MultiThreadProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/processor/MultiThreadProcessor.java @@ -58,7 +58,7 @@ public class MultiThreadProcessor extends AbstractPMDProcessor { } - private void processReports(final List renderers, List> tasks) throws Error { + private void processReports(final List renderers, List> tasks) { while (!tasks.isEmpty()) { Future future = tasks.remove(0); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java b/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java index 67be88be11..b18a881127 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java @@ -95,7 +95,7 @@ public class PmdRunnable extends PMD implements Callable { private RuleSets rulesets; private final RuleSetFactory ruleSetFactory; - public PmdThread(int id, Runnable r, RuleSetFactory ruleSetFactory, RuleContext ctx) { + PmdThread(int id, Runnable r, RuleSetFactory ruleSetFactory, RuleContext ctx) { super(r, "PmdThread " + id); this.id = id; context = new RuleContext(ctx); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractAccumulatingRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractAccumulatingRenderer.java index 76f0faaa15..71072b7390 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractAccumulatingRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractAccumulatingRenderer.java @@ -15,10 +15,10 @@ import net.sourceforge.pmd.util.datasource.DataSource; * working memory proportional to the number of violations found, which can be * quite large in some scenarios. Consider using * {@link AbstractIncrementingRenderer} which can use significantly less memory. - * + * * Subclasses should implement the {@link #end()} method to output the * {@link #report}. - * + * * @see AbstractIncrementingRenderer */ public abstract class AbstractAccumulatingRenderer extends AbstractRenderer { @@ -35,6 +35,7 @@ public abstract class AbstractAccumulatingRenderer extends AbstractRenderer { /** * {@inheritDoc} */ + @Override public void start() throws IOException { report = new Report(); } @@ -42,20 +43,23 @@ public abstract class AbstractAccumulatingRenderer extends AbstractRenderer { /** * {@inheritDoc} */ + @Override public void startFileAnalysis(DataSource dataSource) { } /** * {@inheritDoc} */ + @Override public void renderFileReport(Report report) throws IOException { this.report.merge(report); } /** * Subclasses should output the {@link #report}. - * + * * {@inheritDoc} */ + @Override public abstract void end() throws IOException; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractIncrementingRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractIncrementingRenderer.java index 836655e37d..a8652a8d90 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractIncrementingRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractIncrementingRenderer.java @@ -20,7 +20,7 @@ import net.sourceforge.pmd.util.datasource.DataSource; * significantly less working memory at any given time. Variations in the * delivery of source file reports are reflected in the output of the * {@link Renderer}, so report output can be different between runs. - * + * * Only processing errors and suppressed violations are accumulated across all * files. These are intended to be processed in the {@link #end()} method. */ @@ -43,18 +43,21 @@ public abstract class AbstractIncrementingRenderer extends AbstractRenderer { /** * {@inheritDoc} */ + @Override public void start() throws IOException { } /** * {@inheritDoc} */ + @Override public void startFileAnalysis(DataSource dataSource) { } /** * {@inheritDoc} */ + @Override public void renderFileReport(Report report) throws IOException { Iterator violations = report.iterator(); if (violations.hasNext()) { @@ -73,7 +76,7 @@ public abstract class AbstractIncrementingRenderer extends AbstractRenderer { /** * Render a series of {@link RuleViolation}s. - * + * * @param violations * The iterator of violations to render. * @throws IOException @@ -83,6 +86,7 @@ public abstract class AbstractIncrementingRenderer extends AbstractRenderer { /** * {@inheritDoc} */ + @Override public void end() throws IOException { } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java index 7512272c2c..96216ced43 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java @@ -36,6 +36,7 @@ public abstract class AbstractRenderer extends AbstractPropertySource implements /** * {@inheritDoc} */ + @Override public String getName() { return name; } @@ -43,6 +44,7 @@ public abstract class AbstractRenderer extends AbstractPropertySource implements /** * {@inheritDoc} */ + @Override public void setName(String name) { this.name = name; } @@ -50,6 +52,7 @@ public abstract class AbstractRenderer extends AbstractPropertySource implements /** * {@inheritDoc} */ + @Override public String getDescription() { return description; } @@ -57,6 +60,7 @@ public abstract class AbstractRenderer extends AbstractPropertySource implements /** * {@inheritDoc} */ + @Override public void setDescription(String description) { this.description = description; } @@ -64,6 +68,7 @@ public abstract class AbstractRenderer extends AbstractPropertySource implements /** * {@inheritDoc} */ + @Override @Deprecated // use PropertySource.getPropertyDescriptors() instead public Map getPropertyDefinitions() { @@ -72,7 +77,7 @@ public abstract class AbstractRenderer extends AbstractPropertySource implements /** * Define a property. - * + * * @param name * The property name. * @param description @@ -90,6 +95,7 @@ public abstract class AbstractRenderer extends AbstractPropertySource implements /** * {@inheritDoc} */ + @Override public boolean isShowSuppressedViolations() { return showSuppressedViolations; } @@ -97,6 +103,7 @@ public abstract class AbstractRenderer extends AbstractPropertySource implements /** * {@inheritDoc} */ + @Override public void setShowSuppressedViolations(boolean showSuppressedViolations) { this.showSuppressedViolations = showSuppressedViolations; } @@ -104,6 +111,7 @@ public abstract class AbstractRenderer extends AbstractPropertySource implements /** * {@inheritDoc} */ + @Override public void setWriter(Writer writer) { this.writer = writer; } @@ -111,10 +119,12 @@ public abstract class AbstractRenderer extends AbstractPropertySource implements /** * {@inheritDoc} */ + @Override public Writer getWriter() { return writer; } + @Override public void flush() { try { this.writer.flush(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CSVRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CSVRenderer.java index a32bba3ee5..e4ae2c3927 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CSVRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CSVRenderer.java @@ -38,47 +38,47 @@ public class CSVRenderer extends AbstractIncrementingRenderer { @SuppressWarnings("unchecked") private static final ColumnDescriptor[] ALL_COLUMNS = new ColumnDescriptor[] { - new ColumnDescriptor<>("problem", "Problem", new Accessor() { - @Override - public String get(int idx, RuleViolation rv, String cr) { - return Integer.toString(idx); - } - }), new ColumnDescriptor<>("package", "Package", new Accessor() { - @Override - public String get(int idx, RuleViolation rv, String cr) { - return rv.getPackageName(); - } - }), new ColumnDescriptor<>("file", "File", new Accessor() { - @Override - public String get(int idx, RuleViolation rv, String cr) { - return rv.getFilename(); - } - }), new ColumnDescriptor<>("priority", "Priority", new Accessor() { - @Override - public String get(int idx, RuleViolation rv, String cr) { - return Integer.toString(rv.getRule().getPriority().getPriority()); - } - }), new ColumnDescriptor<>("line", "Line", new Accessor() { - @Override - public String get(int idx, RuleViolation rv, String cr) { - return Integer.toString(rv.getBeginLine()); - } - }), new ColumnDescriptor<>("desc", "Description", new Accessor() { - @Override - public String get(int idx, RuleViolation rv, String cr) { - return StringUtil.replaceString(rv.getDescription(), '\"', "'"); - } - }), new ColumnDescriptor<>("ruleSet", "Rule set", new Accessor() { - @Override - public String get(int idx, RuleViolation rv, String cr) { - return rv.getRule().getRuleSetName(); - } - }), new ColumnDescriptor<>("rule", "Rule", new Accessor() { - @Override - public String get(int idx, RuleViolation rv, String cr) { - return rv.getRule().getName(); - } - }) }; + new ColumnDescriptor<>("problem", "Problem", new Accessor() { + @Override + public String get(int idx, RuleViolation rv, String cr) { + return Integer.toString(idx); + } + }), new ColumnDescriptor<>("package", "Package", new Accessor() { + @Override + public String get(int idx, RuleViolation rv, String cr) { + return rv.getPackageName(); + } + }), new ColumnDescriptor<>("file", "File", new Accessor() { + @Override + public String get(int idx, RuleViolation rv, String cr) { + return rv.getFilename(); + } + }), new ColumnDescriptor<>("priority", "Priority", new Accessor() { + @Override + public String get(int idx, RuleViolation rv, String cr) { + return Integer.toString(rv.getRule().getPriority().getPriority()); + } + }), new ColumnDescriptor<>("line", "Line", new Accessor() { + @Override + public String get(int idx, RuleViolation rv, String cr) { + return Integer.toString(rv.getBeginLine()); + } + }), new ColumnDescriptor<>("desc", "Description", new Accessor() { + @Override + public String get(int idx, RuleViolation rv, String cr) { + return StringUtil.replaceString(rv.getDescription(), '\"', "'"); + } + }), new ColumnDescriptor<>("ruleSet", "Rule set", new Accessor() { + @Override + public String get(int idx, RuleViolation rv, String cr) { + return rv.getRule().getRuleSetName(); + } + }), new ColumnDescriptor<>("rule", "Rule", new Accessor() { + @Override + public String get(int idx, RuleViolation rv, String cr) { + return rv.getRule().getName(); + } + }), }; public CSVRenderer(ColumnDescriptor[] columns, String theSeparator, String theCR) { super(NAME, "Comma-separated values tabular format."); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateIssue.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateIssue.java index bf547481f4..51913fe710 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateIssue.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateIssue.java @@ -48,7 +48,7 @@ public class CodeClimateIssue { /** * Strip out all newlines from the body - * + * * @param {String} * body The text to compose the content from */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java index 5babb2d01e..ec5c75a11f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java @@ -4,6 +4,10 @@ package net.sourceforge.pmd.renderers; +import static net.sourceforge.pmd.renderers.CodeClimateRule.CODECLIMATE_BLOCK_HIGHLIGHTING; +import static net.sourceforge.pmd.renderers.CodeClimateRule.CODECLIMATE_CATEGORIES; +import static net.sourceforge.pmd.renderers.CodeClimateRule.CODECLIMATE_REMEDIATION_MULTIPLIER; + import java.io.IOException; import java.io.Writer; import java.util.Arrays; @@ -11,17 +15,13 @@ import java.util.Iterator; import org.apache.commons.lang3.StringUtils; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.PropertyDescriptor; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; -import static net.sourceforge.pmd.renderers.CodeClimateRule.CODECLIMATE_BLOCK_HIGHLIGHTING; -import static net.sourceforge.pmd.renderers.CodeClimateRule.CODECLIMATE_CATEGORIES; -import static net.sourceforge.pmd.renderers.CodeClimateRule.CODECLIMATE_REMEDIATION_MULTIPLIER; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; /** * Renderer for Code Climate JSON format @@ -64,7 +64,7 @@ public class CodeClimateRenderer extends AbstractIncrementingRenderer { /** * Generate a CodeClimateIssue suitable for processing into JSON from the * given RuleViolation. - * + * * @param rv * RuleViolation to convert. * @return The generated issue. @@ -88,6 +88,7 @@ public class CodeClimateRenderer extends AbstractIncrementingRenderer { issue.severity = "normal"; break; case LOW: + default: issue.severity = "info"; break; } @@ -177,8 +178,9 @@ public class CodeClimateRenderer extends AbstractIncrementingRenderer { PropertyDescriptor typed = (PropertyDescriptor) property; T value = rule.getProperty(typed); String propertyValue = typed.asDelimitedString(value); - if (propertyValue == null) + if (propertyValue == null) { propertyValue = ""; + } propertyValue = propertyValue.replaceAll("(\n|\r\n|\r)", "\\\\n"); String porpertyName = property.name(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRule.java index c198cb2fca..12af712af6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRule.java @@ -4,13 +4,13 @@ package net.sourceforge.pmd.renderers; +import static net.sourceforge.pmd.renderers.CodeClimateRenderer.REMEDIATION_POINTS_DEFAULT; + import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.lang.rule.properties.BooleanProperty; import net.sourceforge.pmd.lang.rule.properties.EnumeratedMultiProperty; import net.sourceforge.pmd.lang.rule.properties.IntegerProperty; -import static net.sourceforge.pmd.renderers.CodeClimateRenderer.REMEDIATION_POINTS_DEFAULT; - /** * This interface tags a Rule specifying properties required for the Code * Climate output format. Each rule implementing this interface must define the @@ -26,12 +26,12 @@ public interface CodeClimateRule extends Rule { * "https://github.com/codeclimate/spec/blob/master/SPEC.md#categories">Code * Climate Spec */ - EnumeratedMultiProperty CODECLIMATE_CATEGORIES = new EnumeratedMultiProperty("cc_categories", + EnumeratedMultiProperty CODECLIMATE_CATEGORIES = new EnumeratedMultiProperty<>("cc_categories", "Code Climate Categories", new String[] { "Bug Risk", "Clarity", "Compatibility", "Complexity", "Duplication", "Performance", - "Security", "Style" }, + "Security", "Style", }, new String[] { "Bug Risk", "Clarity", "Compatibility", "Complexity", "Duplication", "Performance", - "Security", "Style" }, + "Security", "Style", }, new int[] { 7 }, 1.0f); /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmacsRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmacsRenderer.java index aa1c83d5f2..388b1565b3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmacsRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmacsRenderer.java @@ -23,6 +23,7 @@ public class EmacsRenderer extends AbstractIncrementingRenderer { super(NAME, "GNU Emacs integration."); } + @Override public String defaultFileExtension() { return "emacs"; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java index 9b6543f692..9356caf5d3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java @@ -17,7 +17,7 @@ import net.sourceforge.pmd.util.StringUtil; /** * Renderer to basic HTML format. - * + * * FIXME: this class should just work with the XMLRenderer and then apply an * XSLT transformation + stylesheet. No need to hard-code HTML markup here. */ @@ -42,6 +42,7 @@ public class HTMLRenderer extends AbstractIncrementingRenderer { definePropertyDescriptor(LINE_PREFIX); } + @Override public String defaultFileExtension() { return "html"; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/IDEAJRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/IDEAJRenderer.java index 91a2e1e878..ba72a364fa 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/IDEAJRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/IDEAJRenderer.java @@ -40,6 +40,7 @@ public class IDEAJRenderer extends AbstractIncrementingRenderer { definePropertyDescriptor(CLASS_AND_METHOD_NAME); } + @Override public String defaultFileExtension() { return "txt"; } @@ -102,7 +103,7 @@ public class IDEAJRenderer extends AbstractIncrementingRenderer { private Set paths = new HashSet<>(); - public SourcePath(String sourcePathString) { + SourcePath(String sourcePathString) { for (StringTokenizer st = new StringTokenizer(sourcePathString, PATH_SEPARATOR); st.hasMoreTokens();) { paths.add(st.nextToken()); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/Renderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/Renderer.java index a5db38a6fc..58a0edbfd7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/Renderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/Renderer.java @@ -37,14 +37,14 @@ public interface Renderer extends PropertySource { /** * Get the name of the Renderer. - * + * * @return The name of the Renderer. */ String getName(); /** * Set the name of the Renderer. - * + * * @param name * The name of the Renderer. */ @@ -52,21 +52,21 @@ public interface Renderer extends PropertySource { /** * Get the description of the Renderer. - * + * * @return The description of the Renderer. */ String getDescription(); /** * Return the default filename extension to use. - * + * * @return String */ String defaultFileExtension(); /** * Set the description of the Renderer. - * + * * @param description * The description of the Renderer. */ @@ -76,7 +76,7 @@ public interface Renderer extends PropertySource { * Get the configuration property definitions for Renderer. The keys in the * map are the configuration property names, with the corresponding value * being a description. - * + * * @return The configuration property definition map. */ @Deprecated // use PropertySource.getPropertyDescriptors() instead @@ -84,7 +84,7 @@ public interface Renderer extends PropertySource { /** * Get the indicator for whether to show suppressed violations. - * + * * @return true if suppressed violations should show, * false otherwise. */ @@ -92,7 +92,7 @@ public interface Renderer extends PropertySource { /** * Set the indicator for whether to show suppressed violations. - * + * * @param showSuppressedViolations * Whether to show suppressed violations. */ @@ -100,14 +100,14 @@ public interface Renderer extends PropertySource { /** * Get the Writer for the Renderer. - * + * * @return The Writer. */ Writer getWriter(); /** * Set the Writer for the Renderer. - * + * * @param writer * The Writer. */ @@ -117,7 +117,7 @@ public interface Renderer extends PropertySource { * This method is called before any source files are processed. The Renderer * will have been fully initialized by the time this method is called, so * the Writer and other state will be available. - * + * * @throws IOException */ void start() throws IOException; @@ -126,11 +126,11 @@ public interface Renderer extends PropertySource { * This method is called each time a source file is processed. It is called * after {@link Renderer#start()}, but before * {@link Renderer#renderFileReport(Report)} and {@link Renderer#end()}. - * + * * This method may be invoked by different threads which are processing * files independently. Therefore, any non-trivial implementation of this * method needs to be thread-safe. - * + * * @param dataSource * The source file. */ @@ -142,11 +142,11 @@ public interface Renderer extends PropertySource { * after {@link Renderer#start()} and * {@link Renderer#startFileAnalysis(DataSource)}, but before * {@link Renderer#end()}. - * + * * @param report * A file Report. * @throws IOException - * + * * @see Report */ void renderFileReport(Report report) throws IOException; @@ -154,7 +154,7 @@ public interface Renderer extends PropertySource { /** * This method is at the very end of the Rendering process, after * {@link Renderer#renderFileReport(Report)}. - * + * * @throws IOException */ void end() throws IOException; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java index d38cc09aed..7ba1cbafbb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java @@ -18,7 +18,7 @@ import net.sourceforge.pmd.PropertyDescriptor; /** * This class handles the creation of Renderers. - * + * * @see Renderer */ public class RendererFactory { @@ -26,6 +26,7 @@ public class RendererFactory { private static final Logger LOG = Logger.getLogger(RendererFactory.class.getName()); public static final Map> REPORT_FORMAT_TO_RENDERER; + static { Map> map = new TreeMap<>(); map.put(CodeClimateRenderer.NAME, CodeClimateRenderer.class); @@ -46,7 +47,7 @@ public class RendererFactory { /** * Construct an instance of a Renderer based on report format name. - * + * * @param reportFormat * The report format name. * @param properties diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java index 1a5de414ba..38340759cb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java @@ -26,6 +26,7 @@ public class SummaryHTMLRenderer extends AbstractAccumulatingRenderer { definePropertyDescriptor(HTMLRenderer.LINE_PREFIX); } + @Override public String defaultFileExtension() { return "html"; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextColorRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextColorRenderer.java index ea3783ed33..ba17f86892 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextColorRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextColorRenderer.java @@ -25,7 +25,7 @@ import net.sourceforge.pmd.lang.rule.properties.StringProperty; * A console renderer with optional color support under *nix systems. *

    *

    - * + * *

      * * file: ./src/gilot/Test.java
      *     src:  Test.java:12
    @@ -83,6 +83,7 @@ public class TextColorRenderer extends AbstractAccumulatingRenderer {
             definePropertyDescriptor(COLOR);
         }
     
    +    @Override
         public String defaultFileExtension() {
             return "txt";
         }
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextPadRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextPadRenderer.java
    index 1cf8b09aa3..afd78db7fe 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextPadRenderer.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextPadRenderer.java
    @@ -48,6 +48,7 @@ public class TextPadRenderer extends AbstractIncrementingRenderer {
             super(NAME, "TextPad integration.");
         }
     
    +    @Override
         public String defaultFileExtension() {
             return "txt";
         }
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextRenderer.java
    index a79f0584d3..9a65a10094 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextRenderer.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextRenderer.java
    @@ -23,6 +23,7 @@ public class TextRenderer extends AbstractIncrementingRenderer {
             super(NAME, "Text format.");
         }
     
    +    @Override
         public String defaultFileExtension() {
             return "txt";
         }
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/VBHTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/VBHTMLRenderer.java
    index 86c268431e..a09659a99d 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/VBHTMLRenderer.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/VBHTMLRenderer.java
    @@ -14,7 +14,7 @@ import net.sourceforge.pmd.RuleViolation;
     
     /**
      * Renderer to another HTML format.
    - * 
    + *
      * @author Vladimir
      */
     public class VBHTMLRenderer extends AbstractIncrementingRenderer {
    @@ -25,6 +25,7 @@ public class VBHTMLRenderer extends AbstractIncrementingRenderer {
             super(NAME, "Vladimir Bossicard HTML format.");
         }
     
    +    @Override
         public String defaultFileExtension() {
             return "vb.html";
         }
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java
    index 439d62b064..68a3f7374e 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java
    @@ -37,6 +37,7 @@ public class XMLRenderer extends AbstractIncrementingRenderer {
             setProperty(ENCODING, encoding);
         }
     
    +    @Override
         public String defaultFileExtension() {
             return "xml";
         }
    @@ -75,8 +76,10 @@ public class XMLRenderer extends AbstractIncrementingRenderer {
             while (violations.hasNext()) {
                 buf.setLength(0);
                 RuleViolation rv = violations.next();
    -            if (!rv.getFilename().equals(filename)) { // New File
    -                if (filename != null) {// Not first file ?
    +            if (!rv.getFilename().equals(filename)) {
    +                // New File
    +                if (filename != null) {
    +                    // Not first file ?
                         buf.append("").append(PMD.EOL);
                     }
                     filename = rv.getFilename();
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XSLTRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XSLTRenderer.java
    index 12a5e17d9d..dac797eb00 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XSLTRenderer.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XSLTRenderer.java
    @@ -32,7 +32,7 @@ import net.sourceforge.pmd.lang.rule.properties.StringProperty;
     
     /**
      * Renderer to XML format with a XSL Transformation applied.
    - * 
    + *
      * @author Romain Pelisse, belaran@gmail.com
      */
     public class XSLTRenderer extends XMLRenderer {
    @@ -53,6 +53,7 @@ public class XSLTRenderer extends XMLRenderer {
             definePropertyDescriptor(XSLT_FILENAME);
         }
     
    +    @Override
         public String defaultFileExtension() {
             return "xsl";
         }
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/YAHTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/YAHTMLRenderer.java
    index f3b4021b24..576511e96b 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/YAHTMLRenderer.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/YAHTMLRenderer.java
    @@ -26,6 +26,7 @@ public class YAHTMLRenderer extends AbstractAccumulatingRenderer {
             definePropertyDescriptor(OUTPUT_DIR);
         }
     
    +    @Override
         public String defaultFileExtension() {
             return "html";
         }
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/stat/DataPoint.java b/pmd-core/src/main/java/net/sourceforge/pmd/stat/DataPoint.java
    index 3e50131ab2..d4ad758f2d 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/stat/DataPoint.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/stat/DataPoint.java
    @@ -10,7 +10,7 @@ import net.sourceforge.pmd.lang.ast.Node;
     
     /**
      * Datapoint used for rules that deal with metrics.
    - * 
    + *
      * @author David Dixon-Peugh
      * @since Aug 8, 2002
      */
    @@ -34,13 +34,14 @@ public class DataPoint implements Comparable {
     
         /**
          * Compares this data point with the given datapoint.
    -     * 
    +     *
          * @param rhs
          *            the other data point
          * @return 0 if equal; a value less than 0 if this point's score is smaller
          *         than the other data point; a value greater than 0 if this point's
          *         score is greater than the other data point.
          */
    +    @Override
         public int compareTo(DataPoint rhs) {
             if (score != rhs.getScore()) {
                 return Double.compare(score, rhs.getScore());
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/stat/Metric.java b/pmd-core/src/main/java/net/sourceforge/pmd/stat/Metric.java
    index 3fab02768e..2d3de2aa54 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/stat/Metric.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/stat/Metric.java
    @@ -20,7 +20,7 @@ public class Metric {
     
         /**
          * Creates a new metric with the given information.
    -     * 
    +     *
          * @param name
          *            the metric's name
          * @param count
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/ClassUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ClassUtil.java
    index 0be516ab91..e49bfecdc6 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/ClassUtil.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ClassUtil.java
    @@ -24,11 +24,11 @@ public final class ClassUtil {
     
         @SuppressWarnings("PMD.AvoidUsingShortType")
         private static final TypeMap PRIMITIVE_TYPE_NAMES = new TypeMap(new Class[] { int.class, byte.class, long.class,
    -            short.class, float.class, double.class, char.class, boolean.class, });
    +        short.class, float.class, double.class, char.class, boolean.class, });
     
         private static final TypeMap TYPES_BY_NAME = new TypeMap(
                 new Class[] { Integer.class, Byte.class, Long.class, Short.class, Float.class, Double.class,
    -                    Character.class, Boolean.class, BigDecimal.class, String.class, Object.class, Class.class });
    +                Character.class, Boolean.class, BigDecimal.class, String.class, Object.class, Class.class, });
     
         private static final Map, String> SHORT_NAMES_BY_TYPE = computeClassShortNames();
     
    @@ -88,7 +88,7 @@ public final class ClassUtil {
         /**
          * Return the name of the type in its short form if its known to us
          * otherwise return its name fully packaged.
    -     * 
    +     *
          * @param type
          * @return String
          */
    @@ -141,7 +141,7 @@ public final class ClassUtil {
     
         /**
          * Return the methods as a map keyed by their common declaration types.
    -     * 
    +     *
          * @param methods
          * @return Map>
          */
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java
    index d338b18772..962d16cac3 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java
    @@ -25,13 +25,13 @@ public final class CollectionUtil {
     
         @SuppressWarnings("PMD.UnnecessaryFullyQualifiedName")
         public static final TypeMap COLLECTION_INTERFACES_BY_NAMES = new TypeMap(new Class[] { java.util.List.class,
    -            java.util.Collection.class, java.util.Map.class, java.util.Set.class, });
    +        java.util.Collection.class, java.util.Map.class, java.util.Set.class, });
     
         @SuppressWarnings({ "PMD.LooseCoupling", "PMD.UnnecessaryFullyQualifiedName" })
         public static final TypeMap COLLECTION_CLASSES_BY_NAMES = new TypeMap(new Class[] { java.util.ArrayList.class,
    -            java.util.LinkedList.class, java.util.Vector.class, java.util.HashMap.class, java.util.LinkedHashMap.class,
    -            java.util.TreeMap.class, java.util.TreeSet.class, java.util.HashSet.class, java.util.LinkedHashSet.class,
    -            java.util.Hashtable.class });
    +        java.util.LinkedList.class, java.util.Vector.class, java.util.HashMap.class, java.util.LinkedHashMap.class,
    +        java.util.TreeMap.class, java.util.TreeSet.class, java.util.HashSet.class, java.util.LinkedHashSet.class,
    +        java.util.Hashtable.class, });
     
         private CollectionUtil() {
         }
    @@ -39,7 +39,7 @@ public final class CollectionUtil {
         /**
          * Add elements from the source to the target as long as they don't already
          * exist there. Return the number of items actually added.
    -     * 
    +     *
          * @param source
          * @param target
          * @return int
    @@ -238,7 +238,7 @@ public final class CollectionUtil {
     
         /**
          * Returns whether the items array is null or has zero length.
    -     * 
    +     *
          * @param items
          * @return boolean
          */
    @@ -248,7 +248,7 @@ public final class CollectionUtil {
     
         /**
          * Returns whether the items array is non-null and has at least one entry.
    -     * 
    +     *
          * @param items
          * @return boolean
          */
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/CompoundIterator.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/CompoundIterator.java
    index 1c87cfda66..c12d8f9b8d 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/CompoundIterator.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/CompoundIterator.java
    @@ -9,10 +9,10 @@ import java.util.NoSuchElementException;
     
     /**
      * Creates a single compound Iterator from an array of Iterators.
    - * 
    + *
      * @param 
      *            The type returned by the Iterator.
    - * 
    + *
      * @see Iterator
      */
     public class CompoundIterator implements Iterator {
    @@ -20,7 +20,7 @@ public class CompoundIterator implements Iterator {
         private int index;
     
         /**
    -     * 
    +     *
          * @param iterators
          *            The iterators use.
          */
    @@ -32,6 +32,7 @@ public class CompoundIterator implements Iterator {
         /**
          * {@inheritDoc}
          */
    +    @Override
         public boolean hasNext() {
             return getNextIterator() != null;
         }
    @@ -39,6 +40,7 @@ public class CompoundIterator implements Iterator {
         /**
          * {@inheritDoc}
          */
    +    @Override
         public T next() {
             Iterator iterator = getNextIterator();
             if (iterator != null) {
    @@ -51,6 +53,7 @@ public class CompoundIterator implements Iterator {
         /**
          * {@inheritDoc}
          */
    +    @Override
         public void remove() {
             Iterator iterator = getNextIterator();
             if (iterator != null) {
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/DateTimeUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/DateTimeUtil.java
    index 6cd9685ac2..155c2f2b77 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/DateTimeUtil.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/DateTimeUtil.java
    @@ -5,7 +5,7 @@
     package net.sourceforge.pmd.util;
     
     /**
    - * 
    + *
      * @author Brian Remedios
      */
     public final class DateTimeUtil {
    @@ -14,7 +14,7 @@ public final class DateTimeUtil {
         }
     
         /**
    -     * 
    +     *
          * @param milliseconds
          * @return String
          */
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/EmptyIterator.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/EmptyIterator.java
    index 10715e66ea..b503fb5569 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/EmptyIterator.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/EmptyIterator.java
    @@ -8,7 +8,7 @@ import java.util.Iterator;
     
     /**
      * A singleton iterator that never has anything.
    - * 
    + *
      * @author Brian Remedios
      *
      * @param 
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/FileIterable.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/FileIterable.java
    index ef3911aaa0..832707e21d 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/FileIterable.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/FileIterable.java
    @@ -34,6 +34,7 @@ public class FileIterable implements Iterable {
             }
         }
     
    +    @Override
         protected void finalize() throws Throwable {
             try {
                 if (lineReader != null) {
    @@ -45,6 +46,7 @@ public class FileIterable implements Iterable {
             super.finalize();
         }
     
    +    @Override
         public Iterator iterator() {
             return new FileIterator();
         }
    @@ -53,10 +55,12 @@ public class FileIterable implements Iterable {
     
             private boolean hasNext = true;
     
    +        @Override
             public boolean hasNext() {
                 return hasNext;
             }
     
    +        @Override
             public String next() {
                 String line = null;
                 try {
    @@ -73,6 +77,7 @@ public class FileIterable implements Iterable {
                 }
             }
     
    +        @Override
             public void remove() {
                 throw new UnsupportedOperationException("remove is not supported by " + this.getClass().getName());
             }
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/FileUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/FileUtil.java
    index 8bb183e5a8..d266f45e2b 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/FileUtil.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/FileUtil.java
    @@ -35,7 +35,7 @@ public final class FileUtil {
     
         /**
          * Helper method to get a filename without its extension
    -     * 
    +     *
          * @param fileName
          *            String
          * @return String
    @@ -54,7 +54,7 @@ public final class FileUtil {
         /**
          * Normalizes the filename by taking the casing into account, e.g. on
          * Windows, the filename is changed to lowercase only.
    -     * 
    +     *
          * @param fileName
          *            the file name
          * @return the normalized file name
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/IOUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/IOUtil.java
    index 852ccb1fa2..7e53b5d4c8 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/IOUtil.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/IOUtil.java
    @@ -16,7 +16,7 @@ import java.io.Writer;
     import org.apache.commons.io.IOUtils;
     
     /**
    - * 
    + *
      * @author Brian Remedios
      */
     public final class IOUtil {
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/ResourceLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ResourceLoader.java
    index 69f0f88462..937578cca8 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/ResourceLoader.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ResourceLoader.java
    @@ -18,6 +18,7 @@ import net.sourceforge.pmd.RuleSetNotFoundException;
     public final class ResourceLoader {
     
         public static final int TIMEOUT;
    +
         static {
             int timeoutProperty = 5000;
             try {
    @@ -39,7 +40,7 @@ public final class ResourceLoader {
          * Method to find a file, first by finding it as a file (either by the
          * absolute or relative path), then as a URL, and then finally seeing if it
          * is on the classpath.
    -     * 
    +     *
          * @param name
          *            String
          * @return InputStream
    @@ -57,7 +58,7 @@ public final class ResourceLoader {
         /**
          * Uses the ClassLoader passed in to attempt to load the resource if it's
          * not a File or a URL
    -     * 
    +     *
          * @param name
          *            String
          * @param loader
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java
    index 17bd33a3ed..7c5dc036d4 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java
    @@ -210,7 +210,7 @@ public final class StringUtil {
     
         /**
          * Replace some whitespace characters so they are visually apparent.
    -     * 
    +     *
          * @param o
          * @return String
          */
    @@ -257,7 +257,8 @@ public final class StringUtil {
             char c;
             for (int i = 0; i < src.length(); i++) {
                 c = src.charAt(i);
    -            if (c > '~') {// 126
    +            if (c > '~') {
    +                // 126
                     if (!supportUTF8) {
                         int codepoint = c;
                         // surrogate characters are not allowed in XML
    @@ -502,7 +503,7 @@ public final class StringUtil {
     
         /**
          * Left pads a string.
    -     * 
    +     *
          * @param s
          *            The String to pad
          * @param length
    @@ -590,7 +591,7 @@ public final class StringUtil {
     
         /**
          * Returns an empty array of string
    -     * 
    +     *
          * @return String
          */
         public static String[] getEmptyStrings() {
    diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBMSMetadata.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBMSMetadata.java
    index 5277f31e56..e3e5f37998 100644
    --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBMSMetadata.java
    +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBMSMetadata.java
    @@ -24,7 +24,7 @@ import java.util.logging.Logger;
     /**
      * Wrap JDBC connection for use by PMD: {@link DBURI} parameters specify the
      * source code to be passed to PMD.
    - * 
    + *
      * @author sturton
      */
     public class DBMSMetadata {
    @@ -42,7 +42,7 @@ public class DBMSMetadata {
         /**
          * Optional DBType property specifying a query to fetch the Source Objects
          * from the database.
    -     * 
    +     *
          * 

    * If the DBType lacks this property, then the standard * DatabaseMetaData.getProcedures method is used. @@ -53,7 +53,7 @@ public class DBMSMetadata { /** * Essential DBType property specifying a CallableStatement to retrieve the * Source Object's code from the database. - * + * *

    * If the DBType lacks this property, there is no DatabaseMetaData method * to fallback to. @@ -89,7 +89,7 @@ public class DBMSMetadata { /** * {@link java.sql.Types} value representing the type returned by * {@link callableStatement} - * + * * Currently only java.sql.Types.String and java.sql.Types.Clob are * supported */ @@ -98,7 +98,7 @@ public class DBMSMetadata { /* constructors */ /** * Minimal constructor - * + * * @param c * JDBC Connection * @throws SQLException @@ -110,7 +110,7 @@ public class DBMSMetadata { /** * Define database connection and source code to retrieve with explicit * database username and password. - * + * * @param user * Database username * @param password @@ -144,7 +144,7 @@ public class DBMSMetadata { /** * Define database connection and source code to retrieve with database * properties. - * + * * @param properties * database settings such as database username, password * @param dbURI @@ -177,11 +177,11 @@ public class DBMSMetadata { /** * Define database connection and source code to retrieve. - * + * *

    * This constructor is reliant on database username and password embedded in * the JDBC URL or defaulted from the {@link DBURI}'s {@link DriverType}. - * + * * @param user * Database username * @param password @@ -212,7 +212,7 @@ public class DBMSMetadata { /** * Return JDBC Connection for direct JDBC access to the specified database. - * + * * @return I=JDBC Connection * @throws SQLException */ @@ -244,7 +244,7 @@ public class DBMSMetadata { /** * Return source code text from the database. - * + * * @param source * object * @return source code @@ -257,7 +257,7 @@ public class DBMSMetadata { /** * return source code text - * + * * @param objectType * @param name * Source Code name @@ -299,7 +299,7 @@ public class DBMSMetadata { /** * Return all source code objects associated with any associated DBURI. - * + * * @return */ public List getSourceObjectList() { @@ -317,12 +317,12 @@ public class DBMSMetadata { /** * Return all source code objects associated with the specified languages, * schemas, source code types and source code names. - * + * *

    * Each parameter may be null and the appropriate field from any related * DBURI is assigned, defaulting to the normal SQL wildcard expression * ("%"). - * + * * @param languages * Optional list of languages to search for * @param schemas @@ -346,9 +346,9 @@ public class DBMSMetadata { /* * Assign each search list to the first - * + * * explicit parameter dburi field wildcard list - * + * */ if (null == searchLanguages) { List dbURIList = (null == dburi) ? null : dburi.getLanguagesList(); @@ -447,8 +447,8 @@ public class DBMSMetadata { } } } - } else // Use standard DatabaseMetaData interface - { + } else { + // Use standard DatabaseMetaData interface LOGGER.fine( "Have dbUri - no returnSourceCodeObjectsStatement, reverting to DatabaseMetaData.getProcedures(...)"); @@ -477,7 +477,7 @@ public class DBMSMetadata { * procedureReturnsResult - Returns a return value * SPECIFIC_NAME String => The name which uniquely * identifies this procedure within its schema. - * + * * Oracle getProcedures actually returns these 8 * columns:- ResultSet "Matched Procedures" has 8 * columns and contains ... diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBType.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBType.java index 25ec934137..1d8bd40e25 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBType.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBType.java @@ -19,8 +19,8 @@ import org.apache.commons.io.IOUtils; /** * Encapsulate the settings needed to access database source code. - * - * + * + * * @author sturton */ public class DBType { @@ -34,24 +34,23 @@ public class DBType { * The names of the properties */ public enum property { - USER("user", "Name of the connecting database user"), PASSWORD("password", - "The connecting database user's password"), DRIVER("driver", "JDBC driver classname"), CHARACTERSET( - "characterset", "Reader character set"), LANGUAGES("languages", - "Comma-separated list of PMD-supported languages"), SCHEMAS("schemas", - "SchemaSpy compatible regular expression for schemas to be processed"), SOURCE_TYPES( - "sourcecodetypes", - "Comma-separated list of supported source types"), SOURCE_NAMES( - "sourcecodenames", - "Default comma-separated list of source code names to validate"), GET_SOURCE_CODE_STATEMENT( - "getSourceCodeStatement", - "SQL92 or Oracle embedded SQL statement to retrieve code source from the database catalogue"), RETURN_TYPE( - "returnType", - "int equivalent of java.sql.Types return type of getSourceCodeStatement"); + USER("user", "Name of the connecting database user"), + PASSWORD("password", "The connecting database user's password"), + DRIVER("driver", "JDBC driver classname"), + CHARACTERSET("characterset", "Reader character set"), + LANGUAGES("languages", "Comma-separated list of PMD-supported languages"), + SCHEMAS("schemas", "SchemaSpy compatible regular expression for schemas to be processed"), + SOURCE_TYPES("sourcecodetypes", "Comma-separated list of supported source types"), + SOURCE_NAMES("sourcecodenames", "Default comma-separated list of source code names to validate"), + GET_SOURCE_CODE_STATEMENT( + "getSourceCodeStatement", + "SQL92 or Oracle embedded SQL statement to retrieve code source from the database catalogue"), + RETURN_TYPE("returnType", "int equivalent of java.sql.Types return type of getSourceCodeStatement"); private String name; private String description; - private property(String name, String description) { + property(String name, String description) { this.name = name; this.description = description; } @@ -91,7 +90,7 @@ public class DBType { private int sourceCodeReturnType; /** - * + * * @param dbType */ public DBType(String dbType) throws Exception { @@ -100,7 +99,7 @@ public class DBType { /** * Load the most specific dbType for the protocol - * + * * @param subProtocol * @param subnamePrefix * @throws IOException @@ -145,7 +144,7 @@ public class DBType { /** * Load properties from one or more files or resources. - * + * *

    * This method recursively finds property files or JAR resources matching * {@matchstring}. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBURI.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBURI.java index 94de62ccb9..d7805498c0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBURI.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBURI.java @@ -29,11 +29,11 @@ import java.util.logging.Logger; * A DBURI is a faux-URI: it does not have a formal specification and * comprises a JDBC(-ish) URL and an optional query, e.g. * jdbc : subprotocol [ : subname ] : connection details [ query ] . - * + * * The subprotocol and optional subname parts should be a valid DBType * JDBC(-ish) URL jdbc:oracle:thin:username/password@//192.168.100.21:1521/ORCL * JDBC(-ish) URL jdbc:thin:username/password@//192.168.100.21:1521/ORCL - * + * *

    * The query includes one or more of these:- *

    @@ -49,7 +49,7 @@ import java.util.logging.Logger; *
    comma-separated list of database source code names
    *
    *

    - * + * * @see http://docs.oracle.com/javase/7/docs/api/java/net/URI.html * @author sturton */ @@ -61,7 +61,7 @@ public class DBURI { /** * A JDBC URL with an associated query. - * + * * Formats: jdbc:oracle:thin:[/]@//[:]/ * jdbc:oracle:oci:[/]@//[:]/ * @@ -122,7 +122,7 @@ public class DBURI { /** * Create DBURI from a string, combining a JDBC URL and query parameters. - * + * *

    * From the JDBC URL component, infer:- *

      @@ -132,7 +132,7 @@ public class DBURI { *
    • default schemas
    • *
    *

    - * + * *

    * From the query component, define these values, overriding any defaults:- *

      @@ -142,7 +142,7 @@ public class DBURI { *
    • source code
    • *
    *

    - * + * * @param string * URL string * @throws URISyntaxException @@ -151,7 +151,7 @@ public class DBURI { public DBURI(String string) throws URISyntaxException { /* * A JDBC URL is an opaque URL and does not have a query. - * + * * We pretend that it does, strip off the query, use the real JDBC URL * component to infer languages JDBC driver class supported languages * default source code types default schemas generate a faux HTTP URI @@ -224,7 +224,7 @@ public class DBURI { /** * Create a DBURI from standard individual {@link URI} components. - * + * *

    * From the JDBC URL components, infer:- *

      @@ -234,7 +234,7 @@ public class DBURI { *
    • default schemas
    • *
    *

    - * + * *

    * From the query component, define these values, overriding any defaults:- *

      @@ -244,7 +244,7 @@ public class DBURI { *
    • source code
    • *
    *

    - * + * * @param scheme * @param userInfo * @param host @@ -262,7 +262,7 @@ public class DBURI { /** * Return extracted parameters from dburi. - * + * * @param dburi * @return extracted parameters * @throws UnsupportedEncodingException @@ -289,7 +289,7 @@ public class DBURI { /** * Dump this URI to the log. - * + * * @param description * @param dburi */ @@ -433,7 +433,7 @@ public class DBURI { /** * Populate the URI and query collections from the original string - * + * * @throws URISyntaxException * @throws IOException */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/ResourceLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/ResourceLoader.java index 29cdebb5a0..461c3f5f94 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/ResourceLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/ResourceLoader.java @@ -8,7 +8,7 @@ import java.io.InputStream; /** * Helper class for retrieving resources relative to the installation. - * + * * @author Stuart Turton */ public class ResourceLoader { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/ResourceResolver.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/ResourceResolver.java index bb8e200864..233157831b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/ResourceResolver.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/ResourceResolver.java @@ -14,15 +14,14 @@ public class ResourceResolver implements URIResolver { public Source resolve(String href, String base) throws TransformerException { if (null == href || href.length() == 0) { return null; // will make Oracle XSLT processor explode, - // even though it's correct + // even though it's correct } try { String resource = href; ResourceLoader loader = new ResourceLoader(); return new StreamSource(loader.getResourceStream(resource), resource); - } // try - catch (Exception ex) { + } catch (Exception ex) { throw new TransformerException(ex); - } // catch - } // resolve -} // ResourceResolver + } + } +} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/SourceObject.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/SourceObject.java index 2dcf8052a5..7b1d6f2025 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/SourceObject.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/SourceObject.java @@ -21,14 +21,14 @@ public class SourceObject { /** * Database Schema/Owner - SYS,SYSTEM,SCOTT - * + * */ String schema; /** * Source Code Name - DBMS_METADATA - * + * */ String name; @@ -36,14 +36,14 @@ public class SourceObject { /** * Source Code Type - * FUNCTION,PROCEDURE,TRIGGER,PACKAGE,PACKAGE_BODY,TYPE,TYPE_BODY,JAVA_SOURCE. - * + * */ String type; /** * Source Code Revision - Optional revision/version - * + * */ String revision; @@ -123,11 +123,11 @@ public class SourceObject { /** * Map the type to a file suffix associated with a {@link Language} - * + * * @return inferred suffix */ public String getSuffixFromType() { - LOG.entering(CLASS_NAME, "getSuffixFromType", this);// .entering("type="+type.toUpperCase()); + LOG.entering(CLASS_NAME, "getSuffixFromType", this); if (null == type || type.isEmpty()) { return ""; } else if (type.toUpperCase().indexOf("JAVA") >= 0) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/FileDataSource.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/FileDataSource.java index 4477975c94..804d6c6522 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/FileDataSource.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/FileDataSource.java @@ -26,10 +26,12 @@ public class FileDataSource implements DataSource { this.file = file; } + @Override public InputStream getInputStream() throws IOException { return new FileInputStream(file); } + @Override public String getNiceFileName(boolean shortNames, String inputFileName) { return glomName(shortNames, inputFileName, file); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ReaderDataSource.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ReaderDataSource.java index 186a6e7fbd..fe8d819a59 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ReaderDataSource.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ReaderDataSource.java @@ -21,7 +21,7 @@ public class ReaderDataSource implements DataSource { /** * Real or pseudo filename or path name. - * + * *

    * Including a file suffix mapped to the correct language helps assign the * correct parser. @@ -42,7 +42,7 @@ public class ReaderDataSource implements DataSource { *

    * Note: This uses the default encoding. *

    - * + * * @return Derived InputStream * @throws IOException */ @@ -53,11 +53,11 @@ public class ReaderDataSource implements DataSource { /** * Return the dataSourceName via the {@link DataSource} Interface method. - * + * *

    * Both the parameters are ignored *

    - * + * * @param shortNames * ignored * @param inputFileName diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ZipDataSource.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ZipDataSource.java index 0803622439..7667f7705a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ZipDataSource.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ZipDataSource.java @@ -27,10 +27,12 @@ public class ZipDataSource implements DataSource { this.zipEntry = zipEntry; } + @Override public InputStream getInputStream() throws IOException { return zipFile.getInputStream(zipEntry); } + @Override public String getNiceFileName(boolean shortNames, String inputFileName) { // FIXME: this could probably be done better return zipFile.getName() + ":" + zipEntry.getName(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/CodeEditorTextPane.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/CodeEditorTextPane.java index 7dacf44394..cfa96661a8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/CodeEditorTextPane.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/CodeEditorTextPane.java @@ -15,6 +15,7 @@ public class CodeEditorTextPane extends JTextPane implements LineGetter { return getText().split("\r\n|\r|\n"); } + @Override public String getLine(int number) { String[] lines = getLines(); if (number < lines.length) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/DFAPanel.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/DFAPanel.java index e5850fdd9d..9430ef1829 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/DFAPanel.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/DFAPanel.java @@ -245,7 +245,7 @@ public class DFAPanel extends JComponent implements ListSelectionListener { private static class ElementWrapper { private DFAGraphMethod node; - public ElementWrapper(DFAGraphMethod node) { + ElementWrapper(DFAGraphMethod node) { this.node = node; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/Designer.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/Designer.java index 2226690ab2..33f6852b96 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/Designer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/designer/Designer.java @@ -167,7 +167,7 @@ public class Designer implements ClipboardOwner { JMenuBar menuBar = createMenuBar(); frame.setJMenuBar(menuBar); frame.getContentPane().add(containerSplitPane); - frame.setDefaultCloseOperation(exitOnClose ? JFrame.EXIT_ON_CLOSE : JFrame.DISPOSE_ON_CLOSE); + frame.setDefaultCloseOperation(exitOnClose ? JFrame.EXIT_ON_CLOSE : WindowConstants.DISPOSE_ON_CLOSE); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int screenHeight = screenSize.height; @@ -258,7 +258,7 @@ public class Designer implements ClipboardOwner { private Object item; private ExceptionNode[] kids; - public ExceptionNode(Object theItem) { + ExceptionNode(Object theItem) { item = theItem; if (item instanceof ParseException) { @@ -344,7 +344,7 @@ public class Designer implements ClipboardOwner { private ASTTreeNode parent; private ASTTreeNode[] kids; - public ASTTreeNode(Node theNode) { + ASTTreeNode(Node theNode) { node = theNode; Node parent = node.jjtGetParent(); @@ -469,7 +469,7 @@ public class Designer implements ClipboardOwner { private static final long serialVersionUID = 1L; - public TreeWidget(Object[] items) { + TreeWidget(Object[] items) { super(items); setToolTipText(""); } @@ -940,7 +940,7 @@ public class Designer implements ClipboardOwner { codeEditorPane.setText(text); } - private final String getXmlTreeCode() { + private String getXmlTreeCode() { if (codeEditorPane.getText() != null && codeEditorPane.getText().trim().length() > 0) { Node cu = getCompilationUnit(); return getXmlTreeCode(cu); @@ -961,7 +961,7 @@ public class Designer implements ClipboardOwner { return xml; } - private final void copyXmlToClipboard() { + private void copyXmlToClipboard() { String xml = getXmlTreeCode(); if (xml != null) { Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(xml), this); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/AbstractCompoundFilter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/AbstractCompoundFilter.java index 029e086fff..18c0f86d18 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/AbstractCompoundFilter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/AbstractCompoundFilter.java @@ -11,7 +11,7 @@ import java.util.List; /** * A base class for Filters which implements behavior using a List of other * Filters. - * + * * @param * The underlying type on which the filter applies. */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/AbstractDelegateFilter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/AbstractDelegateFilter.java index ad15ec854a..cb0589a6ec 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/AbstractDelegateFilter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/AbstractDelegateFilter.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd.util.filter; /** * A base class for Filters which implements behavior using delegation to an * underlying filter. - * + * * @param * The underlying type on which the filter applies. */ @@ -30,11 +30,13 @@ public abstract class AbstractDelegateFilter implements Filter { } // Subclass should override to do something other the simply delegate. + @Override public boolean filter(T obj) { return filter.filter(obj); } // Subclass should override to do something other the simply delegate. + @Override public String toString() { return filter.toString(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/AndFilter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/AndFilter.java index 3e66b230c7..1a6076c9c2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/AndFilter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/AndFilter.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.util.filter; /** * A logical AND of a list of Filters. This implementation is short circuiting. - * + * * @param * The underlying type on which the filter applies. */ @@ -20,6 +20,7 @@ public class AndFilter extends AbstractCompoundFilter { super(filters); } + @Override public boolean filter(T obj) { boolean match = true; for (Filter filter : filters) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/DirectoryFilter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/DirectoryFilter.java index a6a2a229e0..2e377de150 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/DirectoryFilter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/DirectoryFilter.java @@ -15,10 +15,12 @@ public final class DirectoryFilter implements Filter { private DirectoryFilter() { } + @Override public boolean filter(File file) { return file.isDirectory(); } + @Override public String toString() { return "is Directory"; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/FileExtensionFilter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/FileExtensionFilter.java index c10b463873..252d6adab0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/FileExtensionFilter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/FileExtensionFilter.java @@ -30,6 +30,7 @@ public class FileExtensionFilter implements Filter { } } + @Override public boolean filter(File file) { boolean accept = extensions == null; if (!accept) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/Filter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/Filter.java index 91c16da122..de6364d2aa 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/Filter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/Filter.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.util.filter; /** * A Filter interface, used for filtering arbitrary objects. - * + * * @param * The underlying type on which the filter applies. */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/Filters.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/Filters.java index cdeffaa8de..d418fd9d4b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/Filters.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/Filters.java @@ -18,7 +18,7 @@ public class Filters { /** * Filter a given Collection. - * + * * @param * Type of the Collection. * @param filter @@ -40,7 +40,7 @@ public class Filters { /** * Get a File Filter for files with the given extensions, ignoring case. - * + * * @param extensions * The extensions to filter. * @return A File Filter. @@ -51,7 +51,7 @@ public class Filters { /** * Get a File Filter for directories. - * + * * @return A File Filter. */ public static Filter getDirectoryFilter() { @@ -61,7 +61,7 @@ public class Filters { /** * Get a File Filter for directories or for files with the given extensions, * ignoring case. - * + * * @param extensions * The extensions to filter. * @return A File Filter. @@ -75,19 +75,21 @@ public class Filters { * normalized to a standard pattern using / as a path separator * which can be used cross platform easily in a regular expression based * String Filter. - * + * * @param filter * A String Filter. * @return A File Filter. */ public static Filter toNormalizedFileFilter(final Filter filter) { return new Filter() { + @Override public boolean filter(File file) { String path = file.getPath(); path = path.replace('\\', '/'); return filter.filter(path); } + @Override public String toString() { return filter.toString(); } @@ -98,7 +100,7 @@ public class Filters { * Given a String Filter, expose as a Filter on another type. The * toString() method is called on the objects of the other type * and delegated to the String Filter. - * + * * @param * The desired type. * @param filter @@ -107,10 +109,12 @@ public class Filters { */ public static Filter fromStringFilter(final Filter filter) { return new Filter() { + @Override public boolean filter(T obj) { return filter.filter(obj.toString()); } + @Override public String toString() { return filter.toString(); } @@ -119,17 +123,19 @@ public class Filters { /** * Given a File Filter, expose as a FilenameFilter. - * + * * @param filter * The File Filter. * @return A FilenameFilter. */ public static FilenameFilter toFilenameFilter(final Filter filter) { return new FilenameFilter() { + @Override public boolean accept(File dir, String name) { return filter.filter(new File(dir, name)); } + @Override public String toString() { return filter.toString(); } @@ -138,17 +144,19 @@ public class Filters { /** * Given a FilenameFilter, expose as a File Filter. - * + * * @param filter * The FilenameFilter. * @return A File Filter. */ public static Filter toFileFilter(final FilenameFilter filter) { return new Filter() { + @Override public boolean filter(File file) { return filter.accept(file.getParentFile(), file.getName()); } + @Override public String toString() { return filter.toString(); } @@ -163,7 +171,7 @@ public class Filters { * and does not match an exclude regular expression. *

    * In other words, exclude patterns override include patterns. - * + * * @param includeRegexes * The include regular expressions. May be null. * @param excludeRegexes @@ -199,7 +207,7 @@ public class Filters { * matches or there is not an exclude which matches. *

    * In other words, include patterns override exclude patterns. - * + * * @param includeRegexes * The include regular expressions. May be null. * @param excludeRegexes diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/NotFilter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/NotFilter.java index e71a3fdb9d..31d3aa81a9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/NotFilter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/NotFilter.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.util.filter; /** * A logical NEGATION of a Filter. - * + * * @param * The underlying type on which the filter applies. */ @@ -19,10 +19,12 @@ public class NotFilter extends AbstractDelegateFilter { super(filter); } + @Override public boolean filter(T obj) { return !filter.filter(obj); } + @Override public String toString() { return "not (" + filter + ")"; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/OrFilter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/OrFilter.java index 1efed55e22..571f3c68be 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/OrFilter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/OrFilter.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.util.filter; /** * A logical OR of a list of Filters. This implementation is short circuiting. - * + * * @param * The underlying type on which the filter applies. */ @@ -20,6 +20,7 @@ public class OrFilter extends AbstractCompoundFilter { super(filters); } + @Override public boolean filter(T obj) { boolean match = false; for (Filter filter : filters) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/RegexStringFilter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/RegexStringFilter.java index 044e7a1ad5..b655aaf0a6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/RegexStringFilter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/filter/RegexStringFilter.java @@ -25,12 +25,12 @@ public class RegexStringFilter implements Filter { * may or may not be preceded by a {@code \} escape. The literal path * portion is determine by the absence of any of the following characters: * \ [ ( . * ? + | { $ - * + * * There are two capturing groups in the expression. The first is for the * literal path. The second is for the file extension, without the escaping. * The concatenation of these two captures creates the {@link String} which * can be used with {@link String#endsWith(String)}. - * + * * For ease of reference, the non-Java escaped form of this pattern is: * \^?\.\*([^\\\[\(\.\*\?\+\|\{\$]+)(?:\\?(\.\w+))?\$? */ @@ -74,6 +74,7 @@ public class RegexStringFilter implements Filter { } } + @Override public boolean filter(String obj) { if (this.endsWith != null) { return obj.endsWith(this.endsWith); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/AntLogHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/AntLogHandler.java index 04870762cb..fe15dba444 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/AntLogHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/AntLogHandler.java @@ -16,7 +16,7 @@ import org.apache.tools.ant.Project; /** * AntLogHandler sends log messages to an Ant Task, so the regular Ant logging * is used. - * + * * @author Wouter Zelle */ public class AntLogHandler extends Handler { @@ -28,16 +28,17 @@ public class AntLogHandler extends Handler { this.project = project; } + @Override public void publish(LogRecord logRecord) { // Map the log levels from java.util.logging to Ant int antLevel; Level level = logRecord.getLevel(); if (level == Level.FINEST) { antLevel = Project.MSG_DEBUG; // Shown when -debug is supplied to - // Ant + // Ant } else if (level == Level.FINE || level == Level.FINER || level == Level.CONFIG) { antLevel = Project.MSG_VERBOSE; // Shown when -verbose is supplied - // to Ant + // to Ant } else if (level == Level.INFO) { antLevel = Project.MSG_INFO; // Always shown } else if (level == Level.WARNING) { @@ -46,8 +47,8 @@ public class AntLogHandler extends Handler { antLevel = Project.MSG_ERR; // Always shown } else { throw new IllegalStateException("Unknown logging level"); // shouldn't - // get ALL - // or NONE + // get ALL + // or NONE } project.log(FORMATTER.format(logRecord), antLevel); @@ -59,9 +60,11 @@ public class AntLogHandler extends Handler { } } + @Override public void close() throws SecurityException { } + @Override public void flush() { } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/ConsoleLogHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/ConsoleLogHandler.java index 536f6c6b6c..1092dddb5d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/ConsoleLogHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/ConsoleLogHandler.java @@ -12,13 +12,14 @@ import java.util.logging.LogRecord; /** * Log to the console using a basic formatter. - * + * * @author Wouter Zelle */ public class ConsoleLogHandler extends Handler { private static final Formatter FORMATTER = new PmdLogFormatter(); + @Override public void publish(LogRecord logRecord) { System.out.println(FORMATTER.format(logRecord)); if (logRecord.getThrown() != null) { @@ -32,9 +33,11 @@ public class ConsoleLogHandler extends Handler { } } + @Override public void close() throws SecurityException { } + @Override public void flush() { } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/ASTPanel.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/ASTPanel.java index 56d1f40357..778b4c2558 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/ASTPanel.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/ASTPanel.java @@ -58,6 +58,7 @@ public class ASTPanel extends JPanel implements ViewerModelListener, TreeSelecti tree = new JTree((TreeNode) null); tree.addTreeSelectionListener(this); tree.addMouseListener(new MouseAdapter() { + @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY()); @@ -74,6 +75,7 @@ public class ASTPanel extends JPanel implements ViewerModelListener, TreeSelecti /** * @see ViewerModelListener#viewerModelChanged(ViewerModelEvent) */ + @Override public void viewerModelChanged(ViewerModelEvent e) { switch (e.getReason()) { case ViewerModelEvent.CODE_RECOMPILED: @@ -100,6 +102,7 @@ public class ASTPanel extends JPanel implements ViewerModelListener, TreeSelecti /** * @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent) */ + @Override public void valueChanged(TreeSelectionEvent e) { model.selectNode((Node) e.getNewLeadSelectionPath().getLastPathComponent(), this); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/EvaluationResultsPanel.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/EvaluationResultsPanel.java index 36b01cccb8..de6dd42be0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/EvaluationResultsPanel.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/EvaluationResultsPanel.java @@ -50,6 +50,7 @@ public class EvaluationResultsPanel extends JPanel implements ViewerModelListene list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.addListSelectionListener(new ListSelectionListener() { + @Override public void valueChanged(ListSelectionEvent e) { if (list.getSelectedValue() != null) { model.selectNode((Node) list.getSelectedValue(), EvaluationResultsPanel.this); @@ -63,6 +64,7 @@ public class EvaluationResultsPanel extends JPanel implements ViewerModelListene /** * @see ViewerModelListener#viewerModelChanged(ViewerModelEvent) */ + @Override @SuppressWarnings("PMD.UseArrayListInsteadOfVector") public void viewerModelChanged(ViewerModelEvent e) { switch (e.getReason()) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/MainFrame.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/MainFrame.java index 1a366e1e15..f6ef38715b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/MainFrame.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/MainFrame.java @@ -19,6 +19,7 @@ import javax.swing.JPanel; import javax.swing.JRadioButtonMenuItem; import javax.swing.JSplitPane; import javax.swing.SwingConstants; +import javax.swing.WindowConstants; import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.lang.LanguageRegistry; @@ -115,7 +116,7 @@ public class MainFrame extends JFrame implements ActionListener, ViewerModelList menuBar.add(menu); setJMenuBar(menuBar); - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); pack(); setSize(800, 600); setVisible(true); @@ -143,6 +144,7 @@ public class MainFrame extends JFrame implements ActionListener, ViewerModelList /** * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ + @Override public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); long t0; @@ -184,6 +186,7 @@ public class MainFrame extends JFrame implements ActionListener, ViewerModelList /** * @see ViewerModelListener#viewerModelChanged(ViewerModelEvent) */ + @Override public void viewerModelChanged(ViewerModelEvent e) { evalBtn.setEnabled(model.hasCompiledTree()); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/ParseExceptionHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/ParseExceptionHandler.java index 24faf7f9fd..c78b268c45 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/ParseExceptionHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/ParseExceptionHandler.java @@ -68,6 +68,7 @@ public class ParseExceptionHandler extends JDialog implements ActionListener { /** * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ + @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == okBtn) { dispose(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/SourceCodePanel.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/SourceCodePanel.java index e958d7dd0f..35f6126627 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/SourceCodePanel.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/SourceCodePanel.java @@ -60,10 +60,12 @@ public class SourceCodePanel extends JPanel implements ViewerModelListener { /** * @see ViewerModelListener#viewerModelChanged(ViewerModelEvent) */ + @Override public void viewerModelChanged(ViewerModelEvent e) { if (e.getReason() == ViewerModelEvent.NODE_SELECTED) { final Node node = (Node) e.getParameter(); SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { try { sourceCodeArea.getHighlighter().removeAllHighlights(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/XPathPanel.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/XPathPanel.java index b6457427a2..3cf6b421b4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/XPathPanel.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/XPathPanel.java @@ -10,6 +10,7 @@ import javax.swing.BorderFactory; import javax.swing.JScrollPane; import javax.swing.JTabbedPane; import javax.swing.JTextArea; +import javax.swing.SwingConstants; import net.sourceforge.pmd.util.viewer.model.ViewerModel; import net.sourceforge.pmd.util.viewer.model.ViewerModelEvent; @@ -34,7 +35,7 @@ public class XPathPanel extends JTabbedPane implements ViewerModelListener { * model to refer to */ public XPathPanel(ViewerModel model) { - super(JTabbedPane.BOTTOM); + super(SwingConstants.BOTTOM); this.model = model; init(); } @@ -55,6 +56,7 @@ public class XPathPanel extends JTabbedPane implements ViewerModelListener { /** * @see ViewerModelListener#viewerModelChanged(ViewerModelEvent) */ + @Override public void viewerModelChanged(ViewerModelEvent e) { switch (e.getReason()) { case ViewerModelEvent.PATH_EXPRESSION_APPENDED: diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/menu/XPathFragmentAddingItem.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/menu/XPathFragmentAddingItem.java index ebd3f0d32e..aac92d912f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/menu/XPathFragmentAddingItem.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/gui/menu/XPathFragmentAddingItem.java @@ -41,6 +41,7 @@ public class XPathFragmentAddingItem extends JMenuItem implements ActionListener /** * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ + @Override public void actionPerformed(ActionEvent e) { model.appendToXPathExpression(fragment, this); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/model/ASTModel.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/model/ASTModel.java index b26fbd5506..de0f82f7de 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/model/ASTModel.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/model/ASTModel.java @@ -39,6 +39,7 @@ public class ASTModel implements TreeModel { /** * @see javax.swing.tree.TreeModel */ + @Override public Object getChild(Object parent, int index) { return ((Node) parent).jjtGetChild(index); } @@ -46,6 +47,7 @@ public class ASTModel implements TreeModel { /** * @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object) */ + @Override public int getChildCount(Object parent) { return ((Node) parent).jjtGetNumChildren(); } @@ -53,6 +55,7 @@ public class ASTModel implements TreeModel { /** * @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object,java.lang.Object) */ + @Override public int getIndexOfChild(Object parent, Object child) { Node node = (Node) parent; for (int i = 0; i < node.jjtGetNumChildren(); i++) { @@ -66,6 +69,7 @@ public class ASTModel implements TreeModel { /** * @see javax.swing.tree.TreeModel#isLeaf(java.lang.Object) */ + @Override public boolean isLeaf(Object node) { return ((Node) node).jjtGetNumChildren() == 0; } @@ -73,6 +77,7 @@ public class ASTModel implements TreeModel { /** * @see javax.swing.tree.TreeModel#getRoot() */ + @Override public Object getRoot() { return root; } @@ -80,6 +85,7 @@ public class ASTModel implements TreeModel { /** * @see javax.swing.tree.TreeModel#valueForPathChanged(javax.swing.tree.TreePath,java.lang.Object) */ + @Override public void valueForPathChanged(TreePath path, Object newValue) { throw new UnsupportedOperationException(); } @@ -87,6 +93,7 @@ public class ASTModel implements TreeModel { /** * @see javax.swing.tree.TreeModel#addTreeModelListener(javax.swing.event.TreeModelListener) */ + @Override public void addTreeModelListener(TreeModelListener l) { listeners.add(l); } @@ -94,6 +101,7 @@ public class ASTModel implements TreeModel { /** * @see javax.swing.tree.TreeModel#removeTreeModelListener(javax.swing.event.TreeModelListener) */ + @Override public void removeTreeModelListener(TreeModelListener l) { listeners.remove(l); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/model/SimpleNodeTreeNodeAdapter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/model/SimpleNodeTreeNodeAdapter.java index 87e4cd0b48..6190948ba0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/model/SimpleNodeTreeNodeAdapter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/viewer/model/SimpleNodeTreeNodeAdapter.java @@ -49,6 +49,7 @@ public class SimpleNodeTreeNodeAdapter implements TreeNode { /** * @see javax.swing.tree.TreeNode#getChildAt(int) */ + @Override public TreeNode getChildAt(int childIndex) { checkChildren(); return children.get(childIndex); @@ -57,6 +58,7 @@ public class SimpleNodeTreeNodeAdapter implements TreeNode { /** * @see javax.swing.tree.TreeNode#getChildCount() */ + @Override public int getChildCount() { checkChildren(); return children.size(); @@ -65,6 +67,7 @@ public class SimpleNodeTreeNodeAdapter implements TreeNode { /** * @see javax.swing.tree.TreeNode#getParent() */ + @Override public TreeNode getParent() { return parent; } @@ -72,6 +75,7 @@ public class SimpleNodeTreeNodeAdapter implements TreeNode { /** * @see javax.swing.tree.TreeNode#getIndex(javax.swing.tree.TreeNode) */ + @Override public int getIndex(TreeNode node) { checkChildren(); return children.indexOf(node); @@ -80,6 +84,7 @@ public class SimpleNodeTreeNodeAdapter implements TreeNode { /** * @see javax.swing.tree.TreeNode#getAllowsChildren() */ + @Override public boolean getAllowsChildren() { return true; } @@ -88,6 +93,7 @@ public class SimpleNodeTreeNodeAdapter implements TreeNode { * @see javax.swing.tree.TreeNode#isLeaf() */ + @Override public boolean isLeaf() { checkChildren(); return children.isEmpty(); @@ -97,6 +103,7 @@ public class SimpleNodeTreeNodeAdapter implements TreeNode { * @see javax.swing.tree.TreeNode#children() */ + @Override public Enumeration children() { return Collections.enumeration(children); } @@ -116,6 +123,7 @@ public class SimpleNodeTreeNodeAdapter implements TreeNode { /** * @see java.lang.Object#toString() */ + @Override public String toString() { return node.toString(); } diff --git a/pmd-core/src/main/resources/net/sourceforge/pmd/util/viewer/resources/viewer_strings.properties b/pmd-core/src/main/resources/net/sourceforge/pmd/util/viewer/resources/viewer_strings.properties index e5b8bbcc2f..8816c661db 100644 --- a/pmd-core/src/main/resources/net/sourceforge/pmd/util/viewer/resources/viewer_strings.properties +++ b/pmd-core/src/main/resources/net/sourceforge/pmd/util/viewer/resources/viewer_strings.properties @@ -8,31 +8,31 @@ ########################################################################## # Main Frame -MAIN.FRAME.TITLE = AST Viewer -MAIN.FRAME.COMPILE_BUTTON.TITLE = Compile -MAIN.FRAME.EVALUATE_BUTTON.TITLE = Evaluate XPath Expression -MAIN.FRAME.COMPILATION.TOOK = Compilation took -MAIN.FRAME.COMPILATION.PROBLEM = Compilation problem: -MAIN.FRAME.EVALUATION.TOOK = Evaluation took -MAIN.FRAME.EVALUATION.PROBLEM = Evaluation problem: +MAIN.FRAME.TITLE = AST Viewer +MAIN.FRAME.COMPILE_BUTTON.TITLE = Compile +MAIN.FRAME.EVALUATE_BUTTON.TITLE = Evaluate XPath Expression +MAIN.FRAME.COMPILATION.TOOK = Compilation took +MAIN.FRAME.COMPILATION.PROBLEM = Compilation problem: +MAIN.FRAME.EVALUATION.TOOK = Evaluation took +MAIN.FRAME.EVALUATION.PROBLEM = Evaluation problem: # Source Panel -SOURCE.PANEL.TITLE = Source code +SOURCE.PANEL.TITLE = Source code # Tree Panel -AST.PANEL.TITLE = Abstract Syntax Tree -AST.MENU.ATTRIBUTES = Add predicate from {0}'a attributes -AST.MENU.NODE.TITLE = Add {0} to the XPath expression -AST.MENU.NODE.ADD_ABSOLUTE_PATH = Add with absolute path -AST.MENU.NODE.ADD_ALLDESCENDANTS = Add all descendants of this type +AST.PANEL.TITLE = Abstract Syntax Tree +AST.MENU.ATTRIBUTES = Add predicate from {0}'a attributes +AST.MENU.NODE.TITLE = Add {0} to the XPath expression +AST.MENU.NODE.ADD_ABSOLUTE_PATH = Add with absolute path +AST.MENU.NODE.ADD_ALLDESCENDANTS = Add all descendants of this type # XPath Panel -XPATH.PANEL.TITLE = XPath -XPATH.PANEL.EXPRESSION = Expression -XPATH.PANEL.RESULTS = Results +XPATH.PANEL.TITLE = XPath +XPATH.PANEL.EXPRESSION = Expression +XPATH.PANEL.RESULTS = Results # Compile Error dialog -COMPILE_ERROR.DIALOG.TITLE = Compilation error -COMPILE_ERROR.PANEL.TITLE = Error message -COMPILE_ERROR.OK_BUTTON.CAPTION = Ok \ No newline at end of file +COMPILE_ERROR.DIALOG.TITLE = Compilation error +COMPILE_ERROR.PANEL.TITLE = Error message +COMPILE_ERROR.OK_BUTTON.CAPTION = Ok diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java index 4dac671e61..4ef18fac37 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java @@ -4,6 +4,10 @@ package net.sourceforge.pmd; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.HashMap; import java.util.List; import java.util.Map; @@ -19,10 +23,6 @@ import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.lang.rule.properties.IntegerProperty; import net.sourceforge.pmd.lang.rule.properties.StringProperty; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class AbstractRuleTest { private static class MyRule extends AbstractRule { @@ -30,7 +30,7 @@ public class AbstractRuleTest { private static final StringProperty xpath = new StringProperty("xpath", "xpath property", "", 2.0f); - public MyRule() { + MyRule() { definePropertyDescriptor(pd); definePropertyDescriptor(xpath); setName("MyRule"); @@ -47,7 +47,7 @@ public class AbstractRuleTest { private static class MyOtherRule extends AbstractRule { private static final PropertyDescriptor pd = new StringProperty("foo", "foo property", "x", 1.0f); - public MyOtherRule() { + MyOtherRule() { definePropertyDescriptor(pd); setName("MyOtherRule"); setMessage("my other rule"); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/ConfigurationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/ConfigurationTest.java index aaaeb75afc..80bc45cadf 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/ConfigurationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/ConfigurationTest.java @@ -4,19 +4,20 @@ package net.sourceforge.pmd; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.IOException; import java.net.URL; import java.util.Properties; import org.junit.Test; -import junit.framework.JUnit4TestAdapter; import net.sourceforge.pmd.renderers.CSVRenderer; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.util.ClasspathClassLoader; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import junit.framework.JUnit4TestAdapter; public class ConfigurationTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/FileSelectorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/FileSelectorTest.java index f4b1c32f5c..c51ac2c4d7 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/FileSelectorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/FileSelectorTest.java @@ -1,6 +1,8 @@ package net.sourceforge.pmd; +import static org.junit.Assert.assertEquals; + import java.io.File; import org.junit.Test; @@ -9,8 +11,6 @@ import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageFilenameFilter; import net.sourceforge.pmd.lang.LanguageRegistry; -import static org.junit.Assert.assertEquals; - /** * Tests on FileSelector. * diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/FooRule.java b/pmd-core/src/test/java/net/sourceforge/pmd/FooRule.java index 278dc84589..eeb5ffee79 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/FooRule.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/FooRule.java @@ -19,18 +19,22 @@ public class FooRule extends AbstractRule { setLanguage(LanguageRegistry.getLanguage(DummyLanguageModule.NAME)); } + @Override public String getMessage() { return "blah"; } + @Override public String getName() { return "Foo"; } + @Override public String getRuleSetName() { return "RuleSet"; } + @Override public String getDescription() { return "desc"; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/ReadableDurationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/ReadableDurationTest.java index a006a36501..73de53d6ad 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/ReadableDurationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/ReadableDurationTest.java @@ -4,6 +4,8 @@ package net.sourceforge.pmd; +import static org.junit.Assert.assertEquals; + import java.util.Arrays; import java.util.Collection; @@ -14,8 +16,6 @@ import org.junit.runners.Parameterized.Parameters; import junit.framework.JUnit4TestAdapter; -import static org.junit.Assert.assertEquals; - @RunWith(Parameterized.class) public class ReadableDurationTest { @@ -30,7 +30,7 @@ public class ReadableDurationTest { @Parameters public static Collection data() { return Arrays.asList(new Object[][] { { "0s", 35 }, { "25s", (25 * 1000) }, { "5m 0s", (60 * 1000 * 5) }, - { "2h 0m 0s", (60 * 1000 * 120) } }); + { "2h 0m 0s", (60 * 1000 * 120) }, }); } @Test diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/ReportTest.java index b5f1ca3f74..f0d0d569d7 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/ReportTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/ReportTest.java @@ -4,6 +4,10 @@ package net.sourceforge.pmd; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.io.IOException; import java.io.StringWriter; import java.util.Iterator; @@ -19,19 +23,17 @@ import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.renderers.XMLRenderer; import net.sourceforge.pmd.stat.Metric; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class ReportTest implements ReportListener { private boolean violationSemaphore; private boolean metricSemaphore; + @Override public void ruleViolationAdded(RuleViolation ruleViolation) { violationSemaphore = true; } + @Override public void metricAdded(Metric metric) { metricSemaphore = true; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleContextTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleContextTest.java index bddf0025b0..6738a7cd5f 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleContextTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleContextTest.java @@ -4,12 +4,6 @@ package net.sourceforge.pmd; -import java.io.File; - -import org.junit.Test; - -import junit.framework.JUnit4TestAdapter; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -17,6 +11,12 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import java.io.File; + +import org.junit.Test; + +import junit.framework.JUnit4TestAdapter; + public class RuleContextTest { @Test diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleReferenceTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleReferenceTest.java index 7e4c207e4e..8c15b6f485 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleReferenceTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleReferenceTest.java @@ -4,9 +4,13 @@ package net.sourceforge.pmd; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import org.junit.Test; -import junit.framework.JUnit4TestAdapter; import net.sourceforge.pmd.lang.Dummy2LanguageModule; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageRegistry; @@ -14,10 +18,7 @@ import net.sourceforge.pmd.lang.rule.MockRule; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.properties.StringProperty; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import junit.framework.JUnit4TestAdapter; public class RuleReferenceTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java index 1e4f3f97a0..365e5339dd 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java @@ -4,6 +4,13 @@ package net.sourceforge.pmd; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.UnsupportedEncodingException; @@ -19,13 +26,6 @@ import net.sourceforge.pmd.lang.rule.MockRule; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.util.ResourceLoader; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - public class RuleSetFactoryTest { @Test public void testRuleSetFileName() throws RuleSetNotFoundException { @@ -44,7 +44,7 @@ public class RuleSetFactoryTest { } @Test - public void testRefs() throws Throwable { + public void testRefs() throws Exception { RuleSetFactory rsf = new RuleSetFactory(); RuleSet rs = rsf.createRuleSet("net/sourceforge/pmd/TestRuleset1.xml"); assertNotNull(rs.getRuleByName("TestRuleRef")); @@ -479,7 +479,7 @@ public class RuleSetFactoryTest { /** * Rule reference can't be resolved - ref is used instead of class and the * class is old (pmd 4.3 and not pmd 5). - * + * * @throws Exception * any error */ @@ -496,7 +496,7 @@ public class RuleSetFactoryTest { /** * See https://sourceforge.net/p/pmd/bugs/1225/ - * + * * @throws Exception * any error */ @@ -515,7 +515,7 @@ public class RuleSetFactoryTest { /** * See https://sourceforge.net/p/pmd/bugs/1231/ - * + * * @throws Exception * any error */ @@ -534,7 +534,7 @@ public class RuleSetFactoryTest { /** * Unit test for #1312 see https://sourceforge.net/p/pmd/bugs/1312/ - * + * * @throws Exception * any error */ @@ -559,7 +559,7 @@ public class RuleSetFactoryTest { /** * See https://sourceforge.net/p/pmd/bugs/1231/ - * + * * @throws Exception * any error */ diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetReferenceIdTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetReferenceIdTest.java index d134023521..53958ccad5 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetReferenceIdTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetReferenceIdTest.java @@ -4,15 +4,6 @@ package net.sourceforge.pmd; -import java.io.File; -import java.io.InputStream; -import java.util.List; - -import org.apache.commons.io.IOUtils; -import org.junit.Test; - -import com.github.tomakehurst.wiremock.junit.WireMockRule; - import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.findAll; import static com.github.tomakehurst.wiremock.client.WireMock.get; @@ -26,6 +17,15 @@ import static com.github.tomakehurst.wiremock.client.WireMock.verify; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import java.io.File; +import java.io.InputStream; +import java.util.List; + +import org.apache.commons.io.IOUtils; +import org.junit.Test; + +import com.github.tomakehurst.wiremock.junit.WireMockRule; + public class RuleSetReferenceIdTest { private static void assertRuleSetReferenceId(final boolean expectedExternal, final String expectedRuleSetFileName, diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java index cd743342df..dbb0f9ca2e 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java @@ -4,6 +4,12 @@ package net.sourceforge.pmd; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.util.ArrayList; import java.util.Collection; @@ -22,12 +28,6 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.MockRule; import net.sourceforge.pmd.lang.rule.RuleReference; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - public class RuleSetTest { private String javaCode = "public class Test { }"; @@ -151,7 +151,7 @@ public class RuleSetTest { } @Test - public void testApply0Rules() throws Throwable { + public void testApply0Rules() { RuleSet IUT = new RuleSet(); verifyRuleSet(IUT, 0, new HashSet()); } @@ -406,7 +406,7 @@ public class RuleSetTest { assertEquals("Violations", 1, r.size()); } - private void verifyRuleSet(RuleSet IUT, int size, Set values) throws Throwable { + private void verifyRuleSet(RuleSet IUT, int size, Set values) { RuleContext context = new RuleContext(); Set reportedValues = new HashSet<>(); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetWriterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetWriterTest.java index 9c566bd11e..bc0204ba50 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetWriterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetWriterTest.java @@ -43,7 +43,7 @@ public class RuleSetWriterTest { /** * Tests the exclude rule behavior. See bug #945. - * + * * @throws Exception * any error */ @@ -61,7 +61,7 @@ public class RuleSetWriterTest { /** * Unit test for #1312 see https://sourceforge.net/p/pmd/bugs/1312/ - * + * * @throws Exception * any error */ diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationComparatorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationComparatorTest.java index 5ef21590f6..07aed2f9d7 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationComparatorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationComparatorTest.java @@ -4,6 +4,9 @@ package net.sourceforge.pmd; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -12,14 +15,12 @@ import java.util.Random; import org.junit.Test; -import junit.framework.JUnit4TestAdapter; import net.sourceforge.pmd.lang.ast.DummyNode; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.MockRule; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; +import junit.framework.JUnit4TestAdapter; public class RuleViolationComparatorTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationTest.java index 892802961e..8a39dce91c 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleViolationTest.java @@ -4,17 +4,18 @@ package net.sourceforge.pmd; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Ignore; import org.junit.Test; -import junit.framework.JUnit4TestAdapter; import net.sourceforge.pmd.lang.ast.DummyNode; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.MockRule; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import junit.framework.JUnit4TestAdapter; public class RuleViolationTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/ant/CPDTaskTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/ant/CPDTaskTest.java index 93909d3373..606ab5787f 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/ant/CPDTaskTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/ant/CPDTaskTest.java @@ -4,6 +4,8 @@ package net.sourceforge.pmd.ant; +import static org.junit.Assert.assertTrue; + import java.io.File; import org.apache.tools.ant.BuildFileRule; @@ -11,8 +13,6 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import static org.junit.Assert.assertTrue; - /** * * @author Romain Pelisse diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/ant/FormatterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/ant/FormatterTest.java index dca7f02a55..fbaa15de6e 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/ant/FormatterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/ant/FormatterTest.java @@ -4,6 +4,10 @@ package net.sourceforge.pmd.ant; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.File; import org.junit.Test; @@ -13,10 +17,6 @@ import net.sourceforge.pmd.renderers.HTMLRenderer; import net.sourceforge.pmd.renderers.TextRenderer; import net.sourceforge.pmd.renderers.XMLRenderer; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - public class FormatterTest { @Test diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java index d883395262..bfe4d1ca2a 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java @@ -4,6 +4,8 @@ package net.sourceforge.pmd.ant; +import static org.junit.Assert.fail; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildFileRule; import org.junit.Assert; @@ -11,8 +13,6 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import static org.junit.Assert.fail; - public class PMDTaskTest { @Rule diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDCommandLineInterfaceTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDCommandLineInterfaceTest.java index 32a81d7b99..e470dfeb5d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDCommandLineInterfaceTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDCommandLineInterfaceTest.java @@ -30,7 +30,7 @@ public class PMDCommandLineInterfaceTest { @Test public void testProperties() { PMDParameters params = new PMDParameters(); - String[] args = { "-d", "source_folder", "-f", "yahtml", "-P", "outputDir=output_folder", "-R", "java-empty" }; + String[] args = { "-d", "source_folder", "-f", "yahtml", "-P", "outputDir=output_folder", "-R", "java-empty", }; PMDCommandLineInterface.extractParameters(params, args, "PMD"); Assert.assertEquals("output_folder", params.getProperties().getProperty("outputDir")); @@ -40,7 +40,7 @@ public class PMDCommandLineInterfaceTest { public void testMultipleProperties() { PMDParameters params = new PMDParameters(); String[] args = { "-d", "source_folder", "-f", "ideaj", "-P", "sourcePath=/home/user/source/", "-P", - "fileName=Foo.java", "-P", "classAndMethodName=Foo.method", "-R", "java-empty" }; + "fileName=Foo.java", "-P", "classAndMethodName=Foo.method", "-R", "java-empty", }; PMDCommandLineInterface.extractParameters(params, args, "PMD"); Assert.assertEquals("/home/user/source/", params.getProperties().getProperty("sourcePath")); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/AnyTokenizerTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/AnyTokenizerTest.java index e8f298fe44..559143f126 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/AnyTokenizerTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/AnyTokenizerTest.java @@ -4,16 +4,16 @@ package net.sourceforge.pmd.cpd; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import net.sourceforge.pmd.PMD; -import static org.junit.Assert.assertEquals; - public class AnyTokenizerTest { @Test - public void testMultiLineMacros() throws Throwable { + public void testMultiLineMacros() { AnyTokenizer tokenizer = new AnyTokenizer(); SourceCode code = new SourceCode(new SourceCode.StringCodeLoader(TEST1)); Tokens tokens = new Tokens(); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDCommandLineInterfaceTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDCommandLineInterfaceTest.java index 46be62bfb5..f1ae19a6db 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDCommandLineInterfaceTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDCommandLineInterfaceTest.java @@ -24,7 +24,7 @@ public class CPDCommandLineInterfaceTest { public void testEmptyResultRendering() { System.setProperty(CPDCommandLineInterface.NO_EXIT_AFTER_RUN, "true"); CPDCommandLineInterface.main(new String[] { "--minimum-tokens", "340", "--language", "java", "--files", - "src/test/resources/net/sourceforge/pmd/cpd/files/", "--format", "xml" }); + "src/test/resources/net/sourceforge/pmd/cpd/files/", "--format", "xml", }); Assert.assertEquals("" + "\n" + "" + PMD.EOL, log.getLog()); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDTest.java index effbe16a3b..2aa914b58b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDTest.java @@ -17,6 +17,7 @@ import org.junit.Test; public class CPDTest { private static final String BASE_TEST_RESOURCE_PATH; + static { if (new File("target/clover/test-classes").exists()) { BASE_TEST_RESOURCE_PATH = "target/clover/test-classes/net/sourceforge/pmd/cpd/files/"; @@ -24,6 +25,7 @@ public class CPDTest { BASE_TEST_RESOURCE_PATH = "target/test-classes/net/sourceforge/pmd/cpd/files/"; } } + private CPD cpd; private boolean canTestSymLinks = false; @@ -47,7 +49,7 @@ public class CPDTest { /** * As java doesn't support symlinks in zip files, maven does not, too. So, * we are creating the symlinks manually here before the test. - * + * * @throws Exception * any error */ @@ -56,11 +58,11 @@ public class CPDTest { Runtime runtime = Runtime.getRuntime(); if (!new File(BASE_TEST_RESOURCE_PATH, "symlink-for-real-file.txt").exists()) { runtime.exec(new String[] { "ln", "-s", "real-file.txt", - BASE_TEST_RESOURCE_PATH + "symlink-for-real-file.txt" }).waitFor(); + BASE_TEST_RESOURCE_PATH + "symlink-for-real-file.txt", }).waitFor(); } if (!new File(BASE_TEST_RESOURCE_PATH, "this-is-a-broken-sym-link-for-test").exists()) { runtime.exec(new String[] { "ln", "-s", "broken-sym-link", - BASE_TEST_RESOURCE_PATH + "this-is-a-broken-sym-link-for-test" }).waitFor(); + BASE_TEST_RESOURCE_PATH + "this-is-a-broken-sym-link-for-test", }).waitFor(); } } } @@ -68,7 +70,7 @@ public class CPDTest { /** * A broken symlink (which is basically a not existing file), should be * skipped. - * + * * @throws Exception * any error */ @@ -86,7 +88,7 @@ public class CPDTest { /** * A file should be added only once - even if it was found twice, because of * a sym link. - * + * * @throws Exception * any error */ @@ -105,7 +107,7 @@ public class CPDTest { /** * Add a file with a relative path - should still be added and not be * detected as a sym link. - * + * * @throws Exception * any error */ @@ -125,11 +127,12 @@ public class CPDTest { private int expectedFilesCount; private int files; - public NoFileAssertListener(int expectedFilesCount) { + NoFileAssertListener(int expectedFilesCount) { this.expectedFilesCount = expectedFilesCount; this.files = 0; } + @Override public void addedFile(int fileCount, File file) { files++; if (files > expectedFilesCount) { @@ -137,6 +140,7 @@ public class CPDTest { } } + @Override public void phaseUpdate(int phase) { // not needed for this test } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CSVRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CSVRendererTest.java index 9d925be6ea..010b31b96f 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CSVRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CSVRendererTest.java @@ -4,6 +4,8 @@ package net.sourceforge.pmd.cpd; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.List; @@ -11,8 +13,6 @@ import org.junit.Test; import net.sourceforge.pmd.PMD; -import static org.junit.Assert.assertEquals; - public class CSVRendererTest { @Test public void testLineCountPerFile() { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/FileReporterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/FileReporterTest.java index 675fbd6d68..97c7aade2b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/FileReporterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/FileReporterTest.java @@ -4,6 +4,9 @@ package net.sourceforge.pmd.cpd; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -11,9 +14,6 @@ import java.io.IOException; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - /** * @author Philippe T'Seyen */ @@ -68,8 +68,9 @@ public class FileReporterTest { } return buffer.toString(); } finally { - if (reader != null) + if (reader != null) { reader.close(); + } } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/LanguageFactoryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/LanguageFactoryTest.java index 9eb5d22886..da8b0f20f2 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/LanguageFactoryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/LanguageFactoryTest.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.cpd; -import org.junit.Test; - import static org.junit.Assert.assertTrue; +import org.junit.Test; + public class LanguageFactoryTest { @Test diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MarkTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MarkTest.java index 9d2840d341..60170744cc 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MarkTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MarkTest.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.cpd; -import org.junit.Test; - import static org.junit.Assert.assertEquals; +import org.junit.Test; + public class MarkTest { @Test diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MatchTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MatchTest.java index f58de83dbe..40627a6f3d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MatchTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MatchTest.java @@ -4,14 +4,14 @@ package net.sourceforge.pmd.cpd; -import java.util.Iterator; - -import org.junit.Test; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import java.util.Iterator; + +import org.junit.Test; + public class MatchTest { @Test diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/SourceCodeTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/SourceCodeTest.java index 4059fe384e..ff3579450e 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/SourceCodeTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/SourceCodeTest.java @@ -4,6 +4,8 @@ package net.sourceforge.pmd.cpd; +import static org.junit.Assert.assertEquals; + import java.io.File; import java.util.ArrayList; @@ -12,15 +14,13 @@ import org.junit.Test; import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.cpd.SourceCode.FileCodeLoader; -import static org.junit.Assert.assertEquals; - public class SourceCodeTest { private static final String BASE_RESOURCE_PATH = "src/test/resources/net/sourceforge/pmd/cpd/files/"; private static final String SAMPLE_CODE = "Line 1\n" + "Line 2\n" + "Line 3\n" + "Line 4\n"; @Test - public void testSimple() throws Throwable { + public void testSimple() throws Exception { Tokenizer tokenizer = new AbstractTokenizer() { { this.stringToken = new ArrayList<>(); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/TokenEntryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/TokenEntryTest.java index 905c460180..d3e1042ae8 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/TokenEntryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/TokenEntryTest.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.cpd; -import org.junit.Test; - import static org.junit.Assert.assertEquals; +import org.junit.Test; + public class TokenEntryTest { @Test diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLRendererTest.java index b1a1d162f2..d1c076fd84 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLRendererTest.java @@ -4,6 +4,10 @@ package net.sourceforge.pmd.cpd; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.ByteArrayInputStream; import java.util.ArrayList; import java.util.List; @@ -15,18 +19,14 @@ import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - /** * @author Philippe T'Seyen * @author Romain Pelisse - * + * */ public class XMLRendererTest { - private final static String ENCODING = (String) System.getProperties().get("file.encoding"); + private static final String ENCODING = (String) System.getProperties().get("file.encoding"); @Test public void testWithNoDuplication() { @@ -76,8 +76,9 @@ public class XMLRendererTest { file = file.getNextSibling(); } } - if (file != null) + if (file != null) { assertEquals("73", file.getAttributes().getNamedItem("line").getNodeValue()); + } assertEquals(1, doc.getElementsByTagName("codefragment").getLength()); assertEquals(codeFragment, doc.getElementsByTagName("codefragment").item(0).getTextContent()); } catch (Exception e) { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/jaxen/AttributeTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/jaxen/AttributeTest.java index 430c4e66b4..dcf4cf02d1 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/jaxen/AttributeTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/jaxen/AttributeTest.java @@ -4,6 +4,8 @@ package net.sourceforge.pmd.jaxen; +import static org.junit.Assert.assertEquals; + import java.lang.reflect.Method; import org.junit.Test; @@ -11,8 +13,6 @@ import org.junit.Test; import net.sourceforge.pmd.lang.ast.DummyNode; import net.sourceforge.pmd.lang.ast.xpath.Attribute; -import static org.junit.Assert.assertEquals; - public class AttributeTest { @Test diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/jaxen/MatchesFunctionTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/jaxen/MatchesFunctionTest.java index dacba0e002..953ae8a4a4 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/jaxen/MatchesFunctionTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/jaxen/MatchesFunctionTest.java @@ -1,6 +1,8 @@ package net.sourceforge.pmd.jaxen; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.List; @@ -12,8 +14,6 @@ import net.sourceforge.pmd.lang.ast.AbstractNode; import net.sourceforge.pmd.lang.ast.xpath.Attribute; import net.sourceforge.pmd.lang.xpath.MatchesFunction; -import static org.junit.Assert.assertTrue; - public class MatchesFunctionTest { public static class MyNode extends AbstractNode { @@ -23,6 +23,7 @@ public class MatchesFunctionTest { super(1); } + @Override public String toString() { return "MyNode"; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageModule.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageModule.java index 1f38a389f6..cae19abfcc 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageModule.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageModule.java @@ -109,7 +109,7 @@ public class DummyLanguageModule extends BaseLanguageModule { ParametricRuleViolation rv = new ParametricRuleViolation(rule, ruleContext, node, message) { { this.packageName = "foo"; // just for testing variable - // expansion + // expansion } }; rv.setLines(beginLine, endLine); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/SourceCodePositionerTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/SourceCodePositionerTest.java index 5ac86bb4ed..0dac633558 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/SourceCodePositionerTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/SourceCodePositionerTest.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.lang.ast; -import org.junit.Test; - import static org.junit.Assert.assertEquals; +import org.junit.Test; + /** * Unit test for {@link SourceCodePositioner}. */ diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/xpath/DocumentNavigatorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/xpath/DocumentNavigatorTest.java index 6a6a2be965..f6158c45b6 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/xpath/DocumentNavigatorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/xpath/DocumentNavigatorTest.java @@ -4,23 +4,23 @@ package net.sourceforge.pmd.lang.ast.xpath; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.fail; + import org.junit.Test; import net.sourceforge.pmd.lang.ast.DummyNode; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.fail; - /** * Unit test for {@link DocumentNavigator} */ public class DocumentNavigatorTest { private static class DummyRootNode extends DummyNode implements RootNode { - public DummyRootNode(int id) { + DummyRootNode(int id) { super(id); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/dfa/report/ViolationNodeTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/dfa/report/ViolationNodeTest.java index 91019f37d1..062871cc02 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/dfa/report/ViolationNodeTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/dfa/report/ViolationNodeTest.java @@ -4,15 +4,15 @@ package net.sourceforge.pmd.lang.dfa.report; -import org.junit.Test; - -import net.sourceforge.pmd.RuleViolation; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import org.junit.Test; + +import net.sourceforge.pmd.RuleViolation; + /** * @author Philip Graf */ diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/processor/MultiThreadProcessorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/processor/MultiThreadProcessorTest.java index 80062705bb..c6e7d6f4bb 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/processor/MultiThreadProcessorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/processor/MultiThreadProcessorTest.java @@ -33,7 +33,7 @@ public class MultiThreadProcessorTest { PMDConfiguration configuration = new PMDConfiguration(); configuration.setRuleSets("rulesets/MultiThreadProcessorTest/basic.xml"); configuration.setThreads(2); - List files = new ArrayList(); + List files = new ArrayList<>(); files.add(new StringDataSource("file1-violation.dummy", "ABC")); files.add(new StringDataSource("file2-foo.dummy", "DEF")); @@ -57,7 +57,7 @@ public class MultiThreadProcessorTest { private final String data; private final String name; - public StringDataSource(String name, String data) { + StringDataSource(String name, String data) { this.name = name; this.data = data; } @@ -76,7 +76,7 @@ public class MultiThreadProcessorTest { public static class NotThreadSafeRule extends AbstractRule { public static AtomicInteger count = new AtomicInteger(0); private boolean hasViolation; // this variable will be overridden - // between the threads + // between the threads @Override public void apply(List nodes, RuleContext ctx) { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/AbstractPropertyDescriptorTester.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/AbstractPropertyDescriptorTester.java index 2a8b989206..87973ff00a 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/AbstractPropertyDescriptorTester.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/AbstractPropertyDescriptorTester.java @@ -1,6 +1,10 @@ package net.sourceforge.pmd.properties; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -14,15 +18,11 @@ import net.sourceforge.pmd.PropertyDescriptorFields; import net.sourceforge.pmd.lang.rule.properties.factories.PropertyDescriptorUtil; import net.sourceforge.pmd.util.CollectionUtil; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - /** * Base functionality for all concrete subclasses that evaluate type-specific * property descriptors. Checks for error conditions during construction, error * value detection, serialization, etc. - * + * * @author Brian Remedios */ public abstract class AbstractPropertyDescriptorTester { @@ -44,7 +44,7 @@ public abstract class AbstractPropertyDescriptorTester { /** * Return a legal value(s) per the general scope of the descriptor. - * + * * @param count * int * @return Object @@ -54,7 +54,7 @@ public abstract class AbstractPropertyDescriptorTester { /** * Return a value(s) that is known to be faulty per the general scope of the * descriptor. - * + * * @param count * int * @return Object @@ -63,7 +63,7 @@ public abstract class AbstractPropertyDescriptorTester { /** * Creates and returns a properly configured property descriptor. - * + * * @param multiValue * boolean * @return PropertyDescriptor @@ -73,7 +73,7 @@ public abstract class AbstractPropertyDescriptorTester { /** * Attempt to create a property with faulty configuration values. This * method should throw an IllegalArgumentException if done correctly. - * + * * @param multiValue * boolean * @return PropertyDescriptor @@ -180,14 +180,14 @@ public abstract class AbstractPropertyDescriptorTester { Object testValue = createValue(1); PropertyDescriptor pmdProp = createProperty(false); // plain vanilla - // property & - // valid test - // value + // property & + // valid test + // value String errorMsg = pmdProp.errorFor(testValue); assertNull(errorMsg, errorMsg); testValue = createValue(multiValueCount); // multi-value property, all - // valid test values + // valid test values pmdProp = createProperty(true); errorMsg = pmdProp.errorFor(testValue); assertNull(errorMsg, errorMsg); @@ -200,13 +200,13 @@ public abstract class AbstractPropertyDescriptorTester { PropertyDescriptor pmdProp = createProperty(false); Object testValue = createBadValue(1); String errorMsg = pmdProp.errorFor(testValue); // bad value should - // result in an error + // result in an error if (errorMsg == null) { Assert.fail("uncaught bad value: " + testValue); } testValue = createBadValue(multiValueCount); // multi-value prop, - // several bad values + // several bad values pmdProp = createProperty(true); errorMsg = pmdProp.errorFor(testValue); if (errorMsg == null) { @@ -228,7 +228,7 @@ public abstract class AbstractPropertyDescriptorTester { /** * Method randomInt. - * + * * @return int */ public static int randomInt() { @@ -239,7 +239,7 @@ public abstract class AbstractPropertyDescriptorTester { /** * Method randomInt. - * + * * @param min * int * @param max @@ -247,8 +247,9 @@ public abstract class AbstractPropertyDescriptorTester { * @return int */ public static int randomInt(int min, int max) { - if (max < min) + if (max < min) { max = min; + } int range = Math.abs(max - min); int x = (int) (range * Math.random()); return x + min; @@ -259,14 +260,15 @@ public abstract class AbstractPropertyDescriptorTester { final char[] chars = alphaChars.toCharArray(); StringBuilder sb = new StringBuilder(length); - for (int i = 0; i < length; i++) + for (int i = 0; i < length; i++) { sb.append(randomChar(chars)); + } return sb.toString(); } /** * Method randomFloat. - * + * * @param min * float * @param max @@ -280,7 +282,7 @@ public abstract class AbstractPropertyDescriptorTester { /** * Method randomDouble. - * + * * @param min * double * @param max @@ -288,8 +290,9 @@ public abstract class AbstractPropertyDescriptorTester { * @return double */ public static double randomDouble(double min, double max) { - if (max < min) + if (max < min) { max = min; + } double range = Math.abs(max - min); double x = range * Math.random(); return x + min; @@ -297,7 +300,7 @@ public abstract class AbstractPropertyDescriptorTester { /** * Method randomChar. - * + * * @param characters * char[] * @return char @@ -308,7 +311,7 @@ public abstract class AbstractPropertyDescriptorTester { /** * Method randomChoice. - * + * * @param items * Object[] * @return Object @@ -319,7 +322,7 @@ public abstract class AbstractPropertyDescriptorTester { /** * Method filter. - * + * * @param chars * char[] * @param removeChar @@ -328,15 +331,18 @@ public abstract class AbstractPropertyDescriptorTester { */ protected static final char[] filter(char[] chars, char removeChar) { int count = 0; - for (int i = 0; i < chars.length; i++) - if (chars[i] == removeChar) + for (int i = 0; i < chars.length; i++) { + if (chars[i] == removeChar) { count++; + } + } char[] results = new char[chars.length - count]; int index = 0; for (int i = 0; i < chars.length; i++) { - if (chars[i] != removeChar) + if (chars[i] != removeChar) { results[index++] = chars[i]; + } } return results; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/BooleanPropertyTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/BooleanPropertyTest.java index 3759e14c5c..69227bf4a5 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/BooleanPropertyTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/BooleanPropertyTest.java @@ -18,38 +18,44 @@ public class BooleanPropertyTest extends AbstractPropertyDescriptorTester { /** * Method createValue. - * + * * @param valueCount * int * @return Object */ + @Override protected Object createValue(int valueCount) { - if (valueCount == 1) + if (valueCount == 1) { return System.currentTimeMillis() % 1 > 0 ? Boolean.TRUE : Boolean.FALSE; + } Boolean[] values = new Boolean[valueCount]; - for (int i = 0; i < values.length; i++) + for (int i = 0; i < values.length; i++) { values[i] = (Boolean) createValue(1); + } return values; } + @Override @Test public void testErrorForBad() { // override, cannot create a 'bad' boolean per se } + @Override protected Object createBadValue(int count) { return null; } /** * Method createProperty. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createProperty(boolean multiValue) { return multiValue ? new BooleanMultiProperty("testBoolean", "Test boolean property", new Boolean[] { false, true, true }, 1.0f) @@ -58,11 +64,12 @@ public class BooleanPropertyTest extends AbstractPropertyDescriptorTester { /** * Method createBadProperty. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createBadProperty(boolean multiValue) { return multiValue ? new BooleanMultiProperty("", "Test boolean property", new Boolean[] { false, true, true }, 1.0f) diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/CharacterPropertyTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/CharacterPropertyTest.java index 18c06d8eab..8af8b73c4a 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/CharacterPropertyTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/CharacterPropertyTest.java @@ -11,7 +11,7 @@ import net.sourceforge.pmd.lang.rule.properties.CharacterProperty; * Evaluates the functionality of the CharacterProperty descriptor by testing * its ability to catch creation errors (illegal args), flag invalid characters, * and serialize/deserialize any default values. - * + * * @author Brian Remedios */ public class CharacterPropertyTest extends AbstractPropertyDescriptorTester { @@ -25,51 +25,59 @@ public class CharacterPropertyTest extends AbstractPropertyDescriptorTester { /** * Method createValue. - * + * * @param count * int * @return Object */ + @Override protected Object createValue(int count) { - if (count == 1) + if (count == 1) { return new Character(randomChar(charSet)); + } Character[] values = new Character[count]; - for (int i = 0; i < values.length; i++) + for (int i = 0; i < values.length; i++) { values[i] = (Character) createValue(1); + } return values; } /** * Method createBadValue. - * + * * @param count * int * @return Object */ + @Override protected Object createBadValue(int count) { - if (count == 1) + if (count == 1) { return null; + } Character[] values = new Character[count]; - for (int i = 0; i < values.length; i++) + for (int i = 0; i < values.length; i++) { values[i] = (Character) createBadValue(1); + } return values; } + @Override @Test public void testErrorForBad() { } // not until char properties use illegal chars /** * Method createProperty. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createProperty(boolean multiValue) { return multiValue @@ -81,11 +89,12 @@ public class CharacterPropertyTest extends AbstractPropertyDescriptorTester { /** * Creates a bad property that is missing either its name or description or * includes a delimiter in the set of legal values. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createBadProperty(boolean multiValue) { return multiValue diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/DoublePropertyTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/DoublePropertyTest.java index ef621cb1d6..47eae63b8c 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/DoublePropertyTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/DoublePropertyTest.java @@ -10,7 +10,7 @@ import net.sourceforge.pmd.lang.rule.properties.DoubleProperty; * ability to catch creation errors (illegal args), flag out-of-range test * values, and serialize/deserialize groups of double values onto/from a string * buffer. - * + * * @author Brian Remedios */ public class DoublePropertyTest extends AbstractPropertyDescriptorTester { @@ -25,48 +25,55 @@ public class DoublePropertyTest extends AbstractPropertyDescriptorTester { /** * Creates and returns (count) number of legal Double values - * + * * @param count * int * @return Object */ + @Override protected Object createValue(int count) { - if (count == 1) + if (count == 1) { return Double.valueOf(randomDouble(MIN, MAX)); + } Double[] values = new Double[count]; - for (int i = 0; i < values.length; i++) + for (int i = 0; i < values.length; i++) { values[i] = (Double) createValue(1); + } return values; } /** * Creates and returns (count) number of out-of-range values - * + * * @param count * int * @return Object */ + @Override protected Object createBadValue(int count) { - if (count == 1) + if (count == 1) { return Double.valueOf( randomBool() ? randomDouble(MIN - SHIFT, MIN - 0.01) : randomDouble(MAX + 0.01, MAX + SHIFT)); + } Double[] values = new Double[count]; - for (int i = 0; i < values.length; i++) + for (int i = 0; i < values.length; i++) { values[i] = (Double) createBadValue(1); + } return values; } /** * Creates and returns a property with a (maxCount) value cardinality. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createProperty(boolean multiValue) { return multiValue @@ -77,11 +84,12 @@ public class DoublePropertyTest extends AbstractPropertyDescriptorTester { /** * Attempts to create a property with invalid constructor arguments. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createBadProperty(boolean multiValue) { return multiValue diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/EnumeratedPropertyTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/EnumeratedPropertyTest.java index 7eed549aad..a229f0dbf5 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/EnumeratedPropertyTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/EnumeratedPropertyTest.java @@ -15,7 +15,7 @@ import net.sourceforge.pmd.lang.rule.properties.EnumeratedProperty; * Evaluates the functionality of the EnumeratedProperty descriptor by testing * its ability to catch creation errors (illegal args), flag invalid selections, * and serialize/deserialize selection options. - * + * * @author Brian Remedios */ public class EnumeratedPropertyTest extends AbstractPropertyDescriptorTester { @@ -23,7 +23,7 @@ public class EnumeratedPropertyTest extends AbstractPropertyDescriptorTester { private static final String[] keys = new String[] { "map", "emptyArray", "list", "string", }; private static final Object[] values = new Object[] { new HashMap(), new Object[0], new ArrayList(), - "Hello World!", }; + "Hello World!", }; public EnumeratedPropertyTest() { super("Enum"); @@ -31,48 +31,55 @@ public class EnumeratedPropertyTest extends AbstractPropertyDescriptorTester { /** * Method createValue. - * + * * @param count * int * @return Object */ + @Override protected Object createValue(int count) { - if (count == 1) + if (count == 1) { return randomChoice(values); + } Object[] values = new Object[count]; - for (int i = 0; i < values.length; i++) + for (int i = 0; i < values.length; i++) { values[i] = createValue(1); + } return values; } /** * Returns a (count) number of values that are not in the set of legal * values. - * + * * @param count * int * @return Object */ + @Override protected Object createBadValue(int count) { - if (count == 1) + if (count == 1) { return Integer.toString(randomInt()); // not in the set of values + } Object[] values = new Object[count]; - for (int i = 0; i < values.length; i++) + for (int i = 0; i < values.length; i++) { values[i] = createBadValue(1); + } return values; } /** * Method createProperty. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createProperty(boolean multiValue) { return multiValue @@ -84,11 +91,12 @@ public class EnumeratedPropertyTest extends AbstractPropertyDescriptorTester { /** * Method createBadProperty. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createBadProperty(boolean multiValue) { return multiValue @@ -98,16 +106,19 @@ public class EnumeratedPropertyTest extends AbstractPropertyDescriptorTester { values, -1, 1.0f); } + @Override @Test public void testFactorySingleValue() { Assume.assumeTrue("The EnumeratedProperty is not implemented completely yet", false); } + @Override @Test public void testFactoryMultiValueCustomDelimiter() { Assume.assumeTrue("The EnumeratedProperty is not implemented completely yet", false); } + @Override @Test public void testFactoryMultiValueDefaultDelimiter() { Assume.assumeTrue("The EnumeratedProperty is not implemented completely yet", false); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/FloatPropertyTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/FloatPropertyTest.java index 6d3596db8a..55089f65f2 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/FloatPropertyTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/FloatPropertyTest.java @@ -10,7 +10,7 @@ import net.sourceforge.pmd.lang.rule.properties.FloatProperty; * ability to catch creation errors (illegal args), flag out-of-range test * values, and serialize/deserialize groups of float values onto/from a string * buffer. - * + * * @author Brian Remedios */ public class FloatPropertyTest extends AbstractPropertyDescriptorTester { @@ -33,47 +33,54 @@ public class FloatPropertyTest extends AbstractPropertyDescriptorTester { /** * Method createValue. - * + * * @param count * int * @return Object */ + @Override protected Object createValue(int count) { - if (count == 1) + if (count == 1) { return Float.valueOf(randomFloat(MIN, MAX)); + } Float[] values = new Float[count]; - for (int i = 0; i < values.length; i++) + for (int i = 0; i < values.length; i++) { values[i] = (Float) createValue(1); + } return values; } /** * Creates and returns (count) number of out-of-range float values - * + * * @param count * int * @return Object */ + @Override protected Object createBadValue(int count) { - if (count == 1) + if (count == 1) { return Float.valueOf(randomBool() ? randomFloat(MIN - SHIFT, MIN) : randomFloat(MAX, MAX + SHIFT)); + } Float[] values = new Float[count]; - for (int i = 0; i < values.length; i++) + for (int i = 0; i < values.length; i++) { values[i] = (Float) createBadValue(1); + } return values; } /** * Method createProperty. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createProperty(boolean multiValue) { return multiValue ? new FloatMultiProperty("testFloat", "Test float property", MIN, MAX, @@ -83,11 +90,12 @@ public class FloatPropertyTest extends AbstractPropertyDescriptorTester { /** * Method createBadProperty. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createBadProperty(boolean multiValue) { return multiValue ? new FloatMultiProperty("testFloat", "Test float property", 0f, 5f, diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/IntegerPropertyTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/IntegerPropertyTest.java index 26da7d6096..3587555b4e 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/IntegerPropertyTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/IntegerPropertyTest.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.lang.rule.properties.IntegerProperty; * ability to catch creation errors (illegal args), flag out-of-range test * values, and serialize/deserialize groups of integers onto/from a string * buffer. - * + * * @author Brian Remedios */ public class IntegerPropertyTest extends AbstractPropertyDescriptorTester { @@ -27,51 +27,59 @@ public class IntegerPropertyTest extends AbstractPropertyDescriptorTester { /** * Method createValue. - * + * * @param count * int * @return Object */ + @Override protected Object createValue(int count) { - if (count == 1) + if (count == 1) { return Integer.valueOf(randomInt(MIN, MAX)); + } Integer[] values = new Integer[count]; - for (int i = 0; i < values.length; i++) + for (int i = 0; i < values.length; i++) { values[i] = (Integer) createValue(1); + } return values; } /** * Creates and returns (count) number of out-of-range Integer values - * + * * @param count * int * @return Object */ + @Override protected Object createBadValue(int count) { - if (count == 1) + if (count == 1) { return Integer.valueOf(randomBool() ? randomInt(MIN - SHIFT, MIN) : randomInt(MAX, MAX + SHIFT)); + } Integer[] values = new Integer[count]; - for (int i = 0; i < values.length; i++) + for (int i = 0; i < values.length; i++) { values[i] = (Integer) createBadValue(1); + } return values; } + @Override @Test public void testErrorForBad() { } // not until int properties get ranges /** * Method createProperty. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createProperty(boolean multiValue) { return multiValue @@ -82,11 +90,12 @@ public class IntegerPropertyTest extends AbstractPropertyDescriptorTester { /** * Method createBadProperty. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createBadProperty(boolean multiValue) { return multiValue ? new IntegerMultiProperty("testInteger", "", MIN, MAX, new Integer[] { MIN - 1, MAX }, 1.0f) diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/MethodPropertyTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/MethodPropertyTest.java index 41e7e5e5cd..7d46df1f8a 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/MethodPropertyTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/MethodPropertyTest.java @@ -1,6 +1,9 @@ package net.sourceforge.pmd.properties; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.lang.reflect.Method; import java.util.HashMap; @@ -11,25 +14,22 @@ import net.sourceforge.pmd.lang.rule.properties.MethodMultiProperty; import net.sourceforge.pmd.lang.rule.properties.MethodProperty; import net.sourceforge.pmd.util.ClassUtil; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - /** * Evaluates the functionality of the MethodProperty descriptor by testing its * ability to catch creation errors (illegal args), flag invalid methods per the * allowable packages, and serialize/deserialize groups of methods onto/from a * string buffer. - * + * * We're using methods from java.lang classes for 'normal' constructors and * applying ones from java.util types as ones we expect to fail. - * + * * @author Brian Remedios */ public class MethodPropertyTest extends AbstractPropertyDescriptorTester { private static final String[] methodSignatures = new String[] { "String#indexOf(int)", "String#substring(int,int)", - "java.lang.String#substring(int,int)", "Integer#parseInt(String)", "java.util.HashMap#put(Object,Object)", - "HashMap#containsKey(Object)" }; + "java.lang.String#substring(int,int)", "Integer#parseInt(String)", "java.util.HashMap#put(Object,Object)", + "HashMap#containsKey(Object)", }; public MethodPropertyTest() { super("Method"); @@ -83,7 +83,7 @@ public class MethodPropertyTest extends AbstractPropertyDescriptorTester { Method[] allMethods = HashMap.class.getDeclaredMethods(); if (count == 1) { - return (Method) randomChoice(allMethods); + return randomChoice(allMethods); } Method[] methods = new Method[count]; @@ -111,7 +111,7 @@ public class MethodPropertyTest extends AbstractPropertyDescriptorTester { Method[] allMethods = String.class.getDeclaredMethods(); if (count == 1) { - return (Method) randomChoice(allMethods); + return randomChoice(allMethods); } Method[] methods = new Method[count]; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/NonRuleWithAllPropertyTypes.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/NonRuleWithAllPropertyTypes.java index dd2db5c620..c7788d580f 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/NonRuleWithAllPropertyTypes.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/NonRuleWithAllPropertyTypes.java @@ -29,14 +29,14 @@ import net.sourceforge.pmd.util.ClassUtil; /** * A non-functional rule containing all property types. Used for testing UIs. - * + * * Steps required to use with Eclipse Plugin: - * + * * update your chosen ruleset xml file to include this 'rule' compile new PMD * jars copy both the pmd5.0.jar and pmd-test-5.0.jar to the eclipse-plugin/lib * directory update the /manifest.mf file to ensure it includes the * pmd-test-5.0.jar - * + * * @author Brian Remedios */ public class NonRuleWithAllPropertyTypes extends AbstractRule { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertyAccessorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertyAccessorTest.java index e4b74c722c..382f1075ba 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertyAccessorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertyAccessorTest.java @@ -4,6 +4,12 @@ package net.sourceforge.pmd.properties; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -13,12 +19,6 @@ import net.sourceforge.pmd.cpd.ReportException; import net.sourceforge.pmd.util.CollectionUtil; import net.sourceforge.pmd.util.NumericConstants; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - /** * @author Brian Remedios */ @@ -57,21 +57,22 @@ public class PropertyAccessorTest { /* * rule.setProperty("singleFloat", new Float(0)); * assertTrue(rule.getFloatProperty("singleFloat") == 0f); - * + * * rule.setProperties("multiBool", new Boolean[] {Boolean.TRUE, * Boolean.FALSE}); * assertTrue(areEqual(rule.getBooleanProperties("multiBool"), new * boolean[]{true, false})); - * + * * boolean exceptionOccurred = false; try { * rule.setProperties("singleBool", new Boolean[] {Boolean.TRUE, * Boolean.FALSE}); } catch (Exception ex) { exceptionOccurred = true; } * assertTrue(exceptionOccurred); - * + * * exceptionOccurred = false; try { rule.setProperty("multiBool", * Boolean.TRUE); } catch (Exception ex) { exceptionOccurred = true; } * assertTrue(exceptionOccurred); - */} + */ + } @Test public void testStrings() { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/StringPropertyTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/StringPropertyTest.java index 5e9f7235dd..55b3105305 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/StringPropertyTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/StringPropertyTest.java @@ -10,7 +10,7 @@ import net.sourceforge.pmd.lang.rule.properties.StringProperty; * ability to catch creation errors (illegal args), flag invalid strings per any * specified expressions, and serialize/deserialize groups of strings onto/from * a string buffer. - * + * * @author Brian Remedios */ public class StringPropertyTest extends AbstractPropertyDescriptorTester { @@ -25,43 +25,49 @@ public class StringPropertyTest extends AbstractPropertyDescriptorTester { /** * Method createValue. - * + * * @param count * int * @return Object */ + @Override protected Object createValue(int count) { - if (count == 1) + if (count == 1) { return newString(); + } String[] values = new String[count]; - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { values[i] = (String) createValue(1); + } return values; } /** * Method createBadValue. - * + * * @param count * int * @return Object */ + @Override protected Object createBadValue(int count) { - if (count == 1) + if (count == 1) { return null; + } Object[] values = new Object[count]; - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { values[i] = createBadValue(1); + } return values; } /** * Method newString. - * + * * @return String */ private String newString() { @@ -69,14 +75,15 @@ public class StringPropertyTest extends AbstractPropertyDescriptorTester { int strLength = randomInt(0, maxStringLength); char[] chars = new char[strLength]; - for (int i = 0; i < chars.length; i++) + for (int i = 0; i < chars.length; i++) { chars[i] = randomCharIn(charSet); + } return new String(chars); } /** * Method randomCharIn. - * + * * @param chars * char[] * @return char @@ -87,11 +94,12 @@ public class StringPropertyTest extends AbstractPropertyDescriptorTester { /** * Method createProperty. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createProperty(boolean multiValue) { return multiValue ? new StringMultiProperty("testString", "Test string property", new String[] { "hello", "world" }, 1.0f, delimiter) @@ -100,11 +108,12 @@ public class StringPropertyTest extends AbstractPropertyDescriptorTester { /** * Method createBadProperty. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createBadProperty(boolean multiValue) { return multiValue ? new StringMultiProperty("testString", "Test string property", diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/TypePropertyTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/TypePropertyTest.java index b87b36afa5..cf7f6c7696 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/TypePropertyTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/TypePropertyTest.java @@ -16,18 +16,18 @@ import net.sourceforge.pmd.lang.rule.properties.TypeProperty; * ability to catch creation errors (illegal args), flag invalid Type values per * the allowable packages, and serialize/deserialize groups of types onto/from a * string buffer. - * + * * We're using java.lang classes for 'normal' constructors and applying * java.util types as ones we expect to fail. - * + * * @author Brian Remedios */ public class TypePropertyTest extends AbstractPropertyDescriptorTester { private static final Class[] javaLangClasses = new Class[] { String.class, Integer.class, Thread.class, - Object.class, Runtime.class }; + Object.class, Runtime.class, }; private static final Class[] javaUtilTypes = new Class[] { HashMap.class, Map.class, Comparator.class, Set.class, - Observer.class }; + Observer.class, }; public TypePropertyTest() { super("Class"); @@ -35,47 +35,54 @@ public class TypePropertyTest extends AbstractPropertyDescriptorTester { /** * Method createValue. - * + * * @param count * int * @return Object */ + @Override protected Object createValue(int count) { - if (count == 1) + if (count == 1) { return randomChoice(javaLangClasses); + } Object[] values = new Object[count]; - for (int i = 0; i < values.length; i++) + for (int i = 0; i < values.length; i++) { values[i] = createValue(1); + } return values; } /** * Method createBadValue. - * + * * @param count * int * @return Object */ + @Override protected Object createBadValue(int count) { - if (count == 1) + if (count == 1) { return randomChoice(javaUtilTypes); + } Object[] values = new Object[count]; - for (int i = 0; i < values.length; i++) + for (int i = 0; i < values.length; i++) { values[i] = createBadValue(1); + } return values; } /** * Method createProperty. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createProperty(boolean multiValue) { return multiValue @@ -87,11 +94,12 @@ public class TypePropertyTest extends AbstractPropertyDescriptorTester { /** * Method createProperty. - * + * * @param multiValue * boolean * @return PropertyDescriptor */ + @Override protected PropertyDescriptor createBadProperty(boolean multiValue) { return multiValue diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTst.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTst.java index b2d391c8f0..fcd20a3340 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTst.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTst.java @@ -4,6 +4,8 @@ package net.sourceforge.pmd.renderers; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import net.sourceforge.pmd.FooRule; @@ -17,8 +19,6 @@ import net.sourceforge.pmd.lang.ast.DummyNode; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; -import static org.junit.Assert.assertEquals; - public abstract class AbstractRendererTst { public abstract Renderer getRenderer(); @@ -42,7 +42,7 @@ public abstract class AbstractRendererTst { } @Test(expected = NullPointerException.class) - public void testNullPassedIn() throws Throwable { + public void testNullPassedIn() throws Exception { getRenderer().renderFileReport(null); } @@ -90,28 +90,28 @@ public abstract class AbstractRendererTst { } @Test - public void testRenderer() throws Throwable { + public void testRenderer() throws Exception { Report rep = reportOneViolation(); String actual = ReportTest.render(getRenderer(), rep); assertEquals(filter(getExpected()), filter(actual)); } @Test - public void testRendererEmpty() throws Throwable { + public void testRendererEmpty() throws Exception { Report rep = new Report(); String actual = ReportTest.render(getRenderer(), rep); assertEquals(filter(getExpectedEmpty()), filter(actual)); } @Test - public void testRendererMultiple() throws Throwable { + public void testRendererMultiple() throws Exception { Report rep = reportTwoViolations(); String actual = ReportTest.render(getRenderer(), rep); assertEquals(filter(getExpectedMultiple()), filter(actual)); } @Test - public void testError() throws Throwable { + public void testError() throws Exception { Report rep = new Report(); Report.ProcessingError err = new Report.ProcessingError("Error", "file"); rep.addError(err); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java index b0f0a257a9..92aa9f8699 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java @@ -9,25 +9,30 @@ import net.sourceforge.pmd.Report.ProcessingError; public class CSVRendererTest extends AbstractRendererTst { + @Override public Renderer getRenderer() { return new CSVRenderer(); } + @Override public String getExpected() { return "\"Problem\",\"Package\",\"File\",\"Priority\",\"Line\",\"Description\",\"Rule set\",\"Rule\"" + PMD.EOL + "\"1\",\"\",\"n/a\",\"5\",\"1\",\"blah\",\"RuleSet\",\"Foo\"" + PMD.EOL; } + @Override public String getExpectedEmpty() { return "\"Problem\",\"Package\",\"File\",\"Priority\",\"Line\",\"Description\",\"Rule set\",\"Rule\"" + PMD.EOL; } + @Override public String getExpectedMultiple() { return "\"Problem\",\"Package\",\"File\",\"Priority\",\"Line\",\"Description\",\"Rule set\",\"Rule\"" + PMD.EOL + "\"1\",\"\",\"n/a\",\"5\",\"1\",\"blah\",\"RuleSet\",\"Foo\"" + PMD.EOL + "\"2\",\"\",\"n/a\",\"5\",\"1\",\"blah\",\"RuleSet\",\"Foo\"" + PMD.EOL; } + @Override public String getExpectedError(ProcessingError error) { return "\"Problem\",\"Package\",\"File\",\"Priority\",\"Line\",\"Description\",\"Rule set\",\"Rule\"" + PMD.EOL; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/IDEAJRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/IDEAJRendererTest.java index a80c710260..5c0d07fce9 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/IDEAJRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/IDEAJRendererTest.java @@ -5,6 +5,7 @@ import net.sourceforge.pmd.PMD; public class IDEAJRendererTest extends AbstractRendererTst { + @Override public Renderer getRenderer() { Renderer result = new IDEAJRenderer(); result.setProperty(IDEAJRenderer.SOURCE_PATH, ""); @@ -13,14 +14,17 @@ public class IDEAJRendererTest extends AbstractRendererTst { return result; } + @Override public String getExpected() { return "blah" + PMD.EOL + " at Foo (Foo.java:1)" + PMD.EOL; } + @Override public String getExpectedEmpty() { return ""; } + @Override public String getExpectedMultiple() { return "blah" + PMD.EOL + " at Foo (Foo.java:1)" + PMD.EOL + "blah" + PMD.EOL + " at Foo (Foo.java:1)" + PMD.EOL; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/PapariTextRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/PapariTextRendererTest.java index 824654c91a..7a842aa05d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/PapariTextRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/PapariTextRendererTest.java @@ -15,12 +15,15 @@ import net.sourceforge.pmd.Report.ProcessingError; public class PapariTextRendererTest extends AbstractRendererTst { private static String naString = "n/a"; + static { naString = naString.substring(naString.lastIndexOf(File.separator) + 1); } + @Override public Renderer getRenderer() { TextColorRenderer result = new TextColorRenderer() { + @Override protected Reader getReader(String sourceFile) throws FileNotFoundException { return new StringReader("public class Foo {}"); } @@ -29,16 +32,19 @@ public class PapariTextRendererTest extends AbstractRendererTst { return result; } + @Override public String getExpected() { return "* file: n/a" + PMD.EOL + " src: " + naString + ":1:1" + PMD.EOL + " rule: Foo" + PMD.EOL + " msg: blah" + PMD.EOL + " code: public class Foo {}" + PMD.EOL + PMD.EOL + PMD.EOL + PMD.EOL + "Summary:" + PMD.EOL + PMD.EOL + " : 1" + PMD.EOL + "* warnings: 1" + PMD.EOL; } + @Override public String getExpectedEmpty() { return PMD.EOL + PMD.EOL + "Summary:" + PMD.EOL + PMD.EOL + "* warnings: 0" + PMD.EOL; } + @Override public String getExpectedMultiple() { return "* file: n/a" + PMD.EOL + " src: " + naString + ":1:1" + PMD.EOL + " rule: Foo" + PMD.EOL + " msg: blah" + PMD.EOL + " code: public class Foo {}" + PMD.EOL + PMD.EOL + " src: " @@ -47,6 +53,7 @@ public class PapariTextRendererTest extends AbstractRendererTst { + PMD.EOL + " : 2" + PMD.EOL + "* warnings: 2" + PMD.EOL; } + @Override public String getExpectedError(ProcessingError error) { return PMD.EOL + PMD.EOL + "Summary:" + PMD.EOL + PMD.EOL + " err: Error" + PMD.EOL + PMD.EOL + "* errors: 0" + PMD.EOL + "* warnings: 0" + PMD.EOL; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java index 653f14ff8e..4b1fc12ee3 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java @@ -4,6 +4,8 @@ package net.sourceforge.pmd.renderers; +import static org.junit.Assert.assertEquals; + import java.util.HashMap; import java.util.Map; @@ -18,8 +20,6 @@ import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; -import static org.junit.Assert.assertEquals; - public class SummaryHTMLRendererTest extends AbstractRendererTst { @Override diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/stat/MetricTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/stat/MetricTest.java index 4c911bfbd8..27d17a3247 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/stat/MetricTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/stat/MetricTest.java @@ -23,12 +23,12 @@ package net.sourceforge.pmd.stat; +import static org.junit.Assert.assertEquals; + import java.util.Random; import org.junit.Test; -import static org.junit.Assert.assertEquals; - /** * @author David Dixon-Peugh */ diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/stat/StatisticalRuleTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/stat/StatisticalRuleTest.java index 0b9c6c2aeb..428bfca6a5 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/stat/StatisticalRuleTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/stat/StatisticalRuleTest.java @@ -23,6 +23,12 @@ package net.sourceforge.pmd.stat; +import static net.sourceforge.pmd.lang.rule.stat.StatisticalRule.MINIMUM_DESCRIPTOR; +import static net.sourceforge.pmd.lang.rule.stat.StatisticalRule.SIGMA_DESCRIPTOR; +import static net.sourceforge.pmd.lang.rule.stat.StatisticalRule.TOP_SCORE_DESCRIPTOR; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -33,7 +39,6 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import junit.framework.AssertionFailedError; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleContext; @@ -43,11 +48,7 @@ import net.sourceforge.pmd.lang.ast.DummyNode; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.stat.StatisticalRule; -import static net.sourceforge.pmd.lang.rule.stat.StatisticalRule.MINIMUM_DESCRIPTOR; -import static net.sourceforge.pmd.lang.rule.stat.StatisticalRule.SIGMA_DESCRIPTOR; -import static net.sourceforge.pmd.lang.rule.stat.StatisticalRule.TOP_SCORE_DESCRIPTOR; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import junit.framework.AssertionFailedError; /** * This class tests the Statistical Rules in PMD. @@ -83,8 +84,8 @@ public class StatisticalRuleTest { private DataPoint[] points = new DataPoint[POINTS]; private MockStatisticalRule IUT = null; - private String testName = "";// FIXME - why/when was this added. It was - // never set. + // FIXME - why/when was this added. It was never set. + private String testName = ""; private Random random = new Random(); public static final double MAX_MINIMUM = POINTS; @@ -155,7 +156,7 @@ public class StatisticalRuleTest { * values. */ @Test - public void testMetrics() throws Throwable { + public void testMetrics() { Report report = makeReport(IUT); Iterator metrics = report.metrics(); @@ -184,8 +185,9 @@ public class StatisticalRuleTest { public double randomSigma(int minimum) { double minSigma = ((POINTS - 1 - minimum) - MEAN) / SIGMA; - if ((minSigma <= 0) || (minSigma > 2)) + if ((minSigma <= 0) || (minSigma > 2)) { return randomSigma(); + } return minSigma + (random.nextDouble() * (2 - minSigma)); } @@ -197,8 +199,9 @@ public class StatisticalRuleTest { public int expectedSigma(double sigma) { long expectedMin = Math.round(MEAN + (sigma * SIGMA)); - if (((POINTS - 1) - expectedMin) < 0) + if (((POINTS - 1) - expectedMin) < 0) { return 0; + } return (POINTS - 1) - (int) expectedMin; } @@ -249,8 +252,9 @@ public class StatisticalRuleTest { * than the minimum provided. */ public int randomTopScore(double target) { - if (target < 0) + if (target < 0) { return 0; + } return random.nextInt(Double.valueOf(target).intValue()); } @@ -298,7 +302,7 @@ public class StatisticalRuleTest { // @Test - public void testS() throws Throwable { + public void testS() { verifyResults(MAX_SIGMA, NO_MINIMUM, NO_TOPSCORE, 0, 2); for (int i = 0; i < NUM_TESTS; i++) { @@ -308,32 +312,32 @@ public class StatisticalRuleTest { } @Test - public void testS1() throws Throwable { + public void testS1() { testS(); } @Test - public void testS2() throws Throwable { + public void testS2() { testS(); } @Test - public void testS3() throws Throwable { + public void testS3() { testS(); } @Test - public void testS4() throws Throwable { + public void testS4() { testS(); } @Test - public void testS5() throws Throwable { + public void testS5() { testS(); } @Test - public void testT() throws Throwable { + public void testT() { verifyResults(NO_SIGMA, NO_MINIMUM, MIN_TOPSCORE, 0, 0); for (int i = 0; i < NUM_TESTS; i++) { @@ -343,32 +347,32 @@ public class StatisticalRuleTest { } @Test - public void testT1() throws Throwable { + public void testT1() { testT(); } @Test - public void testT2() throws Throwable { + public void testT2() { testT(); } @Test - public void testT3() throws Throwable { + public void testT3() { testT(); } @Test - public void testT4() throws Throwable { + public void testT4() { testT(); } @Test - public void testT5() throws Throwable { + public void testT5() { testT(); } @Test - public void testM() throws Throwable { + public void testM() { verifyResults(NO_SIGMA, MAX_MINIMUM, NO_TOPSCORE, 0, 0); for (int i = 0; i < NUM_TESTS; i++) { @@ -378,32 +382,32 @@ public class StatisticalRuleTest { } @Test - public void testM1() throws Throwable { + public void testM1() { testM(); } @Test - public void testM2() throws Throwable { + public void testM2() { testM(); } @Test - public void testM3() throws Throwable { + public void testM3() { testM(); } @Test - public void testM4() throws Throwable { + public void testM4() { testM(); } @Test - public void testM5() throws Throwable { + public void testM5() { testM(); } @Test - public void testST() throws Throwable { + public void testST() { verifyResults(randomSigma(), NO_MINIMUM, MIN_TOPSCORE, 0, 0); for (int i = 0; i < NUM_TESTS; i++) { @@ -415,32 +419,32 @@ public class StatisticalRuleTest { } @Test - public void testST1() throws Throwable { + public void testST1() { testST(); } @Test - public void testST2() throws Throwable { + public void testST2() { testST(); } @Test - public void testST3() throws Throwable { + public void testST3() { testST(); } @Test - public void testST4() throws Throwable { + public void testST4() { testST(); } @Test - public void testST5() throws Throwable { + public void testST5() { testST(); } @Test - public void testTS() throws Throwable { + public void testTS() { verifyResults(MAX_SIGMA, NO_MINIMUM, randomTopScore(), 0, 0); for (int i = 0; i < NUM_TESTS; i++) { @@ -452,32 +456,32 @@ public class StatisticalRuleTest { } @Test - public void testTS1() throws Throwable { + public void testTS1() { testTS(); } @Test - public void testTS2() throws Throwable { + public void testTS2() { testTS(); } @Test - public void testTS3() throws Throwable { + public void testTS3() { testTS(); } @Test - public void testTS4() throws Throwable { + public void testTS4() { testTS(); } @Test - public void testTS5() throws Throwable { + public void testTS5() { testTS(); } @Test - public void testSM() throws Throwable { + public void testSM() { verifyResults(randomSigma(), MAX_MINIMUM, NO_TOPSCORE, 0, 0); for (int i = 0; i < NUM_TESTS; i++) { double sigma = randomSigma(); @@ -489,32 +493,32 @@ public class StatisticalRuleTest { } @Test - public void testSM1() throws Throwable { + public void testSM1() { testSM(); } @Test - public void testSM2() throws Throwable { + public void testSM2() { testSM(); } @Test - public void testSM3() throws Throwable { + public void testSM3() { testSM(); } @Test - public void testSM4() throws Throwable { + public void testSM4() { testSM(); } @Test - public void testSM5() throws Throwable { + public void testSM5() { testSM(); } @Test - public void testMS() throws Throwable { + public void testMS() { verifyResults(MAX_SIGMA, randomMinimum(), NO_TOPSCORE, 0, 0); for (int i = 0; i < NUM_TESTS; i++) { double minimum = randomMinimum(); @@ -525,32 +529,32 @@ public class StatisticalRuleTest { } @Test - public void testMS1() throws Throwable { + public void testMS1() { testMS(); } @Test - public void testMS2() throws Throwable { + public void testMS2() { testMS(); } @Test - public void testMS3() throws Throwable { + public void testMS3() { testMS(); } @Test - public void testMS4() throws Throwable { + public void testMS4() { testMS(); } @Test - public void testMS5() throws Throwable { + public void testMS5() { testMS(); } @Test - public void testTM() throws Throwable { + public void testTM() { verifyResults(NO_SIGMA, MAX_MINIMUM, randomTopScore(), 0, 0); for (int i = 0; i < NUM_TESTS; i++) { int topScore = randomTopScore(); @@ -561,32 +565,32 @@ public class StatisticalRuleTest { } @Test - public void testTM1() throws Throwable { + public void testTM1() { testTM(); } @Test - public void testTM2() throws Throwable { + public void testTM2() { testTM(); } @Test - public void testTM3() throws Throwable { + public void testTM3() { testTM(); } @Test - public void testTM4() throws Throwable { + public void testTM4() { testTM(); } @Test - public void testTM5() throws Throwable { + public void testTM5() { testTM(); } @Test - public void testMT() throws Throwable { + public void testMT() { verifyResults(NO_SIGMA, randomMinimum(), MIN_TOPSCORE, 0, 0); for (int i = 0; i < NUM_TESTS; i++) { double minimum = randomMinimum(); @@ -597,32 +601,32 @@ public class StatisticalRuleTest { } @Test - public void testMT1() throws Throwable { + public void testMT1() { testMT(); } @Test - public void testMT2() throws Throwable { + public void testMT2() { testMT(); } @Test - public void testMT3() throws Throwable { + public void testMT3() { testMT(); } @Test - public void testMT4() throws Throwable { + public void testMT4() { testMT(); } @Test - public void testMT5() throws Throwable { + public void testMT5() { testMT(); } @Test - public void testSTM() throws Throwable { + public void testSTM() { double sigma = randomSigma(); verifyResults(sigma, MAX_MINIMUM, randomTopScore(expectedSigma(sigma)), 0, 0); @@ -636,32 +640,32 @@ public class StatisticalRuleTest { } @Test - public void testSTM1() throws Throwable { + public void testSTM1() { testSTM(); } @Test - public void testSTM2() throws Throwable { + public void testSTM2() { testSTM(); } @Test - public void testSTM3() throws Throwable { + public void testSTM3() { testSTM(); } @Test - public void testSTM4() throws Throwable { + public void testSTM4() { testSTM(); } @Test - public void testSTM5() throws Throwable { + public void testSTM5() { testSTM(); } @Test - public void testSMT() throws Throwable { + public void testSMT() { double sigma = randomSigma(); verifyResults(sigma, randomMinimum(expectedSigma(sigma)), MIN_TOPSCORE, 0, 0); @@ -675,27 +679,27 @@ public class StatisticalRuleTest { } @Test - public void testSMT1() throws Throwable { + public void testSMT1() { testSMT(); } @Test - public void testSMT2() throws Throwable { + public void testSMT2() { testSMT(); } @Test - public void testSMT3() throws Throwable { + public void testSMT3() { testSMT(); } @Test - public void testSMT4() throws Throwable { + public void testSMT4() { testSMT(); } @Test - public void testSMT5() throws Throwable { + public void testSMT5() { testSMT(); } @@ -704,7 +708,7 @@ public class StatisticalRuleTest { // tests are disabled in regress mode until somebody figures out // what the tests are supposed to measure and why they sometime fail @Ignore("random failures during continuous integration") - public void testTSM() throws Throwable { + public void testTSM() { int topScore = randomTopScore(); verifyResults(randomSigma(expectedTopScore(topScore)), MAX_MINIMUM, topScore, 0, 0); @@ -719,36 +723,36 @@ public class StatisticalRuleTest { @Test @Ignore("random failures during continuous integration") - public void testTSM1() throws Throwable { + public void testTSM1() { testTSM(); } @Test @Ignore("random failures during continuous integration") - public void testTSM2() throws Throwable { + public void testTSM2() { testTSM(); } @Test @Ignore("random failures during continuous integration") - public void testTSM3() throws Throwable { + public void testTSM3() { testTSM(); } @Test @Ignore("random failures during continuous integration") - public void testTSM4() throws Throwable { + public void testTSM4() { testTSM(); } @Test @Ignore("random failures during continuous integration") - public void testTSM5() throws Throwable { + public void testTSM5() { testTSM(); } @Test - public void testTMS() throws Throwable { + public void testTMS() { int topScore = randomTopScore(); verifyResults(MAX_SIGMA, randomMinimum(expectedTopScore(topScore)), topScore, 0, 0); @@ -762,27 +766,27 @@ public class StatisticalRuleTest { } @Test - public void testTMS1() throws Throwable { + public void testTMS1() { testTMS(); } @Test - public void testTMS2() throws Throwable { + public void testTMS2() { testTMS(); } @Test - public void testTMS3() throws Throwable { + public void testTMS3() { testTMS(); } @Test - public void testTMS4() throws Throwable { + public void testTMS4() { testTMS(); } @Test - public void testTMS5() throws Throwable { + public void testTMS5() { testTMS(); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/CompoundListTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/CompoundListTest.java index 4562dd5a1b..e5be745820 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/CompoundListTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/CompoundListTest.java @@ -4,6 +4,10 @@ package net.sourceforge.pmd.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -12,10 +16,6 @@ import java.util.NoSuchElementException; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class CompoundListTest { private List l1; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/DateTimeUtilTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/DateTimeUtilTest.java index 059dd76e23..61d66292cb 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/DateTimeUtilTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/DateTimeUtilTest.java @@ -4,16 +4,16 @@ package net.sourceforge.pmd.util; +import static org.junit.Assert.assertEquals; + import java.util.Collection; import org.junit.Test; import net.sourceforge.pmd.ReadableDurationTest; -import static org.junit.Assert.assertEquals; - /** - * + * * @author Brian Remedios */ public class DateTimeUtilTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/StringUtilTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/StringUtilTest.java index 8c91cb7bcf..a12b1b03f9 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/StringUtilTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/StringUtilTest.java @@ -4,10 +4,10 @@ package net.sourceforge.pmd.util; -import org.junit.Test; - import static org.junit.Assert.assertEquals; +import org.junit.Test; + public class StringUtilTest { @Test diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/TypeMapTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/TypeMapTest.java index d5601821eb..323744c094 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/TypeMapTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/TypeMapTest.java @@ -1,6 +1,8 @@ package net.sourceforge.pmd.util; +import static org.junit.Assert.fail; + import java.util.HashMap; import java.util.List; import java.util.Map; @@ -9,11 +11,9 @@ import org.junit.Test; import junit.framework.Assert; -import static org.junit.Assert.fail; - /** * Evaluates all major functionality of the TypeMap class. - * + * * @author Brian Remedios */ public class TypeMapTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/database/DBMSMetadataTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/database/DBMSMetadataTest.java index b2fafb615d..6a644e470c 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/database/DBMSMetadataTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/database/DBMSMetadataTest.java @@ -28,19 +28,19 @@ import org.junit.Test; @Ignore public class DBMSMetadataTest { - final static String C_ORACLE_THIN_1 = "jdbc:oracle:thin:scott/tiger@//192.168.100.21:5521/customer_db?characterset=utf8&schemas=scott,hr,sh,system&objectTypes=procedures,functions,triggers,package,types&languages=plsql,java&name=PKG_%25%7C%7CPRC_%25"; + static final String C_ORACLE_THIN_1 = "jdbc:oracle:thin:scott/tiger@//192.168.100.21:5521/customer_db?characterset=utf8&schemas=scott,hr,sh,system&objectTypes=procedures,functions,triggers,package,types&languages=plsql,java&name=PKG_%25%7C%7CPRC_%25"; - final static String C_ORACLE_THIN_3 = "jdbc:oracle:thin:scott/oracle@//192.168.100.21:1521/orcl?characterset=utf8&schemas=scott,hr,sh,system&objectTypes=procedures,functions,triggers,package,types&languages=plsql,java&name=PKG_%25%7C%7CPRC_%25"; + static final String C_ORACLE_THIN_3 = "jdbc:oracle:thin:scott/oracle@//192.168.100.21:1521/orcl?characterset=utf8&schemas=scott,hr,sh,system&objectTypes=procedures,functions,triggers,package,types&languages=plsql,java&name=PKG_%25%7C%7CPRC_%25"; - final static String C_ORACLE_THIN_4 = "jdbc:oracle:thin:system/oracle@//192.168.100.21:1521/ORCL?characterset=utf8&schemas=scott,hr,sh,system&objectTypes=procedures,functions,triggers,package,types&languages=plsql,java&name=PKG_%25%7C%7CPRC_%25"; + static final String C_ORACLE_THIN_4 = "jdbc:oracle:thin:system/oracle@//192.168.100.21:1521/ORCL?characterset=utf8&schemas=scott,hr,sh,system&objectTypes=procedures,functions,triggers,package,types&languages=plsql,java&name=PKG_%25%7C%7CPRC_%25"; - final static String C_ORACLE_THIN_5 = "jdbc:oracle:thin:@//192.168.100.21:1521/ORCL?characterset=utf8&schemas=scott,hr,sh,system&objectTypes=procedures,functions,triggers,package,types&languages=plsql,java&name=PKG_%25%7C%7CPRC_%25&user=system&password=oracle"; + static final String C_ORACLE_THIN_5 = "jdbc:oracle:thin:@//192.168.100.21:1521/ORCL?characterset=utf8&schemas=scott,hr,sh,system&objectTypes=procedures,functions,triggers,package,types&languages=plsql,java&name=PKG_%25%7C%7CPRC_%25&user=system&password=oracle"; /** * URI with minimum information, relying on defaults in * testdefaults.properties */ - final static String C_TEST_DEFAULTS = "jdbc:oracle:testdefault://192.168.100.21:1521/ORCL"; + static final String C_TEST_DEFAULTS = "jdbc:oracle:testdefault://192.168.100.21:1521/ORCL"; private DBURI dbURI; private DBURI dbURI4; @@ -186,10 +186,10 @@ public class DBMSMetadataTest { * result.read(charArray)) > 0 ) { * System.out.println("Reader.read(CharArray)=="+readChars); * stringBuilder.append(charArray, 0, readChars); } result.close(); - * + * * System.out.println("getSourceCode()==\""+stringBuilder.toString()+ * "\"" ); - * + * * assertTrue(stringBuilder.toString().startsWith("\n CREATE ")); */ diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/database/DBURITest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/database/DBURITest.java index 3195e3e568..f030633fb3 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/database/DBURITest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/database/DBURITest.java @@ -4,6 +4,8 @@ package net.sourceforge.pmd.util.database; +import static org.junit.Assert.assertEquals; + import java.net.URI; import java.net.URISyntaxException; import java.util.Arrays; @@ -13,8 +15,6 @@ import java.util.Map; import org.junit.Test; -import static org.junit.Assert.assertEquals; - /** * * @author sturton @@ -25,47 +25,47 @@ public class DBURITest { * URI with minimum information, relying on defaults in * testdefaults.properties */ - final static String C_TEST_DEFAULTS = "jdbc:oracle:testdefault://192.168.100.21:1521/ORCL"; + static final String C_TEST_DEFAULTS = "jdbc:oracle:testdefault://192.168.100.21:1521/ORCL"; /* * Expected values from testdefaults.properties */ - final static String C_DEFAULT_USER = "scott"; - final static String C_DEFAULT_PASSWORD = "tiger"; - final static String C_DEFAULT_LANGUAGES = "java,plsql"; - final static String C_DEFAULT_SCHEMAS = "scott,system"; - final static String C_DEFAULT_SOURCE_CODE_TYPES = "table,view"; - final static String C_DEFAULT_SOURCE_CODE_NAMES = "emp,dept"; - final static String C_DEFAULT_CHARACTERSET = "utf8"; + static final String C_DEFAULT_USER = "scott"; + static final String C_DEFAULT_PASSWORD = "tiger"; + static final String C_DEFAULT_LANGUAGES = "java,plsql"; + static final String C_DEFAULT_SCHEMAS = "scott,system"; + static final String C_DEFAULT_SOURCE_CODE_TYPES = "table,view"; + static final String C_DEFAULT_SOURCE_CODE_NAMES = "emp,dept"; + static final String C_DEFAULT_CHARACTERSET = "utf8"; /** * Fully specified URI, overriding defaults in testdefaults.properties */ - final static String C_TEST_EXPLICIT = "jdbc:oracle:testdefault:system/oracle@//192.168.100.21:1521/ORCL?characterset=us7ascii&schemas=scott,hr,sh,system&sourcecodetypes=procedures,functions,triggers,package,types&languages=plsql,java&sourcecodenames=PKG_%25%25,PRC_%25%25"; + static final String C_TEST_EXPLICIT = "jdbc:oracle:testdefault:system/oracle@//192.168.100.21:1521/ORCL?characterset=us7ascii&schemas=scott,hr,sh,system&sourcecodetypes=procedures,functions,triggers,package,types&languages=plsql,java&sourcecodenames=PKG_%25%25,PRC_%25%25"; /* * Expected values from testdefaults.properties, with values overridden by * URI query parameters */ - final static String C_EXPLICIT_USER = "system"; - final static String C_EXPLICIT_PASSWORD = "oracle"; - final static String C_EXPLICIT_LANGUAGES = "plsql,java"; - final static String C_EXPLICIT_SCHEMAS = "scott,hr,sh,system"; - final static String C_EXPLICIT_SOURCE_CODE_TYPES = "procedures,functions,triggers,package,types"; - final static String C_EXPLICIT_SOURCE_CODE_NAMES = "PKG_%%,PRC_%%"; - final static String C_EXPLICIT_CHARACTERSET = "us7ascii"; + static final String C_EXPLICIT_USER = "system"; + static final String C_EXPLICIT_PASSWORD = "oracle"; + static final String C_EXPLICIT_LANGUAGES = "plsql,java"; + static final String C_EXPLICIT_SCHEMAS = "scott,hr,sh,system"; + static final String C_EXPLICIT_SOURCE_CODE_TYPES = "procedures,functions,triggers,package,types"; + static final String C_EXPLICIT_SOURCE_CODE_NAMES = "PKG_%%,PRC_%%"; + static final String C_EXPLICIT_CHARACTERSET = "us7ascii"; - final static String C_TEST_URI = "test?param1=x%261¶m2=¶m3="; - final static String C_ORACLE_OCI_1 = "jdbc:oracle:oci:system/oracle@//192.168.100.21:1521/ORCL"; - final static String C_ORACLE_OCI_2 = "jdbc:oracle:oci:system/oracle@//192.168.100.21:1521/ORCL?characterset=utf8&schemas=scott,hr,sh,system&sourcecodetypes=procedures,functions,triggers,package,types&languages=plsql,java"; - final static String C_ORACLE_OCI_3 = "jdbc:oracle:oci:system/oracle@//myserver.com:1521/customer_db?characterset=utf8&schemas=scott,hr,sh,system&sourcecodetypes=procedures,functions,triggers,package,types&languages=plsql,java&sourcecodenames=PKG_%25%25,PRC_%25%25"; + static final String C_TEST_URI = "test?param1=x%261¶m2=¶m3="; + static final String C_ORACLE_OCI_1 = "jdbc:oracle:oci:system/oracle@//192.168.100.21:1521/ORCL"; + static final String C_ORACLE_OCI_2 = "jdbc:oracle:oci:system/oracle@//192.168.100.21:1521/ORCL?characterset=utf8&schemas=scott,hr,sh,system&sourcecodetypes=procedures,functions,triggers,package,types&languages=plsql,java"; + static final String C_ORACLE_OCI_3 = "jdbc:oracle:oci:system/oracle@//myserver.com:1521/customer_db?characterset=utf8&schemas=scott,hr,sh,system&sourcecodetypes=procedures,functions,triggers,package,types&languages=plsql,java&sourcecodenames=PKG_%25%25,PRC_%25%25"; - final static String C_ORACLE_THIN_1 = "jdbc:oracle:thin:system/oracle@//192.168.100.21:1521/ORCL"; - final static String C_ORACLE_THIN_2 = "jdbc:oracle:thin:system/oracle@//192.168.100.21:1521/ORCL?characterset=utf8&schemas=scott,hr,sh,system&sourcecodetypes=procedures,functions,triggers,package,types&languages=plsql,java"; - final static String C_ORACLE_THIN_3 = "jdbc:oracle:thin:system/oracle@//myserver.com:1521/customer_db?characterset=utf8&schemas=scott,hr,sh,system&sourcecodetypes=procedures,functions,triggers,package,types&languages=plsql,java&sourcecodenames=PKG_%25%25,PRC_%25%25"; + static final String C_ORACLE_THIN_1 = "jdbc:oracle:thin:system/oracle@//192.168.100.21:1521/ORCL"; + static final String C_ORACLE_THIN_2 = "jdbc:oracle:thin:system/oracle@//192.168.100.21:1521/ORCL?characterset=utf8&schemas=scott,hr,sh,system&sourcecodetypes=procedures,functions,triggers,package,types&languages=plsql,java"; + static final String C_ORACLE_THIN_3 = "jdbc:oracle:thin:system/oracle@//myserver.com:1521/customer_db?characterset=utf8&schemas=scott,hr,sh,system&sourcecodetypes=procedures,functions,triggers,package,types&languages=plsql,java&sourcecodenames=PKG_%25%25,PRC_%25%25"; - final static String C_POSTGRES_1 = "jdbc:postgresql://host/database"; - final static String C_HTTP = "http://localhost:80?characterset=utf8&schemas=scott,hr,sh,system&sourcecodetypes=procedures,functions,triggers,package,types&languages=plsql,java"; + static final String C_POSTGRES_1 = "jdbc:postgresql://host/database"; + static final String C_HTTP = "http://localhost:80?characterset=utf8&schemas=scott,hr,sh,system&sourcecodetypes=procedures,functions,triggers,package,types&languages=plsql,java"; static void dump(String description, URI dburi) { System.err.printf( diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/designer/DesignerTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/designer/DesignerTest.java index ff68d1121f..631257e21d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/designer/DesignerTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/designer/DesignerTest.java @@ -4,14 +4,14 @@ package net.sourceforge.pmd.util.designer; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.ast.Node; -import static org.junit.Assert.assertEquals; - /** * Unit tests for {@link Designer} */ diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/filter/RegexStringFilterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/filter/RegexStringFilterTest.java index e8ba442ab6..0427c16b14 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/filter/RegexStringFilterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/filter/RegexStringFilterTest.java @@ -4,12 +4,12 @@ package net.sourceforge.pmd.util.filter; -import org.junit.Test; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import org.junit.Test; + public class RegexStringFilterTest { @Test

    Examples