pmd-core: Further code formatting, clean-up
This commit is contained in:
@ -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 <code>true</code> then PMD
|
||||
* will log debug information.
|
||||
*
|
||||
*
|
||||
* @return <code>true</code> if debug logging is enabled, <code>false</code>
|
||||
* otherwise.
|
||||
*/
|
||||
@ -53,7 +53,7 @@ public abstract class AbstractConfiguration {
|
||||
|
||||
/**
|
||||
* Set the debug indicator.
|
||||
*
|
||||
*
|
||||
* @param debug
|
||||
* The debug indicator to set.
|
||||
* @see #isDebug()
|
||||
|
@ -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<PropertyDescriptor<?>> 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<PropertyDescriptor<?>, Object> copyPropertyValues() {
|
||||
@ -48,6 +48,7 @@ public abstract class AbstractPropertySource implements PropertySource {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<PropertyDescriptor<?>> 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();
|
||||
|
@ -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 <T>
|
||||
@ -16,14 +16,14 @@ public interface NumericPropertyDescriptor<T extends Object> 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();
|
||||
|
@ -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 <code>0</code> 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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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
|
||||
|
@ -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 <T>
|
||||
*/
|
||||
@ -19,7 +19,7 @@ public interface PropertyDescriptor<T extends Object> extends Comparable<Propert
|
||||
/**
|
||||
* The name of the property without spaces as it serves as the key into the
|
||||
* property map.
|
||||
*
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String name();
|
||||
@ -27,26 +27,26 @@ public interface PropertyDescriptor<T extends Object> extends Comparable<Propert
|
||||
/**
|
||||
* Describes the property and the role it plays within the rule it is
|
||||
* specified for. Could be used in a tooltip.
|
||||
*
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String description();
|
||||
|
||||
/**
|
||||
* Denotes the value datatype.
|
||||
*
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
Class<T> 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<T extends Object> extends Comparable<Propert
|
||||
/**
|
||||
* Default value to use when the user hasn't specified one or when they wish
|
||||
* to revert to a known-good state.
|
||||
*
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
T defaultValue();
|
||||
@ -62,7 +62,7 @@ public interface PropertyDescriptor<T extends Object> extends Comparable<Propert
|
||||
/**
|
||||
* Denotes whether the value is required before the rule can be executed.
|
||||
* Has no meaning for primitive types such as booleans, ints, etc.
|
||||
*
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean isRequired();
|
||||
@ -70,7 +70,7 @@ public interface PropertyDescriptor<T extends Object> extends Comparable<Propert
|
||||
/**
|
||||
* Validation function that returns a diagnostic error message for a sample
|
||||
* property value. Returns null if the value is acceptable.
|
||||
*
|
||||
*
|
||||
* @param value
|
||||
* Object
|
||||
* @return String
|
||||
@ -82,13 +82,13 @@ public interface PropertyDescriptor<T extends Object> extends Comparable<Propert
|
||||
* using an auto-generated UI to display and edit property values. If the
|
||||
* value returned has a non-zero fractional part then this is can be used to
|
||||
* place adjacent fields on the same row. Example:
|
||||
*
|
||||
*
|
||||
* name -> 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<T extends Object> extends Comparable<Propert
|
||||
* If the property is multi-valued then return the separate values after
|
||||
* parsing the propertyString provided. If it isn't a multi-valued property
|
||||
* then the value will be returned within an array of size[1].
|
||||
*
|
||||
*
|
||||
* @param propertyString
|
||||
* String
|
||||
* @return Object
|
||||
@ -109,7 +109,7 @@ public interface PropertyDescriptor<T extends Object> extends Comparable<Propert
|
||||
/**
|
||||
* Formats the object onto a string suitable for storage within the property
|
||||
* map.
|
||||
*
|
||||
*
|
||||
* @param value
|
||||
* Object
|
||||
* @return String
|
||||
@ -119,7 +119,7 @@ public interface PropertyDescriptor<T extends Object> extends Comparable<Propert
|
||||
/**
|
||||
* Returns a set of choice tuples if available, returns null if none are
|
||||
* defined.
|
||||
*
|
||||
*
|
||||
* @return Object[][]
|
||||
*/
|
||||
Object[][] choices();
|
||||
@ -127,7 +127,7 @@ public interface PropertyDescriptor<T extends Object> extends Comparable<Propert
|
||||
/**
|
||||
* A convenience method that returns an error string if the rule holds onto
|
||||
* a property value that has a problem. Returns null otherwise.
|
||||
*
|
||||
*
|
||||
* @param rule
|
||||
* Rule
|
||||
* @return String
|
||||
@ -138,7 +138,7 @@ public interface PropertyDescriptor<T extends Object> extends Comparable<Propert
|
||||
* Return the character being used to delimit multiple property values
|
||||
* within a single string. You must ensure that this character does not
|
||||
* appear within any rule property values to avoid deserialization errors.
|
||||
*
|
||||
*
|
||||
* @return char
|
||||
*/
|
||||
char multiValueDelimiter();
|
||||
@ -147,7 +147,7 @@ public interface PropertyDescriptor<T extends Object> extends Comparable<Propert
|
||||
* If the datatype is a String then return the preferred number of rows to
|
||||
* allocate in the text widget, returns a value of one for all other types.
|
||||
* Useful for multi-line XPATH editors.
|
||||
*
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int preferredRowCount();
|
||||
@ -155,7 +155,7 @@ public interface PropertyDescriptor<T extends Object> extends Comparable<Propert
|
||||
/**
|
||||
* Returns a map representing all the property attributes of the receiver in
|
||||
* string form.
|
||||
*
|
||||
*
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
Map<String, String> attributeValuesById();
|
||||
|
@ -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<String, Boolean> 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}
|
||||
|
@ -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";
|
||||
|
@ -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, <code>null</code>
|
||||
@ -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<PropertyDescriptor<?>> getPropertyDescriptors();
|
||||
|
||||
/**
|
||||
* Get the typed value for the given property.
|
||||
*
|
||||
*
|
||||
* @param <T>
|
||||
* 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 <T>
|
||||
* 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<PropertyDescriptor<?>, Object> getPropertiesByPropertyDescriptor();
|
||||
|
||||
/**
|
||||
* Returns whether this Rule has the specified PropertyDescriptor.
|
||||
*
|
||||
*
|
||||
* @param descriptor
|
||||
* The PropertyDescriptor for which to check.
|
||||
* @return boolean <code>true</code> if the descriptor is present,
|
||||
@ -87,7 +87,7 @@ public interface PropertySource {
|
||||
|
||||
/**
|
||||
* Returns whether this Rule uses default values for properties.
|
||||
*
|
||||
*
|
||||
* @return boolean <code>true</code> if the properties all have default
|
||||
* values, <code>false</code> 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<PropertyDescriptor<?>> 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();
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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 <code>null</code> 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 <code>null</code> 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 {
|
||||
* <li>or, has been renamed/moved and the old name will be completely
|
||||
* removed in a future version of PMD</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @return <code>true</code> 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
|
||||
* <code>null</code> 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<String> 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 <code>true</code> 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 <code>true</code> 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 <code>true</code> 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<String> 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
|
||||
*/
|
||||
|
@ -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
|
||||
|
@ -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 <code>null</code>, 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, <code>null</code> if unknown.
|
||||
*/
|
||||
public LanguageVersion getLanguageVersion() {
|
||||
@ -224,7 +224,7 @@ public class RuleContext {
|
||||
* If set to <code>false</code> 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 <code>true</code> simply skip failing rules (default).
|
||||
*/
|
||||
@ -236,7 +236,7 @@ public class RuleContext {
|
||||
* Gets the configuration whether to skip failing rules (<code>true</code>)
|
||||
* or whether to throw a a RuntimeException and abort the processing for the
|
||||
* first failing rule.
|
||||
*
|
||||
*
|
||||
* @return <code>true</code> when failing rules are skipped,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
|
@ -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()
|
||||
*/
|
||||
|
@ -524,7 +524,7 @@ public class RuleSet {
|
||||
|
||||
private void patternsChanged() {
|
||||
filter = null; // ensure we start with one that reflects the current
|
||||
// patterns
|
||||
// patterns
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
* <code>true</code> 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<String, Boolean> 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
|
||||
|
@ -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<RuleSetFilter> filters = new LinkedList<RuleSetFilter>();
|
||||
private List<RuleSetFilter> 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()) {
|
||||
|
@ -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
|
||||
* <i>ruleSetName</i>, where the RuleSet name is either a resource file path to
|
||||
* a RuleSet that ends with <code>'.xml'</code>.</li>, 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 <code>[language]-[name]</code> is short for the full RuleSet name
|
||||
* <code>rulesets/[language]/[name].xml</code>. A numeric release simple name of
|
||||
* the form <code>[release]</code> is short for the full PMD Release RuleSet
|
||||
* name <code>rulesets/releases/[release].xml</code>.
|
||||
*
|
||||
*
|
||||
* For an external RuleSet, referring to a single Rule, the format is
|
||||
* <i>ruleSetName/ruleName</i>, where the RuleSet name is as described above. A
|
||||
* Rule with the <i>ruleName</i> should exist in this external RuleSet.
|
||||
*
|
||||
*
|
||||
* For the current RuleSet, the format is <i>ruleName</i>, 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 <i>ruleName</i> should exist in the
|
||||
* current RuleSet.
|
||||
*
|
||||
*
|
||||
* <table>
|
||||
* <caption>Examples</caption> <thead>
|
||||
* <tr>
|
||||
@ -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 <code>true</code> 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, <code>null</code> is returned.
|
||||
*
|
||||
*
|
||||
* @param rulesetName
|
||||
* the full rule set path
|
||||
* @return the rule name or <code>null</code>.
|
||||
@ -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 <code>true</code> if this is an external reference,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
@ -366,7 +366,7 @@ public class RuleSetReferenceId {
|
||||
|
||||
/**
|
||||
* Is this a reference to all Rules in a RuleSet, or a single Rule?
|
||||
*
|
||||
*
|
||||
* @return <code>true</code> if this is a reference to all Rules,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
@ -376,7 +376,7 @@ public class RuleSetReferenceId {
|
||||
|
||||
/**
|
||||
* Get the RuleSet file name.
|
||||
*
|
||||
*
|
||||
* @return The RuleSet file name if this is an external reference,
|
||||
* <code>null</code> 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
|
||||
* <i>ruleSetFileName</i> for all Rule external references,
|
||||
* <i>ruleSetFileName/ruleName</i>, for a single Rule external
|
||||
* references, or <i>ruleName</i> otherwise.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (ruleSetFileName != null) {
|
||||
if (allRules) {
|
||||
|
@ -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))) {
|
||||
|
@ -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 <code>true</code> 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<Rule> collector) {
|
||||
|
@ -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 <code>true</code> if this violation is suppressed,
|
||||
* <code>false</code> 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();
|
||||
|
@ -25,6 +25,7 @@ public final class RuleViolationComparator implements Comparator<RuleViolation>
|
||||
private RuleViolationComparator() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(final RuleViolation r1, final RuleViolation r2) {
|
||||
int cmp = r1.getFilename().compareTo(r2.getFilename());
|
||||
if (cmp == 0) {
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ public class SourceLanguage {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "<sourceLanguage name=\"" + this.name + "\" version=\"" + this.version + "\" />";
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<RuleDuration> stressResults, PrintStream out);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param benchmarksByName
|
||||
* @param out
|
||||
*/
|
||||
|
@ -11,12 +11,12 @@ class BenchmarkResult implements Comparable<BenchmarkResult> {
|
||||
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<BenchmarkResult> {
|
||||
this.count += count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(BenchmarkResult benchmarkResult) {
|
||||
int cmp = type.index - benchmarkResult.type.index;
|
||||
if (cmp == 0) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user