diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/CycloMetric.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/CycloMetric.java index 13e2796c7f..6e60120f87 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/CycloMetric.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/CycloMetric.java @@ -29,7 +29,7 @@ public class CycloMetric extends AbstractApexOperationMetric { public double computeFor(ASTMethod node, MetricOptions options) { return ((MutableInt) node.jjtAccept(new StandardCycloVisitor(), new MutableInt(1))).doubleValue(); } - + /** * Computes the number of control flow paths through that expression, which is the number of {@code ||} and {@code diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexUnitTestRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexUnitTestRule.java index 0287220a42..366b58229f 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexUnitTestRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexUnitTestRule.java @@ -12,7 +12,7 @@ import apex.jorje.services.Version; /** * Do special checks for apex unit test classes and methods - * + * * @author a.subramanian */ public abstract class AbstractApexUnitTestRule extends AbstractApexRule { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsRule.java index 9c551f951d..f7aa8e802c 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsRule.java @@ -32,7 +32,7 @@ public class MethodNamingConventionsRule extends AbstractNamingConventionsRule { .desc("deprecated! Skip underscores in test methods") .defaultValue(false) .build(); - + public MethodNamingConventionsRule() { definePropertyDescriptor(SKIP_TEST_METHOD_UNDERSCORES_DESCRIPTOR); definePropertyDescriptor(TEST_REGEX); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java index 8bb26c4d7b..3791a0d7c2 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java @@ -23,7 +23,7 @@ import net.sourceforge.pmd.properties.PropertyFactory; /** * Cyclomatic complexity rule using metrics. Uses Wmc to report classes. - * + * * @author Clément Fournier */ public class CyclomaticComplexityRule extends AbstractApexRule { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssConstructorCountRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssConstructorCountRule.java index 8d01b2c257..44cbc9c381 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssConstructorCountRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssConstructorCountRule.java @@ -8,7 +8,7 @@ import net.sourceforge.pmd.lang.apex.ast.ASTMethod; /** * Non-commented source statement counter for constructors. - * + * * @author ported from Java original by Jason Bennett */ public class NcssConstructorCountRule extends AbstractNcssCountRule { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssMethodCountRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssMethodCountRule.java index 9851390359..15b86516cd 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssMethodCountRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssMethodCountRule.java @@ -8,7 +8,7 @@ import net.sourceforge.pmd.lang.apex.ast.ASTMethod; /** * Non-commented source statement counter for methods. - * + * * @author ported from Java original of Jason Bennett */ public class NcssMethodCountRule extends AbstractNcssCountRule { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssTypeCountRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssTypeCountRule.java index 6e5ed6d834..f534a140fe 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssTypeCountRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssTypeCountRule.java @@ -8,7 +8,7 @@ import net.sourceforge.pmd.lang.apex.ast.ASTUserClass; /** * Non-commented source statement counter for type declarations. - * + * * @author ported from Java original of Jason Bennett */ public class NcssTypeCountRule extends AbstractNcssCountRule { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/StdCyclomaticComplexityRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/StdCyclomaticComplexityRule.java index a62d6c5129..244539584f 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/StdCyclomaticComplexityRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/StdCyclomaticComplexityRule.java @@ -32,10 +32,10 @@ import net.sourceforge.pmd.properties.PropertyFactory; *

* Standard rules: +1 for each decision point, but not including boolean * operators unlike CyclomaticComplexityRule. - * + * * @author ported on Java version of Alan Hohn, based on work by Donald A. * Leckie - * + * * @since June 18, 2014 */ public class StdCyclomaticComplexityRule extends AbstractApexRule { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidHardcodingIdRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidHardcodingIdRule.java index 39e6373ca8..bec4d78575 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidHardcodingIdRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidHardcodingIdRule.java @@ -15,18 +15,18 @@ import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule; public class AvoidHardcodingIdRule extends AbstractApexRule { private static final Pattern PATTERN = Pattern.compile("^[a-zA-Z0-9]{5}0[a-zA-Z0-9]{9}([a-zA-Z0-5]{3})?$"); private static final Map CHECKSUM_LOOKUP; - + static { final Map lookup = new HashMap<>(); final char[] chartable = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345".toCharArray(); - + for (int i = 0; i < chartable.length; i++) { lookup.put(String.format("%5s", Integer.toBinaryString(i)).replace(' ', '0'), chartable[i]); } - + CHECKSUM_LOOKUP = Collections.unmodifiableMap(lookup); } - + public AvoidHardcodingIdRule() { addRuleChainVisit(ASTLiteralExpression.class); } @@ -55,11 +55,11 @@ public class AvoidHardcodingIdRule extends AbstractApexRule { final String part1 = literal.substring(0, 5); final String part2 = literal.substring(5, 10); final String part3 = literal.substring(10, 15); - + final char checksum1 = checksum(part1); final char checksum2 = checksum(part2); final char checksum3 = checksum(part3); - + return literal.charAt(15) == checksum1 && literal.charAt(16) == checksum2 && literal.charAt(17) == checksum3; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/internal/Helper.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/internal/Helper.java index c8d53b21f1..c2145d05c7 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/internal/Helper.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/internal/Helper.java @@ -40,7 +40,7 @@ import apex.jorje.semantic.ast.statement.VariableDeclaration; /** * Helper methods - * + * * @author sergey.gorbaty * */ @@ -73,9 +73,9 @@ public final class Helper { /** * Finds DML operations in a given node descendants' path - * + * * @param node - * + * * @return true if found DML operations in node descendants */ public static boolean foundAnyDML(final ApexNode node) { @@ -165,7 +165,7 @@ public final class Helper { .append(n.getFieldInfo().getName()); return sb.toString(); } - + public static String getFQVariableName(final ASTFieldDeclaration variable) { StringBuilder sb = new StringBuilder() .append(variable.getNode().getDefiningType().getApexName()).append(":") diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointRule.java index f406c2ad9d..800145219f 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointRule.java @@ -22,7 +22,7 @@ import net.sourceforge.pmd.lang.apex.rule.internal.Helper; /** * Insecure HTTP endpoints passed to (req.setEndpoint) * req.setHeader('Authorization') should use named credentials - * + * * @author sergey.gorbaty * */ diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionRule.java index b190139e5f..19e0f5fd7f 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionRule.java @@ -30,7 +30,7 @@ import net.sourceforge.pmd.lang.apex.rule.internal.Helper; /** * Detects if variables in Database.query(variable) is escaped with * String.escapeSingleQuotes - * + * * @author sergey.gorbaty * */ diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java index ee43c7aabb..83639d66c0 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java @@ -16,7 +16,7 @@ import net.sourceforge.pmd.lang.apex.rule.internal.Helper; /** * Finds Apex class that do not define sharing - * + * * @author sergey.gorbaty */ public class ApexSharingViolationsRule extends AbstractApexRule { @@ -43,7 +43,7 @@ public class ApexSharingViolationsRule extends AbstractApexRule { /** * Check if class contains any Database.query / Database.insert [ Database.* * ] methods - * + * * @param node * @param data */ @@ -73,7 +73,7 @@ public class ApexSharingViolationsRule extends AbstractApexRule { /** * Check if class has no sharing declared - * + * * @param node * @param data */ @@ -86,7 +86,7 @@ public class ApexSharingViolationsRule extends AbstractApexRule { /** * Does class have sharing keyword declared? - * + * * @param node * @return */ diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredRule.java index 7ce1d05d8c..45c9bbac4a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredRule.java @@ -23,7 +23,7 @@ import net.sourceforge.pmd.lang.apex.rule.internal.Helper; * Flags usage of http request.setHeader('Authorization',..) and suggests using * named credentials which helps store credentials for the callout in a safe * place. - * + * * @author sergey.gorbaty * */ diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamRule.java index 7a77721ddf..99a200db03 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamRule.java @@ -24,7 +24,7 @@ import net.sourceforge.pmd.lang.apex.rule.internal.Helper; /** * Detects potential XSS when controller extracts a variable from URL query and * uses it without escaping first - * + * * @author sergey.gorbaty * */ diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/Helper.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/Helper.java index da4032cb63..cb83f24cae 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/Helper.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/Helper.java @@ -38,7 +38,7 @@ import apex.jorje.semantic.ast.statement.VariableDeclaration; /** * Helper methods - * + * * @author sergey.gorbaty * * @deprecated Use {@link net.sourceforge.pmd.lang.apex.rule.internal.Helper} instead. @@ -72,9 +72,9 @@ public final class Helper { /** * Finds DML operations in a given node descendants' path - * + * * @param node - * + * * @return true if found DML operations in node descendants */ static boolean foundAnyDML(final ApexNode node) { @@ -166,7 +166,7 @@ public final class Helper { .append(n.getFieldInfo().getName()); return sb.toString(); } - + static String getFQVariableName(final ASTFieldDeclaration variable) { StringBuilder sb = new StringBuilder() .append(variable.getNode().getDefiningType().getApexName()).append(":") diff --git a/pmd-apex/src/main/resources/category/apex/design.xml b/pmd-apex/src/main/resources/category/apex/design.xml index 53284d4e1d..1b87d42416 100644 --- a/pmd-apex/src/main/resources/category/apex/design.xml +++ b/pmd-apex/src/main/resources/category/apex/design.xml @@ -92,7 +92,7 @@ public class Complicated { class="net.sourceforge.pmd.lang.apex.rule.design.ExcessiveClassLengthRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_design.html#excessiveclasslength"> -Excessive class file lengths are usually indications that the class may be burdened with excessive +Excessive class file lengths are usually indications that the class may be burdened with excessive responsibilities that could be provided by external classes or functions. In breaking these methods apart the code becomes more managable and ripe for reuse. @@ -133,7 +133,7 @@ same datatype. These situations usually denote the need for new objects to wrap public void addPerson(int birthYear, int birthMonth, int birthDate, int height, int weight, int ssn) { // ... } -// preferred approach +// preferred approach public void addPerson(Date birthdate, BodyMeasurements measurements, int ssn) { // ... } @@ -260,8 +260,8 @@ public class Foo extends Bar { class="net.sourceforge.pmd.lang.apex.rule.design.StdCyclomaticComplexityRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_design.html#stdcyclomaticcomplexity"> -Complexity directly affects maintenance costs is determined by the number of decision points in a method -plus one for the method entry. The decision points include 'if', 'while', 'for', and 'case labels' calls. +Complexity directly affects maintenance costs is determined by the number of decision points in a method +plus one for the method entry. The decision points include 'if', 'while', 'for', and 'case labels' calls. Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote high complexity, and 11+ is very high complexity. @@ -315,7 +315,7 @@ public class Foo { externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_design.html#toomanyfields"> Classes that have too many fields can become unwieldy and could be redesigned to have fewer fields, -possibly through grouping related fields in new objects. For example, a class with individual +possibly through grouping related fields in new objects. For example, a class with individual city/state/zip fields could park them within a single Address field. 3 diff --git a/pmd-apex/src/main/resources/category/apex/errorprone.xml b/pmd-apex/src/main/resources/category/apex/errorprone.xml index 88e729b6f9..cd458821a1 100644 --- a/pmd-apex/src/main/resources/category/apex/errorprone.xml +++ b/pmd-apex/src/main/resources/category/apex/errorprone.xml @@ -71,8 +71,8 @@ Avoid directly accessing Trigger.old and Trigger.new as it can lead to a bug. Tr -Empty Catch Block finds instances where an exception is caught, but nothing is done. -In most circumstances, this swallows an exception which should either be acted on +Empty Catch Block finds instances where an exception is caught, but nothing is done. +In most circumstances, this swallows an exception which should either be acted on or reported. 3 @@ -261,7 +261,7 @@ public class Foo { class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_errorprone.html#emptywhilestmt"> -Empty While Statement finds all instances where a while statement does nothing. +Empty While Statement finds all instances where a while statement does nothing. If it is a timing loop, then you should use Thread.sleep() for it; if it is a while loop that does a lot in the exit expression, rewrite it to make it clearer. diff --git a/pmd-apex/src/main/resources/category/apex/performance.xml b/pmd-apex/src/main/resources/category/apex/performance.xml index 01c4191bf8..cc3fad8698 100644 --- a/pmd-apex/src/main/resources/category/apex/performance.xml +++ b/pmd-apex/src/main/resources/category/apex/performance.xml @@ -21,7 +21,7 @@ Avoid DML statements inside loops to avoid hitting the DML governor limit. Inste The rule validates you are checking for access permissions before a SOQL/SOSL/DML operation. -Since Apex runs in system mode not having proper permissions checks results in escalation of +Since Apex runs in system mode not having proper permissions checks results in escalation of privilege and may produce runtime errors. This check forces you to handle such scenarios. 3 diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexLexerTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexLexerTest.java index 9f767b1765..df56adb9d5 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexLexerTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexLexerTest.java @@ -27,7 +27,7 @@ public class ApexLexerTest { public void testLexer() throws Exception { CharStream in = new ANTLRStringStream(CODE); ApexLexer lexer = new ApexLexer(in); - + Token token = lexer.nextToken(); int tokenCount = 0; while (token.getType() != Token.EOF) { diff --git a/pmd-core/pom.xml b/pmd-core/pom.xml index f46e5bf834..bff2176537 100644 --- a/pmd-core/pom.xml +++ b/pmd-core/pom.xml @@ -101,8 +101,8 @@ antlr4-runtime - com.beust - jcommander + com.beust + jcommander commons-io @@ -196,14 +196,14 @@ - m2e - - - - m2e.version - - - + m2e + + + + m2e.version + + + - - - - idea.maven.embedder.version - - - + idea + + + + + idea.maven.embedder.version + + + jaxen jaxen false - + 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 6894c50daa..b5da5adf89 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java @@ -460,11 +460,11 @@ public class PMD { */ public static int run(final String[] args) { final PMDParameters params = PMDCommandLineInterface.extractParameters(new PMDParameters(), args, "pmd"); - + if (params.isBenchmark()) { TimeTracker.startGlobalTracking(); } - + int status = PMDCommandLineInterface.NO_ERRORS_STATUS; final PMDConfiguration configuration = params.toConfiguration(); @@ -490,7 +490,7 @@ public class PMD { } finally { logHandlerManager.close(); LOG.setLevel(oldLogLevel); - + if (params.isBenchmark()) { final TimingReport timingReport = TimeTracker.stopGlobalTracking(); 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 c83d47ee97..532d1b6575 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java @@ -581,7 +581,7 @@ public class PMDConfiguration extends AbstractConfiguration { /** * Retrieves the currently used analysis cache. Will never be null. - * + * * @return The currently used analysis cache. Never null. */ public AnalysisCache getAnalysisCache() { @@ -593,7 +593,7 @@ public class PMDConfiguration extends AbstractConfiguration { return analysisCache; } - + /** * Sets the analysis cache to be used. Setting a * value of {@code null} will cause a Noop AnalysisCache to be used. @@ -611,7 +611,7 @@ public class PMDConfiguration extends AbstractConfiguration { /** * Sets the location of the analysis cache to be used. This will automatically configure * and appropriate AnalysisCache implementation. - * + * * @param cacheLocation The location of the analysis cache to be used. */ public void setAnalysisCacheLocation(final String cacheLocation) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PMDVersion.java b/pmd-core/src/main/java/net/sourceforge/pmd/PMDVersion.java index 3e50b27392..e5a79a1f3d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PMDVersion.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PMDVersion.java @@ -16,14 +16,14 @@ import java.util.logging.Logger; public final class PMDVersion { private static final Logger LOG = Logger.getLogger(PMDVersion.class.getName()); - + /** * Constant that contains always the current version of PMD. */ public static final String VERSION; - + private static final String UNKNOWN_VERSION = "unknown"; - + /** * Determines the version from maven's generated pom.properties file. */ @@ -34,33 +34,33 @@ public final class PMDVersion { final Properties properties = new Properties(); properties.load(stream); pmdVersion = properties.getProperty("version"); - } + } } catch (final IOException e) { LOG.log(Level.FINE, "Couldn't determine version of PMD", e); } - + VERSION = pmdVersion; } - + private PMDVersion() { throw new AssertionError("Can't instantiate utility classes"); } - + /** * Retrieves the next major release to be expected. * Useful when logging deprecation messages to indicate when support will be removed. - * + * * @return The next major release to be expected. */ public static String getNextMajorRelease() { if (isUnknown()) { return UNKNOWN_VERSION; } - + final int major = Integer.parseInt(VERSION.split("\\.")[0]); return (major + 1) + ".0.0"; } - + /** * Checks if the current version is unknown. * @return True if an unknown version, false otherwise @@ -68,7 +68,7 @@ public final class PMDVersion { public static boolean isUnknown() { return UNKNOWN_VERSION.equals(VERSION); } - + /** * Checks if the current version is a snapshot. * @return True if a snapshot release, false otherwise 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 6d9f41e970..f7425da4b3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java @@ -454,21 +454,21 @@ public class RuleSetFactory { // This is the PRIMARY defense. If DTDs (doctypes) are disallowed, almost all XML entity attacks are prevented // Xerces 2 only - http://xerces.apache.org/xerces2-j/features.html#disallow-doctype-decl dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - + // If you can't completely disable DTDs, then at least do the following: // Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-general-entities // Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-general-entities - // JDK7+ - http://xml.org/sax/features/external-general-entities + // JDK7+ - http://xml.org/sax/features/external-general-entities dbf.setFeature("http://xml.org/sax/features/external-general-entities", false); - + // Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-parameter-entities // Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-parameter-entities - // JDK7+ - http://xml.org/sax/features/external-parameter-entities + // JDK7+ - http://xml.org/sax/features/external-parameter-entities dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false); - + // Disable external DTDs as well dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); - + // and these as well, per Timothy Morgan's 2014 paper: "XML Schema, DTD, and Entity Attacks" dbf.setXIncludeAware(false); dbf.setExpandEntityReferences(false); @@ -476,7 +476,7 @@ public class RuleSetFactory { // an unsupported feature... too bad, but won't fail execution due to this LOG.log(Level.WARNING, "Ignored unsupported XML Parser Feature for parsing rulesets", e); } - + return dbf.newDocumentBuilder(); } 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 8e7c06cef8..122a368d14 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactoryCompatibility.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactoryCompatibility.java @@ -61,7 +61,7 @@ public class RuleSetFactoryCompatibility { addFilterRuleMoved("java", "basic", "unnecessary", "UselessOperationOnImmutable"); addFilterRuleMoved("java", "basic", "unnecessary", "UnusedNullCheckInEquals"); addFilterRuleMoved("java", "basic", "unnecessary", "UselessParentheses"); - + // PMD 5.6.0 addFilterRuleRenamed("java", "design", "AvoidConstantsInterface", "ConstantsInInterface"); // unused/UnusedModifier moved AND renamed, order is important! 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 482687f4ab..1747233922 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSets.java @@ -258,7 +258,7 @@ public class RuleSets { /** * Retrieves a checksum of the rulesets being used. Any change to any rule * of any ruleset should trigger a checksum change. - * + * * @return The checksum for this ruleset collection. */ public long getChecksum() { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/ThreadSafeReportListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/ThreadSafeReportListener.java index c0a1334478..f15af5dfb5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/ThreadSafeReportListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/ThreadSafeReportListener.java @@ -7,7 +7,7 @@ package net.sourceforge.pmd; /** * Marker interface for report listeners that, being thread-safe, need not * extra synchronization. - * + * * Thread-safety is required only for concurrently notifying about different files. * Same file violations are guaranteed to be reported serially. */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TextTimingReportRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TextTimingReportRenderer.java index ed478c8446..b8d9a4e0be 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TextTimingReportRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TextTimingReportRenderer.java @@ -23,16 +23,16 @@ import net.sourceforge.pmd.benchmark.TimeTracker.TimedResult; * @author Juan Martín Sotuyo Dodero */ public class TextTimingReportRenderer implements TimingReportRenderer { - + private static final String TIME_FORMAT = "{0,number,0.0000}"; private static final String CUSTOM_COUNTER_FORMAT = "{0,number,###,###,###}"; - + private static final int LABEL_COLUMN_WIDTH = 50; private static final int TIME_COLUMN_WIDTH = 12; private static final int SELF_TIME_COLUMN_WIDTH = 17; private static final int CALL_COLUMN_WIDTH = 9; private static final int COUNTER_COLUMN_WIDTH = 12; - + private static final int COLUMNS = LABEL_COLUMN_WIDTH + TIME_COLUMN_WIDTH + SELF_TIME_COLUMN_WIDTH + CALL_COLUMN_WIDTH + COUNTER_COLUMN_WIDTH; @@ -44,63 +44,63 @@ public class TextTimingReportRenderer implements TimingReportRenderer { renderCategoryMeasurements(category, labeledMeasurements, writer); } } - + renderHeader("Summary", writer); - + for (final TimedOperationCategory category : TimedOperationCategory.values()) { final TimedResult timedResult = report.getUnlabeledMeasurements(category); if (timedResult != null) { renderMeasurement(category.displayName(), timedResult, writer); } } - + writer.write(PMD.EOL); renderHeader("Total", writer); - + writer.write(StringUtils.rightPad("Wall Clock Time", LABEL_COLUMN_WIDTH)); final String wallClockTime = MessageFormat.format(TIME_FORMAT, report.getWallClockMillis() / 1000.0); writer.write(StringUtils.leftPad(wallClockTime, TIME_COLUMN_WIDTH)); writer.write(PMD.EOL); - + writer.flush(); } private void renderMeasurement(final String label, final TimedResult timedResult, final Writer writer) throws IOException { writer.write(StringUtils.rightPad(label, LABEL_COLUMN_WIDTH)); - + final String time = MessageFormat.format(TIME_FORMAT, timedResult.totalTimeNanos.get() / 1000000000.0); writer.write(StringUtils.leftPad(time, TIME_COLUMN_WIDTH)); - + final String selfTime = MessageFormat.format(TIME_FORMAT, timedResult.selfTimeNanos.get() / 1000000000.0); writer.write(StringUtils.leftPad(selfTime, SELF_TIME_COLUMN_WIDTH)); - + if (timedResult.callCount.get() > 0) { final String callCount = MessageFormat.format(CUSTOM_COUNTER_FORMAT, timedResult.callCount.get()); writer.write(StringUtils.leftPad(callCount, CALL_COLUMN_WIDTH)); - + if (timedResult.extraDataCounter.get() > 0) { final String counter = MessageFormat.format(CUSTOM_COUNTER_FORMAT, timedResult.extraDataCounter.get()); writer.write(StringUtils.leftPad(counter, COUNTER_COLUMN_WIDTH)); } } - + writer.write(PMD.EOL); } private void renderCategoryMeasurements(final TimedOperationCategory category, final Map labeledMeasurements, final Writer writer) throws IOException { renderHeader(category.displayName(), writer); - + final TimedResult grandTotal = new TimedResult(); final Set> sortedKeySet = new TreeSet<>(Comparator.comparingLong(o -> o.getValue().selfTimeNanos.get())); sortedKeySet.addAll(labeledMeasurements.entrySet()); - + for (final Map.Entry entry : sortedKeySet) { renderMeasurement(entry.getKey(), entry.getValue(), writer); grandTotal.mergeTimes(entry.getValue()); } - + writer.write(PMD.EOL); renderMeasurement("Total " + category.displayName(), grandTotal, writer); writer.write(PMD.EOL); @@ -109,23 +109,23 @@ public class TextTimingReportRenderer implements TimingReportRenderer { private void renderHeader(final String displayName, final Writer writer) throws IOException { final StringBuilder sb = new StringBuilder(COLUMNS) .append(displayName); - + // Make sure we have an even-length string if (displayName.length() % 2 == 1) { sb.append(' '); } - + // Surround with <<< and >>> sb.insert(0, "<<< ").append(" >>>"); - + // Create the ruler while (sb.length() < COLUMNS) { sb.insert(0, '-').append('-'); } - + writer.write(sb.toString()); writer.write(PMD.EOL); - + // Write table titles writer.write(StringUtils.rightPad("Label", LABEL_COLUMN_WIDTH)); writer.write(StringUtils.leftPad("Time (secs)", TIME_COLUMN_WIDTH)); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimeTracker.java b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimeTracker.java index eb98d7f0ee..9fe69c04f7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimeTracker.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimeTracker.java @@ -16,7 +16,7 @@ import java.util.concurrent.atomic.AtomicLong; /** * A time tracker class to measure time spent on different sections of PMD analysis. * The class is thread-aware, allowing to differentiate CPU and wall clock time. - * + * * @author Juan Martín Sotuyo Dodero */ public final class TimeTracker { @@ -37,15 +37,15 @@ public final class TimeTracker { // noop } }; - + static { TIMER_ENTRIES = ThreadLocal.withInitial(() -> Collections.asLifoQueue(new LinkedList<>())); } - + private TimeTracker() { throw new AssertionError("Can't instantiate utility class"); } - + /** * Starts global tracking. Allows tracking operations to take place and starts the wall clock. * Must be called once PMD starts if tracking is desired, no tracking will be performed otherwise. @@ -56,7 +56,7 @@ public final class TimeTracker { ACCUMULATED_RESULTS.clear(); // just in case initThread(); // init main thread } - + /** * Stops global tracking. Stops the wall clock. All further operations will be treated as NOOP. * @return The timed data obtained through the run. @@ -65,19 +65,19 @@ public final class TimeTracker { if (!trackTime) { return null; } - + finishThread(); // finish the main thread trackTime = false; - + // Fix UNACCOUNTED metric (total time is meaningless as is call count) final TimedResult unaccountedResult = ACCUMULATED_RESULTS.get( new TimedOperationKey(TimedOperationCategory.UNACCOUNTED, null)); unaccountedResult.totalTimeNanos.set(unaccountedResult.selfTimeNanos.get()); unaccountedResult.callCount.set(0); - + return new TimingReport(System.currentTimeMillis() - wallClockStartMillis, ACCUMULATED_RESULTS); } - + /** * Initialize a thread, starting to track it's own time. */ @@ -85,10 +85,10 @@ public final class TimeTracker { if (!trackTime) { return; } - + startOperation(TimedOperationCategory.UNACCOUNTED); } - + /** * Finishes tracking a thread. */ @@ -96,15 +96,15 @@ public final class TimeTracker { if (!trackTime) { return; } - + finishOperation(0); - + // clean up thread-locals in multithread analysis if (TIMER_ENTRIES.get().isEmpty()) { TIMER_ENTRIES.remove(); } } - + /** * Starts tracking an operation. * @param category The category under which to track the operation. @@ -113,7 +113,7 @@ public final class TimeTracker { public static TimedOperation startOperation(final TimedOperationCategory category) { return startOperation(category, null); } - + /** * Starts tracking an operation. * @param category The category under which to track the operation. @@ -124,11 +124,11 @@ public final class TimeTracker { if (!trackTime) { return NOOP_TIMED_OPERATION; } - + TIMER_ENTRIES.get().add(new TimerEntry(category, label)); return new TimedOperationImpl(); } - + /** * Finishes tracking an operation. * @param extraDataCounter An optional additional data counter to track along the measurements. @@ -152,11 +152,11 @@ public final class TimeTracker { // Update counters and let next element on the stack ignore the time we spent final long delta = result.accumulate(timerEntry, extraDataCounter); - if (!queue.isEmpty()) { + if (!queue.isEmpty()) { queue.peek().inNestedOperationsNanos += delta; } } - + /** * An entry in the open timers queue. Defines an operation that has started and hasn't finished yet. */ @@ -164,7 +164,7 @@ public final class TimeTracker { /* package */ final TimedOperationKey operation; /* package */ final long start; /* package */ long inNestedOperationsNanos = 0; - + /* package */ TimerEntry(final TimedOperationCategory category, final String label) { this.operation = new TimedOperationKey(category, label); this.start = System.nanoTime(); @@ -175,7 +175,7 @@ public final class TimeTracker { return "TimerEntry for " + operation; } } - + /** * Aggregate results measured so far for a given category + label. */ @@ -184,7 +184,7 @@ public final class TimeTracker { /* package */ AtomicLong selfTimeNanos = new AtomicLong(); /* package */ AtomicInteger callCount = new AtomicInteger(); /* package */ AtomicLong extraDataCounter = new AtomicLong(); - + /** * Adds a new {@link TimerEntry} to the results. * @param timerEntry The entry to be added @@ -193,15 +193,15 @@ public final class TimeTracker { */ /* package */ long accumulate(final TimerEntry timerEntry, final long extraData) { final long delta = System.nanoTime() - timerEntry.start; - + totalTimeNanos.getAndAdd(delta); selfTimeNanos.getAndAdd(delta - timerEntry.inNestedOperationsNanos); callCount.getAndIncrement(); extraDataCounter.getAndAdd(extraData); - + return delta; } - + /** * Merges the times (and only the times) from another {@link TimedResult} into self. * @param timedResult The {@link TimedResult} to merge @@ -211,14 +211,14 @@ public final class TimeTracker { selfTimeNanos.getAndAdd(timedResult.selfTimeNanos.get()); } } - + /** * A unique identifier for a timed operation */ /* package */ static class TimedOperationKey { /* package */ final TimedOperationCategory category; /* package */ final String label; - + /* package */ TimedOperationKey(final TimedOperationCategory category, final String label) { this.category = category; this.label = label; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperation.java b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperation.java index 20978cdf49..74ba7fa6f3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperation.java @@ -14,7 +14,7 @@ public interface TimedOperation extends AutoCloseable { */ @Override void close(); - + /** * Stops tracking if not already stopped. * @param extraDataCounter An optional additional data counter to track along the measurements. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperationCategory.java b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperationCategory.java index 0abede5514..0ae6cf7829 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperationCategory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperationCategory.java @@ -27,7 +27,7 @@ public enum TimedOperationCategory { REPORTING, FILE_PROCESSING, UNACCOUNTED; - + public String displayName() { final String[] parts = name().toLowerCase(Locale.getDefault()).split("_"); final StringBuilder sb = new StringBuilder(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimingReport.java b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimingReport.java index f8fed28d93..028e8906f6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimingReport.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimingReport.java @@ -18,25 +18,25 @@ public class TimingReport { private final long wallClockMillis; private final Map results; - + /* package */ TimingReport(final long wallClockMillis, final Map accumulatedResults) { this.wallClockMillis = wallClockMillis; results = accumulatedResults; } - + public Map getLabeledMeasurements(final TimedOperationCategory category) { final Map ret = new HashMap<>(); - + for (final Map.Entry entry : results.entrySet()) { final TimedOperationKey timedOperation = entry.getKey(); if (timedOperation.category == category && timedOperation.label != null) { ret.put(timedOperation.label, entry.getValue()); } } - + return ret; } - + public TimedResult getUnlabeledMeasurements(final TimedOperationCategory category) { for (final Map.Entry entry : results.entrySet()) { final TimedOperationKey timedOperation = entry.getKey(); @@ -44,10 +44,10 @@ public class TimingReport { return entry.getValue(); } } - + return null; } - + public long getWallClockMillis() { return wallClockMillis; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java index 42e5514668..34e4c5cf9c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AnalysisCache.java @@ -51,7 +51,7 @@ public interface AnalysisCache extends ThreadSafeReportListener { * @param sourceFile The file whose analysis failed */ void analysisFailed(File sourceFile); - + /** * Checks if the cache is valid for the configured rulesets and class loader. * If the provided rulesets and classpath don't match those of the cache, the diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java index db1e0435e9..aa1be53825 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/CachedRuleMapper.java @@ -42,7 +42,7 @@ public class CachedRuleMapper { cachedRulesInstances.put(getRuleKey(r.getRuleClass(), r.getName(), r.getLanguage().getTerseName()), r); } } - + private String getRuleKey(final String className, final String ruleName, final String languageName) { return className + "$$" + ruleName + "$$" + languageName; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/ChecksumAware.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/ChecksumAware.java index ce48b62ce1..e3a13abb7d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/ChecksumAware.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/ChecksumAware.java @@ -20,7 +20,7 @@ import net.sourceforge.pmd.annotation.InternalApi; public interface ChecksumAware { /** * Retrieves the current instance checksum - * + * * @return The current checksum */ long getChecksum(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java index ec0f663f9d..46a4d77a89 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/NoopAnalysisCache.java @@ -20,7 +20,7 @@ import net.sourceforge.pmd.annotation.InternalApi; @Deprecated @InternalApi public class NoopAnalysisCache implements AnalysisCache { - + @Override public void ruleViolationAdded(final RuleViolation ruleViolation) { // noop 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 ad5d8cee58..da009e56cc 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 @@ -40,7 +40,7 @@ public class CPDConfiguration extends AbstractConfiguration { public static final String DEFAULT_RENDERER = "text"; private static final Map> RENDERERS = new HashMap<>(); - + static { RENDERERS.put(DEFAULT_RENDERER, SimpleRenderer.class); RENDERERS.put("xml", XMLRenderer.class); @@ -71,7 +71,7 @@ public class CPDConfiguration extends AbstractConfiguration { */ @Deprecated private Renderer renderer; - + private CPDRenderer cpdRenderer; private String encoding; @@ -203,7 +203,7 @@ public class CPDConfiguration extends AbstractConfiguration { return new SimpleRenderer(); } } - + public static CPDRenderer getCPDRendererFromString(String name, String encoding) { String clazzname = name; if (clazzname == null || "".equals(clazzname)) { @@ -317,7 +317,7 @@ public class CPDConfiguration extends AbstractConfiguration { public Renderer getRenderer() { return renderer; } - + public CPDRenderer getCPDRenderer() { return cpdRenderer; } @@ -373,7 +373,7 @@ public class CPDConfiguration extends AbstractConfiguration { this.renderer = renderer; this.cpdRenderer = null; } - + public void setCPDRenderer(CPDRenderer renderer) { this.cpdRenderer = renderer; this.renderer = null; 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 3197025d65..1b5f4fea28 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 @@ -27,9 +27,9 @@ import net.sourceforge.pmd.cpd.renderer.CPDRenderer; /** * CPDTask - * + * *

Runs the CPD utility via ant. The ant task looks like this:

- * + * *
  * <project name="CPDProj" default="main" basedir=".">
  *   <taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask" />
@@ -44,7 +44,7 @@ import net.sourceforge.pmd.cpd.renderer.CPDRenderer;
  *   </target>
  * </project>
  * 
- * + * *

Required: minimumTokenCount, outputFile, and at least one file

*/ public class CPDTask extends Task { @@ -131,7 +131,7 @@ public class CPDTask extends Task { log("No duplicates over " + minimumTokenCount + " tokens found", Project.MSG_INFO); } CPDRenderer renderer = createRenderer(); - + try { // will be closed via BufferedWriter/OutputStreamWriter chain down below final OutputStream os; @@ -142,11 +142,11 @@ public class CPDTask extends Task { } else { os = Files.newOutputStream(new File(getProject().getBaseDir(), outputFile.toString()).toPath()); } - + if (encoding == null) { encoding = System.getProperty("file.encoding"); } - + try (Writer writer = new BufferedWriter(new OutputStreamWriter(os, encoding))) { renderer.render(cpd.getMatches(), writer); } 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 ab71d78bdf..d7e29d93d7 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 @@ -96,7 +96,7 @@ public final class XMLRenderer implements Renderer, CPDRenderer { } return writer.toString(); } - + @Override public void render(Iterator matches, Writer writer) throws IOException { Document doc = createDocument(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/internal/JavaCCTokenizer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/internal/JavaCCTokenizer.java index 0672b655f0..2721f5cbc6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/internal/JavaCCTokenizer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/internal/JavaCCTokenizer.java @@ -26,7 +26,7 @@ public abstract class JavaCCTokenizer implements Tokenizer { protected TokenEntry processToken(Tokens tokenEntries, GenericToken currentToken, String filename) { return new TokenEntry(currentToken.getImage(), filename, currentToken.getBeginLine(), currentToken.getBeginColumn(), currentToken.getEndColumn()); } - + @Override public void tokenize(SourceCode sourceCode, Tokens tokenEntries) throws IOException { TokenManager tokenManager = getLexerForSource(sourceCode); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/internal/DeprecatedAttribute.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/internal/DeprecatedAttribute.java index 97346d92a7..75e80d4f5f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/internal/DeprecatedAttribute.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/internal/DeprecatedAttribute.java @@ -15,7 +15,7 @@ import java.lang.annotation.Target; * Node attribute getter methods might be annotated with {@code DeprecatedAttribute} * to mark the attribute as deprecated for XPath. Unlike {@link Deprecated}, this * annotation does not deprecate the method for java usage. - * + * * @since 6.21.0 */ @Documented 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 0c9bc0923a..c0a374ce6a 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 @@ -443,7 +443,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul return getClass().getName().hashCode() + (getName() != null ? getName().hashCode() : 0) + getPriority().hashCode() + (propertyValues != null ? propertyValues.hashCode() : 0); } - + @SuppressWarnings("unchecked") @Override public Rule deepCopy() { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java index 8b1d189f36..e3086542b3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java @@ -384,7 +384,7 @@ public class RuleReference extends AbstractDelegateRule { propertyDescriptors.remove(desc); } } - + @Override public Rule deepCopy() { return new RuleReference(this); 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 f874ad299c..93bc286cbe 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 @@ -47,7 +47,7 @@ public class XPathRule extends AbstractRule { tmp.put(XPATH_2_0, XPATH_2_0); XPATH_VERSIONS = Collections.unmodifiableMap(tmp); } - + // published, can't be converted public static final EnumeratedProperty VERSION_DESCRIPTOR = EnumeratedProperty.named("version") .desc("XPath specification version") 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 ee0bb7f382..1eec5ec1ae 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 @@ -37,7 +37,7 @@ import net.sourceforge.pmd.util.datasource.DataSource; public abstract class AbstractPMDProcessor { private static final Logger LOG = Logger.getLogger(AbstractPMDProcessor.class.getName()); - + protected final PMDConfiguration configuration; public AbstractPMDProcessor(PMDConfiguration configuration) { @@ -56,7 +56,7 @@ public abstract class AbstractPMDProcessor { } /** - * + * * @deprecated this method will be removed. It was once used to determine a short filename * for the file being analyzed, so that shortnames can be reported. But the logic has * been moved to the renderers. @@ -78,15 +78,15 @@ public abstract class AbstractPMDProcessor { */ protected RuleSets createRuleSets(RuleSetFactory factory, Report report) { final RuleSets rs = RulesetsFactoryUtils.getRuleSets(configuration.getRuleSets(), factory); - + final Set brokenRules = removeBrokenRules(rs); for (final Rule rule : brokenRules) { report.addConfigError(new Report.ConfigurationError(rule, rule.dysfunctionReason())); } - + return rs; } - + /** * Remove and return the misconfigured rules from the rulesets and log them * for good measure. @@ -128,7 +128,7 @@ public abstract class AbstractPMDProcessor { // render base report first - general errors renderReports(renderers, ctx.getReport()); - + // then add analysis results per file collectReports(renderers); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/processor/MonoThreadProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/processor/MonoThreadProcessor.java index 1adb114a89..6acf61a32c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/processor/MonoThreadProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/processor/MonoThreadProcessor.java @@ -18,7 +18,7 @@ import net.sourceforge.pmd.renderers.Renderer; public final class MonoThreadProcessor extends AbstractPMDProcessor { private final List reports = new ArrayList<>(); - + public MonoThreadProcessor(PMDConfiguration configuration) { super(configuration); } 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 d3693d7ad0..d3ddeb6230 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 @@ -57,7 +57,7 @@ public class PmdRunnable implements Callable { @Override public Report call() { TimeTracker.initThread(); - + ThreadContext tc = LOCAL_THREAD_CONTEXT.get(); if (tc == null) { tc = new ThreadContext(new RuleSets(ruleSets), new RuleContext(ruleContext)); @@ -85,7 +85,7 @@ public class PmdRunnable implements Callable { } TimeTracker.finishThread(); - + return report; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorBuilder.java index c47f6b2113..4f3d4ac117 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorBuilder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorBuilder.java @@ -38,7 +38,7 @@ public abstract class PropertyDescriptorBuilder errors = new LinkedList<>(); - + /** * Accumulated configuration errors. */ @@ -66,7 +66,7 @@ public abstract class AbstractIncrementingRenderer extends AbstractRenderer { for (Iterator i = report.errors(); i.hasNext();) { errors.add(i.next()); } - + for (Iterator i = report.configErrors(); i.hasNext();) { configErrors.add(i.next()); } 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 a7c005fb9c..bc2c95c706 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 @@ -162,7 +162,7 @@ public class TextColorRenderer extends AbstractAccumulatingRenderer { .append(this.red).append(error.getDetail()).append(colorReset).append(PMD.EOL).append(PMD.EOL); writer.write(buf.toString()); } - + for (Iterator i = report.configErrors(); i.hasNext();) { buf.setLength(0); numberOfErrors++; 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 c2db75be17..9b050cbdc7 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 @@ -105,7 +105,7 @@ public class VBHTMLRenderer extends AbstractIncrementingRenderer { sb.append(""); writer.write(sb.toString()); } - + if (!configErrors.isEmpty()) { sb.setLength(0); sb.append(""); 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 4dfde3d00b..cd3b28e5f5 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 @@ -488,7 +488,7 @@ public class DBMSMetadata { sourceCodeObjects.getString("PROCEDURE_SCHEM"), sourceCodeObjects.getString("PROCEDURE_TYPE"), sourceCodeObjects.getString("PROCEDURE_NAME"))); - + sourceObjectsList.add(new SourceObject(sourceCodeObjects.getString("PROCEDURE_SCHEM"), sourceCodeObjects.getString("PROCEDURE_TYPE"), sourceCodeObjects.getString("PROCEDURE_NAME"), null)); @@ -538,7 +538,7 @@ public class DBMSMetadata { sourceCodeObjects.getString("PROCEDURE_SCHEM"), sourceCodeObjects.getString("PROCEDURE_TYPE"), sourceCodeObjects.getString("PROCEDURE_NAME"))); - + sourceObjectsList .add(new SourceObject(sourceCodeObjects.getString("PROCEDURE_SCHEM"), sourceCodeObjects.getString("PROCEDURE_TYPE"), 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 085044151d..34bb80c712 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleReferenceTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleReferenceTest.java @@ -63,7 +63,7 @@ public class RuleReferenceTest { validateOverridenValues(PROPERTY1_DESCRIPTOR, PROPERTY2_DESCRIPTOR, ruleReference); } - + @Test public void testDeepCopyOverride() { final StringProperty PROPERTY1_DESCRIPTOR = new StringProperty("property1", "Test property", null, 0f); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryCompatibilityTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryCompatibilityTest.java index dd7104c561..6acaf22971 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryCompatibilityTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryCompatibilityTest.java @@ -34,7 +34,7 @@ public class RuleSetFactoryCompatibilityTest { RuleSet createdRuleSet = createRulesetFromString(ruleset, factory); Assert.assertNotNull(createdRuleSet.getRuleByName("DummyBasicMockRule")); } - + @Test public void testCorrectMovedAndRename() throws Exception { final String ruleset = "\n" + "\n" + "")); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java index 80e7095403..34e130a3a8 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cache/FileAnalysisCacheTest.java @@ -35,19 +35,19 @@ import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.lang.Language; public class FileAnalysisCacheTest { - + @Rule public TemporaryFolder tempFolder = new TemporaryFolder(); - + @Rule public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties(); - + private File unexistingCacheFile; private File newCacheFile; private File emptyCacheFile; - + private File sourceFile; - + @Before public void setUp() throws IOException { unexistingCacheFile = new File(tempFolder.getRoot(), "non-existing-file.cache"); @@ -61,18 +61,18 @@ public class FileAnalysisCacheTest { final FileAnalysisCache cache = new FileAnalysisCache(unexistingCacheFile); assertNotNull("Cache creation from non existing file failed.", cache); } - + @Test public void testLoadFromEmptyFile() throws IOException { final FileAnalysisCache cache = new FileAnalysisCache(emptyCacheFile); assertNotNull("Cache creation from empty file failed.", cache); } - + @Test public void testLoadFromDirectoryShouldntThrow() throws IOException { new FileAnalysisCache(tempFolder.getRoot()); } - + @Test public void testLoadFromUnreadableFileShouldntThrow() throws IOException { emptyCacheFile.setReadable(false); @@ -110,7 +110,7 @@ public class FileAnalysisCacheTest { final FileAnalysisCache reloadedCache = new FileAnalysisCache(newCacheFile); assertTrue("Cache believes unmodified file with violations is not up to date", reloadedCache.isUpToDate(sourceFile)); - + final List cachedViolations = reloadedCache.getCachedViolations(sourceFile); assertEquals("Cached rule violations count mismatch", 1, cachedViolations.size()); } @@ -132,39 +132,39 @@ public class FileAnalysisCacheTest { public void testRulesetChangeInvalidatesCache() { final RuleSets rs = mock(RuleSets.class); final ClassLoader cl = mock(ClassLoader.class); - + setupCacheWithFiles(newCacheFile, rs, cl, sourceFile); - + final FileAnalysisCache reloadedCache = new FileAnalysisCache(newCacheFile); when(rs.getChecksum()).thenReturn(1L); reloadedCache.checkValidity(rs, cl); assertFalse("Cache believes unmodified file is up to date after ruleset changed", reloadedCache.isUpToDate(sourceFile)); } - + @Test public void testAuxClasspathNonExistingAuxclasspathEntriesIgnored() throws MalformedURLException, IOException { final RuleSets rs = mock(RuleSets.class); final URLClassLoader cl = mock(URLClassLoader.class); when(cl.getURLs()).thenReturn(new URL[] { new File(tempFolder.getRoot(), "non-existing-dir").toURI().toURL(), }); - + setupCacheWithFiles(newCacheFile, rs, cl, sourceFile); - + final FileAnalysisCache analysisCache = new FileAnalysisCache(newCacheFile); when(cl.getURLs()).thenReturn(new URL[] {}); analysisCache.checkValidity(rs, cl); assertTrue("Cache believes unmodified file is not up to date after non-existing auxclasspath entry removed", analysisCache.isUpToDate(sourceFile)); } - + @Test public void testAuxClasspathChangeWithoutDFAorTypeResolutionDoesNotInvalidatesCache() throws MalformedURLException, IOException { final RuleSets rs = mock(RuleSets.class); final URLClassLoader cl = mock(URLClassLoader.class); when(cl.getURLs()).thenReturn(new URL[] { }); - + setupCacheWithFiles(newCacheFile, rs, cl, sourceFile); - + final FileAnalysisCache reloadedCache = new FileAnalysisCache(newCacheFile); when(cl.getURLs()).thenReturn(new URL[] { tempFolder.newFile().toURI().toURL(), }); reloadedCache.checkValidity(rs, cl); @@ -177,16 +177,16 @@ public class FileAnalysisCacheTest { final RuleSets rs = mock(RuleSets.class); final URLClassLoader cl = mock(URLClassLoader.class); when(cl.getURLs()).thenReturn(new URL[] { }); - + setupCacheWithFiles(newCacheFile, rs, cl, sourceFile); - + final FileAnalysisCache reloadedCache = new FileAnalysisCache(newCacheFile); final File classpathFile = tempFolder.newFile(); when(cl.getURLs()).thenReturn(new URL[] { classpathFile.toURI().toURL(), }); - + // Make sure the auxclasspath file is not empty Files.write(Paths.get(classpathFile.getAbsolutePath()), "some text".getBytes()); - + final net.sourceforge.pmd.Rule r = mock(net.sourceforge.pmd.Rule.class); when(r.isDfa()).thenReturn(true); when(r.getLanguage()).thenReturn(mock(Language.class)); @@ -195,25 +195,25 @@ public class FileAnalysisCacheTest { assertFalse("Cache believes unmodified file is up to date after auxclasspath changed", reloadedCache.isUpToDate(sourceFile)); } - + @Test public void testAuxClasspathJarContentsChangeInvalidatesCache() throws MalformedURLException, IOException { final RuleSets rs = mock(RuleSets.class); final URLClassLoader cl = mock(URLClassLoader.class); - + final File classpathFile = tempFolder.newFile(); when(cl.getURLs()).thenReturn(new URL[] { classpathFile.toURI().toURL(), }); - + final net.sourceforge.pmd.Rule r = mock(net.sourceforge.pmd.Rule.class); when(r.isDfa()).thenReturn(true); when(r.getLanguage()).thenReturn(mock(Language.class)); when(rs.getAllRules()).thenReturn(Collections.singleton(r)); - + setupCacheWithFiles(newCacheFile, rs, cl, sourceFile); - + // Edit the auxclasspath referenced file Files.write(Paths.get(classpathFile.getAbsolutePath()), "some text".getBytes()); - + final FileAnalysisCache reloadedCache = new FileAnalysisCache(newCacheFile); reloadedCache.checkValidity(rs, cl); assertFalse("Cache believes cache is up to date when a auxclasspath file changed", @@ -224,10 +224,10 @@ public class FileAnalysisCacheTest { public void testClasspathNonExistingEntryIsIgnored() throws MalformedURLException, IOException { final RuleSets rs = mock(RuleSets.class); final ClassLoader cl = mock(ClassLoader.class); - + System.setProperty("java.class.path", System.getProperty("java.class.path") + File.pathSeparator + tempFolder.getRoot().getAbsolutePath() + File.separator + "non-existing-dir"); - + final FileAnalysisCache reloadedCache = new FileAnalysisCache(newCacheFile); try { reloadedCache.checkValidity(rs, cl); @@ -235,42 +235,42 @@ public class FileAnalysisCacheTest { fail("Validity check failed when classpath includes non-existing directories"); } } - + @Test public void testClasspathChangeInvalidatesCache() throws MalformedURLException, IOException { final RuleSets rs = mock(RuleSets.class); final ClassLoader cl = mock(ClassLoader.class); - + final File classpathFile = tempFolder.newFile(); - + setupCacheWithFiles(newCacheFile, rs, cl, sourceFile); - + // Edit the classpath referenced file Files.write(Paths.get(classpathFile.getAbsolutePath()), "some text".getBytes()); System.setProperty("java.class.path", System.getProperty("java.class.path") + File.pathSeparator + classpathFile.getAbsolutePath()); - + final FileAnalysisCache reloadedCache = new FileAnalysisCache(newCacheFile); reloadedCache.checkValidity(rs, cl); assertFalse("Cache believes cache is up to date when the classpath changed", reloadedCache.isUpToDate(sourceFile)); } - + @Test public void testClasspathContentsChangeInvalidatesCache() throws MalformedURLException, IOException { final RuleSets rs = mock(RuleSets.class); final ClassLoader cl = mock(ClassLoader.class); - + final File classpathFile = tempFolder.newFile(); - + // Add a file to classpath Files.write(Paths.get(classpathFile.getAbsolutePath()), "some text".getBytes()); System.setProperty("java.class.path", System.getProperty("java.class.path") + File.pathSeparator + classpathFile.getAbsolutePath()); - + setupCacheWithFiles(newCacheFile, rs, cl, sourceFile); - + // Change the file's contents Files.write(Paths.get(classpathFile.getAbsolutePath()), "some other text".getBytes()); - + final FileAnalysisCache reloadedCache = new FileAnalysisCache(newCacheFile); reloadedCache.checkValidity(rs, cl); assertFalse("Cache believes cache is up to date when a classpath file changed", @@ -331,19 +331,19 @@ public class FileAnalysisCacheTest { @Test public void testFileIsUpToDate() throws IOException { setupCacheWithFiles(newCacheFile, mock(RuleSets.class), mock(ClassLoader.class), sourceFile); - + final FileAnalysisCache cache = new FileAnalysisCache(newCacheFile); assertTrue("Cache believes a known, unchanged file is not up to date", cache.isUpToDate(sourceFile)); } - + @Test public void testFileIsNotUpToDateWhenEdited() throws IOException { setupCacheWithFiles(newCacheFile, mock(RuleSets.class), mock(ClassLoader.class), sourceFile); - + // Edit the file Files.write(Paths.get(sourceFile.getAbsolutePath()), "some text".getBytes()); - + final FileAnalysisCache cache = new FileAnalysisCache(newCacheFile); assertFalse("Cache believes a known, changed file is up to date", cache.isUpToDate(sourceFile)); @@ -354,7 +354,7 @@ public class FileAnalysisCacheTest { // Setup a cache file with an entry for an empty Source.java with no violations final FileAnalysisCache cache = new FileAnalysisCache(cacheFile); cache.checkValidity(ruleSets, classLoader); - + for (final File f : files) { cache.isUpToDate(f); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDConfigurationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDConfigurationTest.java index f5749fa78b..38912fba83 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDConfigurationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDConfigurationTest.java @@ -29,7 +29,7 @@ public class CPDConfigurationTest { Assert.assertSame(entry.getValue(), r.getClass()); } } - + @Test public void testCPDRenderers() { Map> renderersToTest = new HashMap<>(); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDFilelistTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDFilelistTest.java index 47edeec96c..5c21740f85 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDFilelistTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDFilelistTest.java @@ -23,7 +23,7 @@ public class CPDFilelistTest { arguments.setFileListPath("src/test/resources/net/sourceforge/pmd/cpd/cli/filelist.txt"); CPD cpd = new CPD(arguments); CPDCommandLineInterface.addSourceFilesToCPD(cpd, arguments); - + List paths = cpd.getSourcePaths(); assertEquals(2, paths.size()); Set simpleNames = new HashSet<>(); @@ -41,7 +41,7 @@ public class CPDFilelistTest { arguments.setFileListPath("src/test/resources/net/sourceforge/pmd/cpd/cli/filelist2.txt"); CPD cpd = new CPD(arguments); CPDCommandLineInterface.addSourceFilesToCPD(cpd, arguments); - + List paths = cpd.getSourcePaths(); assertEquals(2, paths.size()); Set simpleNames = new HashSet<>(); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/junit/JavaUtilLoggingRule.java b/pmd-core/src/test/java/net/sourceforge/pmd/junit/JavaUtilLoggingRule.java index bc728d2b37..b779aeeb4e 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/junit/JavaUtilLoggingRule.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/junit/JavaUtilLoggingRule.java @@ -13,7 +13,7 @@ import org.junit.rules.ExternalResource; /** * Junit Rule, to check for java util logging statements. - * + * * @author Andreas Dangel * @see Testing the presence of log messages with java.util.logging */ diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/junit/LocaleRule.java b/pmd-core/src/test/java/net/sourceforge/pmd/junit/LocaleRule.java index 63a5d57579..adefc78fb0 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/junit/LocaleRule.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/junit/LocaleRule.java @@ -11,7 +11,7 @@ import org.junit.rules.TestWatcher; import org.junit.runner.Description; /** - * + * * Based on digulla/DefaultLocaleRule.java. * */ diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java index 8634a17e3c..e9bc85a985 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java @@ -14,7 +14,7 @@ public class XPathRuleTest { * defining XPath rules in xml. Therefore we by default enable * typeresolution. For Java rules, type resolution was enabled by * default long time ago. - * + * * @see #2048 [core] Enable type resolution by default for XPath rules */ @Test 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 020cd21c89..60a19e23ca 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 @@ -38,7 +38,7 @@ public class MultiThreadProcessorTest { private RuleSetFactory ruleSetFactory; private List files; private SimpleReportListener reportListener; - + public void setUpForTest(final String ruleset) { PMDConfiguration configuration = new PMDConfiguration(); configuration.setRuleSets(ruleset); @@ -65,14 +65,14 @@ public class MultiThreadProcessorTest { final Iterator configErrors = renderer.getReport().configErrors(); final ConfigurationError error = configErrors.next(); - + Assert.assertEquals("Dysfunctional rule message not present", DysfunctionalRule.DYSFUNCTIONAL_RULE_REASON, error.issue()); Assert.assertEquals("Dysfunctional rule is wrong", DysfunctionalRule.class, error.rule().getClass()); Assert.assertFalse("More configuration errors found than expected", configErrors.hasNext()); } - + @Test public void testRulesThreadSafety() { setUpForTest("rulesets/MultiThreadProcessorTest/basic.xml"); @@ -137,7 +137,7 @@ public class MultiThreadProcessorTest { } } } - + public static class DysfunctionalRule extends AbstractRule { public static final String DYSFUNCTIONAL_RULE_REASON = "dysfunctional rule is dysfunctional"; @@ -146,7 +146,7 @@ public class MultiThreadProcessorTest { public void apply(List nodes, RuleContext ctx) { // noop } - + @Override public String dysfunctionReason() { return DYSFUNCTIONAL_RULE_REASON; @@ -162,7 +162,7 @@ public class MultiThreadProcessorTest { } } - + private static class SimpleRenderer extends AbstractAccumulatingRenderer { /* default */ SimpleRenderer(String name, String description) { @@ -177,7 +177,7 @@ public class MultiThreadProcessorTest { @Override public void end() throws IOException { } - + public Report getReport() { return report; } 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 dbc7a04c21..029dd303d8 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 @@ -37,12 +37,12 @@ public class CSVRendererTest extends AbstractRendererTest { public String getExpectedError(ProcessingError error) { return getHeader(); } - + @Override public String getExpectedError(ConfigurationError error) { return getHeader(); } - + private String getHeader() { return "\"Problem\",\"Package\",\"File\",\"Priority\",\"Line\",\"Description\",\"Rule set\",\"Rule\"" + PMD.EOL; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java index d3044c62f3..28ca250b06 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java @@ -87,7 +87,7 @@ public class CodeClimateRendererTest extends AbstractRendererTest { + "\"},\"categories\":[\"Style\"],\"location\":{\"path\":\"" + getSourceCodeFilename() + "\",\"lines\":{\"begin\":1,\"end\":1}},\"severity\":\"info\",\"remediation_points\":50000}" + "\u0000" + PMD.EOL; } - + @Test public void testXPathRule() throws Exception { DummyNode node = createNode(1); @@ -96,14 +96,14 @@ public class CodeClimateRendererTest extends AbstractRendererTest { Report report = new Report(); XPathRule theRule = new XPathRule(); theRule.setProperty(XPathRule.XPATH_DESCRIPTOR, "//dummyNode"); - + // Setup as FooRule theRule.setDescription("desc"); theRule.setName("Foo"); - + report.addRuleViolation(new ParametricRuleViolation(theRule, ctx, node, "blah")); String rendered = ReportTest.render(getRenderer(), report); - + // Output should be the exact same as for non xpath rules assertEquals(filter(getExpected()), filter(rendered)); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/HTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/HTMLRendererTest.java index 88caa8c339..02651b0b3b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/HTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/HTMLRendererTest.java @@ -57,7 +57,7 @@ public class HTMLRendererTest extends AbstractRendererTest { + "" + PMD.EOL + "" + PMD.EOL + "" + PMD.EOL + "
file
" + error.getDetail() + "
" + PMD.EOL; } - + @Override public String getExpectedError(ConfigurationError error) { return getHeader() diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java index d08536db10..e2c1e15023 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java @@ -78,7 +78,7 @@ public class VBHTMLRendererTest extends AbstractRendererTest { + "-->

 Problems found
" + error.getFile() + "
" + error.getDetail() + "
" + PMD.EOL; } - + @Override public String getExpectedError(ConfigurationError error) { return "PMD