From c27481f81573b6de4ab6112be4b9a19503e9a89e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Fri, 24 Jan 2020 23:08:52 +0100 Subject: [PATCH 1/3] Trim trailing spaces in XML --- .../main/resources/category/apex/design.xml | 10 ++--- .../resources/category/apex/errorprone.xml | 10 ++--- .../resources/category/apex/performance.xml | 2 +- .../main/resources/category/apex/security.xml | 2 +- .../resources/category/java/bestpractices.xml | 22 +++++----- .../resources/category/java/codestyle.xml | 26 ++++++------ .../main/resources/category/java/design.xml | 38 +++++++++--------- .../resources/category/java/documentation.xml | 2 +- .../resources/category/java/errorprone.xml | 40 +++++++++---------- .../resources/category/java/performance.xml | 16 ++++---- .../main/resources/category/java/security.xml | 2 +- .../resources/category/jsp/errorprone.xml | 4 +- .../category/plsql/bestpractices.xml | 2 +- .../main/resources/category/plsql/design.xml | 22 +++++----- .../src/main/resources/category/vm/design.xml | 2 +- .../resources/category/xsl/performance.xml | 2 +- 16 files changed, 101 insertions(+), 101 deletions(-) diff --git a/pmd-apex/src/main/resources/category/apex/design.xml b/pmd-apex/src/main/resources/category/apex/design.xml index 4ae0320382..790c5cd416 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-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index 85ce77b7a1..5c089e46d7 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -622,7 +622,7 @@ public class GoodTest { typeResolution="true" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit4testshoulduseafterannotation"> -In JUnit 3, the tearDown method was used to clean up all data entities required in running tests. +In JUnit 3, the tearDown method was used to clean up all data entities required in running tests. JUnit 4 skips the tearDown method and executes all methods annotated with @After after running each test. JUnit 5 introduced @AfterEach and @AfterAll annotations to execute methods after each test or after all tests in the class, respectively. @@ -666,7 +666,7 @@ public class MyTest2 { typeResolution="true" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit4testshouldusebeforeannotation"> -In JUnit 3, the setUp method was used to set up all data entities required in running tests. +In JUnit 3, the setUp method was used to set up all data entities required in running tests. JUnit 4 skips the setUp method and executes all methods annotated with @Before before all tests. JUnit 5 introduced @BeforeEach and @BeforeAll annotations to execute methods before each test or before all tests in the class, respectively. @@ -710,7 +710,7 @@ public class MyTest2 { typeResolution="true" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit4testshouldusetestannotation"> -In JUnit 3, the framework executed all methods which started with the word test as a unit test. +In JUnit 3, the framework executed all methods which started with the word test as a unit test. In JUnit 4, only methods annotated with the @Test annotation are executed. In JUnit 5, one of the following annotations should be used for tests: @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest. @@ -758,7 +758,7 @@ public class MyTest { class="net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitAssertionsShouldIncludeMessageRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junitassertionsshouldincludemessage"> -JUnit assertions should include an informative message - i.e., use the three-argument version of +JUnit assertions should include an informative message - i.e., use the three-argument version of assertEquals(), not the two-argument version. 3 @@ -784,7 +784,7 @@ public class Foo extends TestCase { typeResolution="true" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junittestcontainstoomanyasserts"> -Unit tests should not contain too many asserts. Many asserts are indicative of a complex test, for which +Unit tests should not contain too many asserts. Many asserts are indicative of a complex test, for which it is harder to verify correctness. Consider breaking the test scenario into multiple, shorter test scenarios. Customize the maximum number of assertions used by this Rule to suit your needs. @@ -837,7 +837,7 @@ public class MyTestCase extends TestCase { class="net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitTestsShouldIncludeAssertRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junittestsshouldincludeassert"> -JUnit tests should include at least one assertion. This makes the tests more robust, and using assert +JUnit tests should include at least one assertion. This makes the tests more robust, and using assert with messages provide the developer a clearer idea of what the test does. 3 @@ -927,7 +927,7 @@ public class Bar { class="net.sourceforge.pmd.lang.java.rule.bestpractices.MethodReturnsInternalArrayRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#methodreturnsinternalarray"> -Exposing internal arrays to the caller violates object encapsulation since elements can be +Exposing internal arrays to the caller violates object encapsulation since elements can be removed or replaced outside of the object that owns it. It is safer to return a copy of the array. 3 @@ -1300,8 +1300,8 @@ class Foo{ class="net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedFormalParameterRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#unusedformalparameter"> -Avoid passing parameters to methods or constructors without actually referencing them in the method body. -Removing unused formal parameters from public methods could cause a ripple effect through the code base. +Avoid passing parameters to methods or constructors without actually referencing them in the method body. +Removing unused formal parameters from public methods could cause a ripple effect through the code base. Hence, by default, this rule only considers private methods. To include non-private methods, set the `checkAll` property to `true`. @@ -1455,7 +1455,7 @@ public class FooTest extends TestCase { typeResolution="true" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#useassertnullinsteadofasserttrue"> -This rule detects JUnit assertions in object references equality. These assertions should be made by +This rule detects JUnit assertions in object references equality. These assertions should be made by more specific methods, like assertNull, assertNotNull. 3 @@ -1504,7 +1504,7 @@ public class FooTest extends TestCase { typeResolution="true" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#useassertsameinsteadofasserttrue"> -This rule detects JUnit assertions in object references equality. These assertions should be made +This rule detects JUnit assertions in object references equality. These assertions should be made by more specific methods, like assertSame, assertNotSame. 3 diff --git a/pmd-java/src/main/resources/category/java/codestyle.xml b/pmd-java/src/main/resources/category/java/codestyle.xml index c6a14810ef..6f8e3e2ae4 100644 --- a/pmd-java/src/main/resources/category/java/codestyle.xml +++ b/pmd-java/src/main/resources/category/java/codestyle.xml @@ -395,7 +395,7 @@ public class Foo extends Bar{ -Avoid using 'for' statements without using curly braces. If the code formatting or -indentation is lost then it becomes difficult to separate the code being controlled +Avoid using 'for' statements without using curly braces. If the code formatting or +indentation is lost then it becomes difficult to separate the code being controlled from the rest. This rule is deprecated and will be removed with PMD 7.0.0. The rule is replaced @@ -864,7 +864,7 @@ Names for references to generic values should be limited to a single uppercase l 1 + string-length(@Image) > 1 or string:upper-case(@Image) != @Image ] @@ -934,8 +934,8 @@ try { class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#ifelsestmtsmustusebraces"> -Avoid using if..else statements without using surrounding braces. If the code formatting -or indentation is lost then it becomes difficult to separate the code being controlled +Avoid using if..else statements without using surrounding braces. If the code formatting +or indentation is lost then it becomes difficult to separate the code being controlled from the rest. This rule is deprecated and will be removed with PMD 7.0.0. The rule is replaced @@ -976,7 +976,7 @@ if (foo) class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#ifstmtsmustusebraces"> -Avoid using if statements without using braces to surround the code block. If the code +Avoid using if statements without using braces to surround the code block. If the code formatting or indentation is lost then it becomes difficult to separate the code being controlled from the rest. @@ -1755,14 +1755,14 @@ public class Foo { message="Too many static imports may lead to messy code" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#toomanystaticimports"> -If you overuse the static import feature, it can make your program unreadable and -unmaintainable, polluting its namespace with all the static members you import. -Readers of your code (including you, a few months after you wrote it) will not know +If you overuse the static import feature, it can make your program unreadable and +unmaintainable, polluting its namespace with all the static members you import. +Readers of your code (including you, a few months after you wrote it) will not know which class a static member comes from (Sun 1.5 Language Guide). 3 - @@ -2200,7 +2200,7 @@ public class Foo { class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#whileloopsmustusebraces"> -Avoid using 'while' statements without using braces to surround the code block. If the code +Avoid using 'while' statements without using braces to surround the code block. If the code formatting or indentation is lost then it becomes difficult to separate the code being controlled from the rest. @@ -2217,7 +2217,7 @@ by the rule {% rule java/codestyle/ControlStatementBraces %}. *Effective Java, 3rd Edition, Item 72: Favor the use of standard exceptions* > ->Arguably, every erroneous method invocation boils down to an illegal argument or state, -but other exceptions are standardly used for certain kinds of illegal arguments and states. -If a caller passes null in some parameter for which null values are prohibited, convention dictates that +>Arguably, every erroneous method invocation boils down to an illegal argument or state, +but other exceptions are standardly used for certain kinds of illegal arguments and states. +If a caller passes null in some parameter for which null values are prohibited, convention dictates that NullPointerException be thrown rather than IllegalArgumentException. To implement that, you are encouraged to use `java.util.Objects.requireNonNull()` @@ -219,7 +219,7 @@ Your parameter validation could thus look like the following: ``` public class Foo { private String exampleValue; - + void setExampleValue(String exampleValue) { // check, throw and assignment in a single standard call this.exampleValue = Objects.requireNonNull(exampleValue, "exampleValue must not be null!"); @@ -405,7 +405,7 @@ void bar() { class="net.sourceforge.pmd.lang.java.rule.design.CouplingBetweenObjectsRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#couplingbetweenobjects"> -This rule counts the number of unique attributes, local variables, and return types within an object. +This rule counts the number of unique attributes, local variables, and return types within an object. A number higher than the specified threshold can indicate a high degree of coupling. 3 @@ -583,7 +583,7 @@ public void bar() { class="net.sourceforge.pmd.lang.java.rule.design.ExcessiveClassLengthRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_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 manageable and ripe for reuse. @@ -615,8 +615,8 @@ public class Foo { class="net.sourceforge.pmd.lang.java.rule.design.ExcessiveImportsRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#excessiveimports"> -A high number of imports can indicate a high degree of coupling within an object. This rule -counts the number of unique imports and reports a violation if the count is above the +A high number of imports can indicate a high degree of coupling within an object. This rule +counts the number of unique imports and reports a violation if the count is above the user-specified threshold. 3 @@ -639,7 +639,7 @@ public class Foo { externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#excessivemethodlength"> When methods are excessively long this usually indicates that the method is doing more than its -name/signature might suggest. They also become challenging for others to digest since excessive +name/signature might suggest. They also become challenging for others to digest since excessive scrolling causes readers to lose focus. Try to reduce the method length by creating helper methods and removing any copy/pasted code. @@ -672,7 +672,7 @@ public void addPerson( // too many arguments liable to be mixed up . . . . } - + public void addPerson( // preferred approach Date birthdate, BodyMeasurements measurements, int ssn) { @@ -827,7 +827,7 @@ public class Foo { // a constructor call, not a method call. D d = new D(); // this method call is ok, because we have create the new instance of D locally. - d.doSomethingElse(); + d.doSomethingElse(); } } ]]> @@ -877,7 +877,7 @@ public boolean bar(int a, int b) { class="net.sourceforge.pmd.lang.java.rule.design.LoosePackageCouplingRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#loosepackagecoupling"> -Avoid using classes from the configured package hierarchy outside of the package hierarchy, +Avoid using classes from the configured package hierarchy outside of the package hierarchy, except when using one of the configured allowed classes. 3 @@ -901,8 +901,8 @@ public class Bar { externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#modifiedcyclomaticcomplexity" deprecated="true"> -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. Modified complexity treats switch statements as a single decision point. @@ -1428,8 +1428,8 @@ public class Foo { externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#stdcyclomaticcomplexity" deprecated="true"> -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. @@ -1516,7 +1516,7 @@ public class Foo { externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_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-java/src/main/resources/category/java/documentation.xml b/pmd-java/src/main/resources/category/java/documentation.xml index db378336b3..7b6d5cd81f 100644 --- a/pmd-java/src/main/resources/category/java/documentation.xml +++ b/pmd-java/src/main/resources/category/java/documentation.xml @@ -37,7 +37,7 @@ Denotes whether javadoc (formal) comments are required (or unwanted) for specifi The method Object.finalize() is called by the garbage collector on an object when garbage collection determines that there are no more references to the object. It should not be invoked by application logic. - + Note that Oracle has declared Object.finalize() as deprecated since JDK 9. 3 @@ -211,7 +211,7 @@ void foo() { class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingnpe"> -Code should never throw NullPointerExceptions under normal circumstances. A catch block may hide the +Code should never throw NullPointerExceptions under normal circumstances. A catch block may hide the original error, causing other, more subtle problems later on. 3 @@ -245,7 +245,7 @@ public class Foo { class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCatchingThrowableRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingthrowable"> -Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as +Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as OutOfMemoryError that should be exposed and managed separately. 3 @@ -372,8 +372,8 @@ public class A { class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingMethodNameRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingmethodname"> -It can be confusing to have a field name with the same name as a method. While this is permitted, -having information (field) and actions (method) is not clear naming. Developers versed in +It can be confusing to have a field name with the same name as a method. While this is permitted, +having information (field) and actions (method) is not clear naming. Developers versed in Smalltalk often prefer this approach as the methods denote accessor methods. 3 @@ -663,9 +663,9 @@ boolean x = (y == Double.NaN); class="net.sourceforge.pmd.lang.java.rule.errorprone.BeanMembersShouldSerializeRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#beanmembersshouldserialize"> -If a class is a bean, or is referenced by a bean directly or indirectly it needs to be serializable. -Member variables need to be marked as transient, static, or have accessor methods in the class. Marking -variables as transient is the safest and easiest modification. Accessor methods should follow the Java +If a class is a bean, or is referenced by a bean directly or indirectly it needs to be serializable. +Member variables need to be marked as transient, static, or have accessor methods in the class. Marking +variables as transient is the safest and easiest modification. Accessor methods should follow the Java naming conventions, i.e. for a variable named foo, getFoo() and setFoo() accessor methods should be provided. 3 @@ -1373,7 +1373,7 @@ public class MyActivity extends Activity { class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotthrowexceptioninfinally"> -Throwing exceptions within a 'finally' block is confusing since they may mask other exceptions +Throwing exceptions within a 'finally' block is confusing since they may mask other exceptions or code defects. Note: This is a PMD implementation of the Lint4j rule "A throw in a finally block" @@ -1464,8 +1464,8 @@ public class Count { class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptycatchblock"> -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 @@ -1660,7 +1660,7 @@ public class Foo { class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptystatementnotinloop"> -An empty statement (or a semicolon by itself) that is not used as the sole body of a 'for' +An empty statement (or a semicolon by itself) that is not used as the sole body of a 'for' or 'while' loop is probably a bug. It could also be a double semicolon, which has no purpose and should be removed. @@ -1791,7 +1791,7 @@ public class Foo { class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_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. @@ -1949,7 +1949,7 @@ protected void finalize() { Methods named finalize() should not have parameters. It is confusing and most likely an attempt to overload Object.finalize(). It will not be called by the VM. - + Note that Oracle has declared Object.finalize() as deprecated since JDK 9. 3 @@ -1980,9 +1980,9 @@ public class Foo { class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#finalizeshouldbeprotected"> -When overriding the finalize(), the new method should be set as protected. If made public, +When overriding the finalize(), the new method should be set as protected. If made public, other classes may invoke it at inappropriate times. - + Note that Oracle has declared Object.finalize() as deprecated since JDK 9. 3 @@ -2992,7 +2992,7 @@ new StringBuffer() // 16 new StringBuffer(6) // 6 new StringBuffer("hello world") // 11 + 16 = 27 new StringBuffer('A') // chr(A) = 65 -new StringBuffer("A") // 1 + 16 = 17 +new StringBuffer("A") // 1 + 16 = 17 new StringBuilder() // 16 new StringBuilder(6) // 6 @@ -3047,7 +3047,7 @@ intention to override the equals(Object) method. -Test classes end with the suffix Test. Having a non-test class with that name is not a good practice, +Test classes end with the suffix Test. Having a non-test class with that name is not a good practice, since most people will assume it is a test case. Test classes have test methods named testXXX. 3 @@ -3522,7 +3522,7 @@ String z2 = a.toLowerCase(Locale.getDefault()); class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#useproperclassloader"> -In J2EE, the getClassLoader() method might not work as expected. Use +In J2EE, the getClassLoader() method might not work as expected. Use Thread.currentThread().getContextClassLoader() instead. 3 diff --git a/pmd-java/src/main/resources/category/java/performance.xml b/pmd-java/src/main/resources/category/java/performance.xml index 59d6c3ed30..7d0c75b226 100644 --- a/pmd-java/src/main/resources/category/java/performance.xml +++ b/pmd-java/src/main/resources/category/java/performance.xml @@ -23,14 +23,14 @@ It is much better to use one of the type-specific toString() methods instead. - - @@ -439,7 +439,7 @@ sb.append(System.getProperty("java.io.tmpdir")); externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#insufficientstringbufferdeclaration"> Failing to pre-size a StringBuffer or StringBuilder properly could cause it to re-size many times -during runtime. This rule attempts to determine the total number the characters that are actually +during runtime. This rule attempts to determine the total number the characters that are actually passed into StringBuffer.append(), but represents a best guess "worst case" scenario. An empty StringBuffer/StringBuilder constructor initializes the object to 16 characters. This default is assumed if the length of the constructor can not be determined. @@ -770,7 +770,7 @@ public class Foo { externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#unnecessarywrapperobjectcreation"> Most wrapper classes provide static conversion methods that avoid the need to create intermediate objects -just to create the primitive forms. Using these avoids the cost of creating objects that also need to be +just to create the primitive forms. Using these avoids the cost of creating objects that also need to be garbage-collected later. 3 @@ -834,7 +834,7 @@ public class SimpleTest extends TestCase { class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#usearraysaslist"> -(Arrays.asList(...)) if that is inconvenient for you PrimaryExpression/PrimaryPrefix/Name[ substring-before(@Image,'.add') = ancestor::MethodDeclaration//LocalVariableDeclaration[ ./Type//ClassOrInterfaceType[ - @Image = 'Collection' or + @Image = 'Collection' or @Image = 'List' or @Image='ArrayList' ] ] @@ -948,7 +948,7 @@ public String convert(int i) { externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#usestringbufferforstringappends"> The use of the '+=' operator for appending strings causes the JVM to create and use an internal StringBuffer. -If a non-trivial number of these concatenations are being used then the explicit use of a StringBuilder or +If a non-trivial number of these concatenations are being used then the explicit use of a StringBuilder or threadsafe StringBuffer is recommended to avoid this. 3 @@ -995,7 +995,7 @@ if (sb.length() == 0) {} // preferred "" + int or "" + (int) i and String.valueOf(int) - + and using Integer.toString(int) IntegerToStringShouldBeUsed diff --git a/pmd-java/src/main/resources/category/java/security.xml b/pmd-java/src/main/resources/category/java/security.xml index 8c81f3b7c8..cc6af00573 100644 --- a/pmd-java/src/main/resources/category/java/security.xml +++ b/pmd-java/src/main/resources/category/java/security.xml @@ -53,7 +53,7 @@ public class Foo { void bad() { byte[] iv = new byte[] { 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, }; } - + void alsoBad() { byte[] iv = "secret iv in here".getBytes(); } diff --git a/pmd-jsp/src/main/resources/category/jsp/errorprone.xml b/pmd-jsp/src/main/resources/category/jsp/errorprone.xml index 482eef476b..1006fb141d 100644 --- a/pmd-jsp/src/main/resources/category/jsp/errorprone.xml +++ b/pmd-jsp/src/main/resources/category/jsp/errorprone.xml @@ -26,8 +26,8 @@ A missing 'meta' tag or page directive will trigger this rule, as well as a non- //CompilationUnit/Content[ not(Element[@Name="meta"][ Attribute[@Name="content"]/AttributeValue[contains(lower-case(@Image),"charset=utf-8")] -]) -and +]) +and not(JspDirective[@Name='page']/JspDirectiveAttribute[@Name='contentType'][contains(lower-case(@Value),"charset=utf-8")]) ] ]]> diff --git a/pmd-plsql/src/main/resources/category/plsql/bestpractices.xml b/pmd-plsql/src/main/resources/category/plsql/bestpractices.xml index 909c70cdd6..d18992823f 100644 --- a/pmd-plsql/src/main/resources/category/plsql/bestpractices.xml +++ b/pmd-plsql/src/main/resources/category/plsql/bestpractices.xml @@ -17,7 +17,7 @@ Rules which enforce generally accepted best practices. class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_bestpractices.html#tomkytesdespair"> -"WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR +"WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR 3 diff --git a/pmd-plsql/src/main/resources/category/plsql/design.xml b/pmd-plsql/src/main/resources/category/plsql/design.xml index d48d7c5461..1c5cf2b278 100644 --- a/pmd-plsql/src/main/resources/category/plsql/design.xml +++ b/pmd-plsql/src/main/resources/category/plsql/design.xml @@ -16,15 +16,15 @@ Rules that help you discover design issues. class="net.sourceforge.pmd.lang.plsql.rule.design.CyclomaticComplexityRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#cyclomaticcomplexity"> -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. 3 When methods are excessively long this usually indicates that the method is doing more than its -name/signature might suggest. They also become challenging for others to digest since excessive +name/signature might suggest. They also become challenging for others to digest since excessive scrolling causes readers to lose focus. Try to reduce the method length by creating helper methods and removing any copy/pasted code. @@ -174,7 +174,7 @@ END; class="net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveObjectLengthRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#excessiveobjectlength"> -Excessive object line lengths are usually indications that the object may be burdened with excessive +Excessive object line lengths are usually indications that the object may be burdened with excessive responsibilities that could be provided by other objects. In breaking these methods apart the code becomes more managable and ripe for reuse. @@ -209,7 +209,7 @@ END; class="net.sourceforge.pmd.lang.plsql.rule.design.ExcessivePackageBodyLengthRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#excessivepackagebodylength"> -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. @@ -244,7 +244,7 @@ END; class="net.sourceforge.pmd.lang.plsql.rule.design.ExcessivePackageSpecificationLengthRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#excessivepackagespecificationlength"> -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. @@ -334,7 +334,7 @@ public class Foo { class="net.sourceforge.pmd.lang.plsql.rule.design.ExcessiveTypeLengthRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#excessivetypelength"> -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. @@ -420,7 +420,7 @@ CREATE OR REPLACE PACKAGE pkg_ externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_design.html#npathcomplexity"> The NPath complexity of a method is the number of acyclic execution paths through that method. -A threshold of 200 is generally considered the point where measures should be taken to reduce +A threshold of 200 is generally considered the point where measures should be taken to reduce complexity and increase readability. 3 @@ -470,7 +470,7 @@ END; externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_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 @@ -508,7 +508,7 @@ have more fine grained objects. or local-name(.) = 'TypeSpecification' ) - and + and ( count(/descendant::ProgramUnit[ not ( diff --git a/pmd-vm/src/main/resources/category/vm/design.xml b/pmd-vm/src/main/resources/category/vm/design.xml index e28b00d445..7bea5920f7 100644 --- a/pmd-vm/src/main/resources/category/vm/design.xml +++ b/pmd-vm/src/main/resources/category/vm/design.xml @@ -59,7 +59,7 @@ Avoid inline JavaScript. Import .js files instead. diff --git a/pmd-xml/src/main/resources/category/xsl/performance.xml b/pmd-xml/src/main/resources/category/xsl/performance.xml index 93180bb071..ebb954b755 100644 --- a/pmd-xml/src/main/resources/category/xsl/performance.xml +++ b/pmd-xml/src/main/resources/category/xsl/performance.xml @@ -35,7 +35,7 @@ cutting through 100% of the document. contains(@select,'following::') or contains(@select,'descendant::') - or + or contains(@select,'descendant-self::') or ( ($checkSelfDescendantAbreviation = 'true' ) From 58fa793e67f837217b0c8640ad560d5c1f8d87df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Fri, 24 Jan 2020 23:11:18 +0100 Subject: [PATCH 2/3] Fix indentation in poms For some reason pmd-apex and pmd-apex-jorje use 2 spaces while the rest use 4. --- pmd-core/pom.xml | 42 +++++++++++++-------------- pmd-doc/pom.xml | 6 ++-- pmd-java/pom.xml | 24 ++++++++-------- pmd-lang-test/pom.xml | 66 +++++++++++++++++++++---------------------- pom.xml | 66 +++++++++++++++++++++---------------------- 5 files changed, 102 insertions(+), 102 deletions(-) diff --git a/pmd-core/pom.xml b/pmd-core/pom.xml index 0b9a61ea5b..80aab40792 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 @@ -190,14 +190,14 @@ - m2e - - - - m2e.version - - - + m2e + + + + m2e.version + + + - - - - idea.maven.embedder.version - - - + idea + + + + + idea.maven.embedder.version + + + jaxen jaxen false - + diff --git a/pmd-doc/pom.xml b/pmd-doc/pom.xml index f1efc7fe1a..757a7b1499 100644 --- a/pmd-doc/pom.xml +++ b/pmd-doc/pom.xml @@ -95,9 +95,9 @@ commons-lang3 - org.apache.commons - commons-text - 1.6 + org.apache.commons + commons-text + 1.6 org.yaml diff --git a/pmd-java/pom.xml b/pmd-java/pom.xml index 1a5367f636..0dff843f17 100644 --- a/pmd-java/pom.xml +++ b/pmd-java/pom.xml @@ -154,18 +154,18 @@ slf4j-api test - - org.apache.logging.log4j - log4j-api - 2.12.1 - test - - - org.apache.logging.log4j - log4j-core - 2.12.1 - test - + + org.apache.logging.log4j + log4j-api + 2.12.1 + test + + + org.apache.logging.log4j + log4j-core + 2.12.1 + test + junit junit diff --git a/pmd-lang-test/pom.xml b/pmd-lang-test/pom.xml index d1ac5b4405..a245fd9193 100644 --- a/pmd-lang-test/pom.xml +++ b/pmd-lang-test/pom.xml @@ -45,39 +45,39 @@ - org.jetbrains.dokka - dokka-maven-plugin - ${dokka.version} - - - package - - - dokka - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - kotlin-javadoc - package - - jar - - - ${project.build.directory}/dokka - javadoc - - - - + org.jetbrains.dokka + dokka-maven-plugin + ${dokka.version} + + + package + + + dokka + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + kotlin-javadoc + package + + jar + + + ${project.build.directory}/dokka + javadoc + + + + diff --git a/pom.xml b/pom.xml index fb30089200..d8abf23ab3 100644 --- a/pom.xml +++ b/pom.xml @@ -8,13 +8,13 @@ PMD -PMD is a source code analyzer. It finds common programming flaws like unused variables, empty catch blocks, -unnecessary object creation, and so forth. It supports Java, JavaScript, Salesforce.com Apex and Visualforce, -Modelica, PLSQL, Apache Velocity, XML, XSL, Scala. + PMD is a source code analyzer. It finds common programming flaws like unused variables, empty catch blocks, + unnecessary object creation, and so forth. It supports Java, JavaScript, Salesforce.com Apex and Visualforce, + Modelica, PLSQL, Apache Velocity, XML, XSL, Scala. -Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code in -C/C++, C#, Dart, Fortran, Go, Groovy, Java, JavaScript, JSP, Kotlin, Lua, Matlab, Modelica, -Objective-C, Perl, PHP, PLSQL, Python, Ruby, Salesforce.com Apex, Scala, Swift and Visualforce. + Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code in + C/C++, C#, Dart, Fortran, Go, Groovy, Java, JavaScript, JSP, Kotlin, Lua, Matlab, Modelica, + Objective-C, Perl, PHP, PLSQL, Python, Ruby, Salesforce.com Apex, Scala, Swift and Visualforce. https://pmd.github.io/ @@ -297,7 +297,7 @@ Objective-C, Perl, PHP, PLSQL, Python, Ruby, Salesforce.com Apex, Scala, Swift a checkstyle-check verify - check + check @@ -388,9 +388,9 @@ Objective-C, Perl, PHP, PLSQL, Python, Ruby, Salesforce.com Apex, Scala, Swift a 1.6.8 - org.jacoco - jacoco-maven-plugin - 0.8.5 + org.jacoco + jacoco-maven-plugin + 0.8.5 @@ -616,9 +616,9 @@ Objective-C, Perl, PHP, PLSQL, Python, Ruby, Salesforce.com Apex, Scala, Swift a - com.beust - jcommander - 1.72 + com.beust + jcommander + 1.72 org.ow2.asm @@ -914,16 +914,16 @@ Objective-C, Perl, PHP, PLSQL, Python, Ruby, Salesforce.com Apex, Scala, Swift a - org.jacoco - jacoco-maven-plugin - - - default-prepare-agent - - prepare-agent - - - + org.jacoco + jacoco-maven-plugin + + + default-prepare-agent + + prepare-agent + + + org.eluder.coveralls @@ -963,16 +963,16 @@ Objective-C, Perl, PHP, PLSQL, Python, Ruby, Salesforce.com Apex, Scala, Swift a - org.jacoco - jacoco-maven-plugin - - - default-prepare-agent - - prepare-agent - - - + org.jacoco + jacoco-maven-plugin + + + default-prepare-agent + + prepare-agent + + + From d90d5d267c9790dacc24cbfb6787f65f064e4afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Fri, 24 Jan 2020 23:40:06 +0100 Subject: [PATCH 3/3] Remove trailing whitespace everywhere --- .../lang/apex/metrics/impl/CycloMetric.java | 2 +- .../apex/rule/AbstractApexUnitTestRule.java | 2 +- .../MethodNamingConventionsRule.java | 2 +- .../rule/design/CyclomaticComplexityRule.java | 2 +- .../rule/design/NcssConstructorCountRule.java | 2 +- .../apex/rule/design/NcssMethodCountRule.java | 2 +- .../apex/rule/design/NcssTypeCountRule.java | 2 +- .../design/StdCyclomaticComplexityRule.java | 4 +- .../errorprone/AvoidHardcodingIdRule.java | 14 +-- .../pmd/lang/apex/rule/internal/Helper.java | 8 +- .../security/ApexInsecureEndpointRule.java | 2 +- .../rule/security/ApexSOQLInjectionRule.java | 2 +- .../security/ApexSharingViolationsRule.java | 8 +- .../ApexSuggestUsingNamedCredRule.java | 2 +- .../security/ApexXSSFromURLParamRule.java | 2 +- .../pmd/lang/apex/rule/security/Helper.java | 8 +- .../pmd/lang/apex/ast/ApexLexerTest.java | 2 +- .../main/java/net/sourceforge/pmd/PMD.java | 6 +- .../net/sourceforge/pmd/PMDConfiguration.java | 6 +- .../java/net/sourceforge/pmd/PMDVersion.java | 22 ++--- .../main/java/net/sourceforge/pmd/Rule.java | 2 +- .../net/sourceforge/pmd/RuleSetFactory.java | 14 +-- .../pmd/RuleSetFactoryCompatibility.java | 2 +- .../java/net/sourceforge/pmd/RuleSets.java | 2 +- .../pmd/ThreadSafeReportListener.java | 2 +- .../pmd/ant/internal/PMDTaskImpl.java | 2 +- .../benchmark/TextTimingReportRenderer.java | 42 ++++----- .../pmd/benchmark/TimeTracker.java | 54 +++++------ .../pmd/benchmark/TimedOperation.java | 2 +- .../pmd/benchmark/TimedOperationCategory.java | 2 +- .../pmd/benchmark/TimingReport.java | 14 +-- .../sourceforge/pmd/cache/AnalysisCache.java | 2 +- .../pmd/cache/CachedRuleMapper.java | 2 +- .../sourceforge/pmd/cache/ChecksumAware.java | 2 +- .../pmd/cache/NoopAnalysisCache.java | 2 +- .../sourceforge/pmd/cpd/AntlrTokenizer.java | 2 +- .../sourceforge/pmd/cpd/CPDConfiguration.java | 10 +-- .../java/net/sourceforge/pmd/cpd/CPDTask.java | 12 +-- .../net/sourceforge/pmd/cpd/XMLRenderer.java | 2 +- .../pmd/cpd/internal/JavaCCTokenizer.java | 2 +- .../xpath/internal/DeprecatedAttribute.java | 2 +- .../pmd/lang/rule/AbstractRule.java | 2 +- .../pmd/lang/rule/RuleReference.java | 2 +- .../sourceforge/pmd/lang/rule/XPathRule.java | 2 +- .../pmd/processor/AbstractPMDProcessor.java | 12 +-- .../pmd/processor/MonoThreadProcessor.java | 2 +- .../pmd/processor/PmdRunnable.java | 4 +- .../builders/PropertyDescriptorBuilder.java | 2 +- .../SingleNumericPropertyBuilder.java | 2 +- .../AbstractIncrementingRenderer.java | 4 +- .../pmd/renderers/HTMLRenderer.java | 2 +- .../pmd/renderers/TextColorRenderer.java | 2 +- .../pmd/renderers/TextRenderer.java | 4 +- .../pmd/renderers/VBHTMLRenderer.java | 2 +- .../pmd/renderers/XMLRenderer.java | 2 +- .../pmd/util/database/DBMSMetadata.java | 4 +- .../net/sourceforge/pmd/AbstractRuleTest.java | 2 +- .../sourceforge/pmd/RuleReferenceTest.java | 2 +- .../pmd/RuleSetFactoryCompatibilityTest.java | 4 +- .../sourceforge/pmd/RuleSetFactoryTest.java | 2 +- .../pmd/cache/FileAnalysisCacheTest.java | 90 +++++++++---------- .../pmd/cpd/CPDConfigurationTest.java | 2 +- .../sourceforge/pmd/cpd/CPDFilelistTest.java | 4 +- .../pmd/junit/JavaUtilLoggingRule.java | 2 +- .../net/sourceforge/pmd/junit/LocaleRule.java | 2 +- .../AbstractRuleViolationFactoryTest.java | 2 +- .../pmd/lang/rule/XPathRuleTest.java | 2 +- .../processor/MultiThreadProcessorTest.java | 14 +-- .../pmd/renderers/CSVRendererTest.java | 4 +- .../renderers/CodeClimateRendererTest.java | 8 +- .../pmd/renderers/HTMLRendererTest.java | 2 +- .../renderers/SummaryHTMLRendererTest.java | 2 +- .../pmd/renderers/VBHTMLRendererTest.java | 2 +- .../pmd/renderers/XMLRendererTest.java | 2 +- .../util/datasource/FileDataSourceTest.java | 32 +++---- .../net/sourceforge/pmd/cpd/CPPLanguage.java | 2 +- .../net/sourceforge/pmd/cpd/CPPTokenizer.java | 4 +- .../sourceforge/pmd/lang/cpp/CppParser.java | 4 +- .../pmd/lang/cpp/CppTokenManager.java | 2 +- .../sourceforge/pmd/cpd/CPPTokenizerTest.java | 2 +- .../net/sourceforge/pmd/it/AllRulesIT.java | 2 +- .../sourceforge/pmd/docs/RuleTagChecker.java | 4 +- .../pmd/docs/MockedFileWriter.java | 2 +- .../sourceforge/pmd/cpd/FortranLanguage.java | 2 +- .../sourceforge/pmd/cpd/FortranTokenizer.java | 2 +- .../pmd/cpd/EdgeCasesTokenizerTest.java | 2 +- .../java/rule/design/ExcessiveLengthRule.java | 4 +- .../ModifiedCyclomaticComplexityRule.java | 4 +- .../java/rule/design/TooManyFieldsRule.java | 2 +- .../documentation/CodeInCommentsRule.java | 2 +- .../rule/documentation/CommentSizeRule.java | 4 +- .../documentation/HeaderCommentsRule.java | 2 +- .../AvoidCatchingThrowableRule.java | 2 +- ...UnsynchronizedStaticDateFormatterRule.java | 4 +- .../UnsynchronizedStaticFormatterRule.java | 6 +- .../AppendCharacterWithCharRule.java | 6 +- .../pmd/lang/java/rule/regex/RegexHelper.java | 8 +- .../java/symboltable/AbstractJavaScope.java | 2 +- .../SimpleTypedNameDeclaration.java | 2 +- .../typeresolution/PMDASMClassLoader.java | 4 +- .../lang/java/typeresolution/TypeHelper.java | 12 +-- .../JavaTypeDefinitionUpper.java | 2 +- .../java/xpath/TypeIsExactlyFunction.java | 2 +- .../pmd/lang/java/xpath/TypeIsFunction.java | 2 +- .../pmd/coverage/PMDCoverageTest.java | 2 +- .../pmd/cpd/CPDCommandLineInterfaceTest.java | 2 +- .../lang/java/rule/JavaRuleViolationTest.java | 6 +- .../pmd/lang/java/rule/XPathRuleTest.java | 4 +- .../ClassWithPublicEnum.java | 2 +- .../MyTestCase.java | 2 +- .../typeresolution/PMDASMClassLoaderTest.java | 2 +- .../testdata/EnumWithAnonymousInnerClass.java | 4 +- .../FieldAccessPrimaryGenericSimple.java | 2 +- .../testdata/MethodFirstPhase.java | 6 +- .../testdata/NestedAnonymousClass.java | 2 +- .../testdata/VarargsAsFixedArity.java | 4 +- .../testdata/VarargsZeroArity.java | 4 +- .../testdata/dummytypes/WildcardMethod.java | 2 +- .../pmd/lang/java/ast/ParserCornerCases.java | 6 +- .../lang/java/ast/ParserCornerCases17.java | 14 +-- .../lang/java/ast/ParserCornerCases18.java | 20 ++--- ...VariableTypeInferenceTryWithResources.java | 4 +- .../java12/MultipleCaseLabels.java | 2 +- .../java12/SwitchExpressions.java | 2 +- .../java12/SwitchExpressionsBreak.java | 2 +- .../jdkversiontests/java12/SwitchRules.java | 2 +- .../java13/SwitchExpressions.java | 10 +-- .../java13/SwitchExpressionsYield.java | 2 +- .../jdkversiontests/java13/TextBlocks.java | 8 +- .../jdk17_numerical_literals.java | 12 +-- .../pmd/cpd/EcmascriptLanguage.java | 2 +- .../java/net/sourceforge/pmd/cli/CLITest.java | 2 +- .../pmd/cpd/EcmascriptTokenizerTest.java | 6 +- .../pmd/lang/jsp/ast/OpenTagRegisterTest.java | 2 +- .../pmd/lang/matlab/MatlabParser.java | 2 +- .../pmd/cpd/MatlabTokenizerTest.java | 2 +- .../pmd/lang/objectivec/ObjectiveCParser.java | 2 +- .../cpd/UnicodeObjectiveCTokenizerTest.java | 2 +- .../sourceforge/pmd/cpd/PLSQLLanguage.java | 2 +- .../plsql/ast/ASTComparisonCondition.java | 2 +- .../rule/design/NcssMethodCountRule.java | 2 +- .../pmd/cpd/PLSQLTokenizerTest.java | 2 +- .../pmd/lang/python/PythonParser.java | 2 +- .../net/sourceforge/pmd/cpd/RubyLanguage.java | 2 +- .../sourceforge/pmd/cpd/RubyTokenizer.java | 2 +- .../sourceforge/pmd/cpd/ScalaTokenizer.java | 2 +- .../pmd/lang/scala/ScalaLanguageHandler.java | 4 +- .../pmd/lang/scala/ast/ASTCase.java | 2 +- .../pmd/lang/scala/ast/ASTCtorPrimary.java | 2 +- .../pmd/lang/scala/ast/ASTCtorSecondary.java | 2 +- .../pmd/lang/scala/ast/ASTDeclDef.java | 2 +- .../pmd/lang/scala/ast/ASTDeclType.java | 2 +- .../pmd/lang/scala/ast/ASTDeclVal.java | 2 +- .../pmd/lang/scala/ast/ASTDeclVar.java | 2 +- .../pmd/lang/scala/ast/ASTDefnClass.java | 2 +- .../pmd/lang/scala/ast/ASTDefnDef.java | 2 +- .../pmd/lang/scala/ast/ASTDefnMacro.java | 2 +- .../pmd/lang/scala/ast/ASTDefnObject.java | 2 +- .../pmd/lang/scala/ast/ASTDefnTrait.java | 2 +- .../pmd/lang/scala/ast/ASTDefnType.java | 2 +- .../pmd/lang/scala/ast/ASTDefnVal.java | 2 +- .../pmd/lang/scala/ast/ASTDefnVar.java | 2 +- .../scala/ast/ASTEnumeratorGenerator.java | 2 +- .../lang/scala/ast/ASTEnumeratorGuard.java | 2 +- .../pmd/lang/scala/ast/ASTEnumeratorVal.java | 2 +- .../pmd/lang/scala/ast/ASTImport.java | 2 +- .../pmd/lang/scala/ast/ASTImporteeName.java | 2 +- .../pmd/lang/scala/ast/ASTImporteeRename.java | 2 +- .../lang/scala/ast/ASTImporteeUnimport.java | 2 +- .../lang/scala/ast/ASTImporteeWildcard.java | 2 +- .../pmd/lang/scala/ast/ASTImporter.java | 2 +- .../pmd/lang/scala/ast/ASTInit.java | 2 +- .../pmd/lang/scala/ast/ASTLitBoolean.java | 2 +- .../pmd/lang/scala/ast/ASTLitByte.java | 2 +- .../pmd/lang/scala/ast/ASTLitChar.java | 2 +- .../pmd/lang/scala/ast/ASTLitDouble.java | 2 +- .../pmd/lang/scala/ast/ASTLitFloat.java | 2 +- .../pmd/lang/scala/ast/ASTLitInt.java | 2 +- .../pmd/lang/scala/ast/ASTLitLong.java | 2 +- .../pmd/lang/scala/ast/ASTLitNull.java | 2 +- .../pmd/lang/scala/ast/ASTLitShort.java | 2 +- .../pmd/lang/scala/ast/ASTLitString.java | 2 +- .../pmd/lang/scala/ast/ASTLitSymbol.java | 2 +- .../pmd/lang/scala/ast/ASTLitUnit.java | 2 +- .../pmd/lang/scala/ast/ASTModAbstract.java | 2 +- .../pmd/lang/scala/ast/ASTModAnnot.java | 2 +- .../pmd/lang/scala/ast/ASTModCase.java | 2 +- .../lang/scala/ast/ASTModContravariant.java | 2 +- .../pmd/lang/scala/ast/ASTModCovariant.java | 2 +- .../pmd/lang/scala/ast/ASTModFinal.java | 2 +- .../pmd/lang/scala/ast/ASTModImplicit.java | 2 +- .../pmd/lang/scala/ast/ASTModInline.java | 2 +- .../pmd/lang/scala/ast/ASTModLazy.java | 2 +- .../pmd/lang/scala/ast/ASTModOverride.java | 2 +- .../pmd/lang/scala/ast/ASTModPrivate.java | 2 +- .../pmd/lang/scala/ast/ASTModProtected.java | 2 +- .../pmd/lang/scala/ast/ASTModSealed.java | 2 +- .../pmd/lang/scala/ast/ASTModValParam.java | 2 +- .../pmd/lang/scala/ast/ASTModVarParam.java | 2 +- .../pmd/lang/scala/ast/ASTNameAnonymous.java | 2 +- .../lang/scala/ast/ASTNameIndeterminate.java | 2 +- .../pmd/lang/scala/ast/ASTPatAlternative.java | 2 +- .../pmd/lang/scala/ast/ASTPatBind.java | 2 +- .../pmd/lang/scala/ast/ASTPatExtract.java | 2 +- .../lang/scala/ast/ASTPatExtractInfix.java | 2 +- .../pmd/lang/scala/ast/ASTPatInterpolate.java | 2 +- .../pmd/lang/scala/ast/ASTPatSeqWildcard.java | 2 +- .../pmd/lang/scala/ast/ASTPatTuple.java | 2 +- .../pmd/lang/scala/ast/ASTPatTyped.java | 2 +- .../pmd/lang/scala/ast/ASTPatVar.java | 2 +- .../pmd/lang/scala/ast/ASTPatWildcard.java | 2 +- .../pmd/lang/scala/ast/ASTPatXml.java | 2 +- .../pmd/lang/scala/ast/ASTPkg.java | 2 +- .../pmd/lang/scala/ast/ASTPkgObject.java | 2 +- .../pmd/lang/scala/ast/ASTQuasi.java | 2 +- .../pmd/lang/scala/ast/ASTSelf.java | 2 +- .../pmd/lang/scala/ast/ASTTemplate.java | 2 +- .../pmd/lang/scala/ast/ASTTermAnnotate.java | 2 +- .../pmd/lang/scala/ast/ASTTermApply.java | 2 +- .../pmd/lang/scala/ast/ASTTermApplyInfix.java | 2 +- .../pmd/lang/scala/ast/ASTTermApplyType.java | 2 +- .../pmd/lang/scala/ast/ASTTermApplyUnary.java | 2 +- .../pmd/lang/scala/ast/ASTTermAscribe.java | 2 +- .../pmd/lang/scala/ast/ASTTermAssign.java | 2 +- .../pmd/lang/scala/ast/ASTTermBlock.java | 2 +- .../pmd/lang/scala/ast/ASTTermDo.java | 2 +- .../pmd/lang/scala/ast/ASTTermEta.java | 2 +- .../pmd/lang/scala/ast/ASTTermFor.java | 2 +- .../pmd/lang/scala/ast/ASTTermForYield.java | 2 +- .../pmd/lang/scala/ast/ASTTermFunction.java | 2 +- .../pmd/lang/scala/ast/ASTTermIf.java | 2 +- .../lang/scala/ast/ASTTermInterpolate.java | 2 +- .../pmd/lang/scala/ast/ASTTermMatch.java | 2 +- .../pmd/lang/scala/ast/ASTTermName.java | 2 +- .../pmd/lang/scala/ast/ASTTermNew.java | 2 +- .../lang/scala/ast/ASTTermNewAnonymous.java | 2 +- .../pmd/lang/scala/ast/ASTTermParam.java | 2 +- .../scala/ast/ASTTermPartialFunction.java | 2 +- .../lang/scala/ast/ASTTermPlaceholder.java | 2 +- .../pmd/lang/scala/ast/ASTTermRepeated.java | 2 +- .../pmd/lang/scala/ast/ASTTermReturn.java | 2 +- .../pmd/lang/scala/ast/ASTTermSelect.java | 2 +- .../pmd/lang/scala/ast/ASTTermSuper.java | 2 +- .../pmd/lang/scala/ast/ASTTermThis.java | 2 +- .../pmd/lang/scala/ast/ASTTermThrow.java | 2 +- .../pmd/lang/scala/ast/ASTTermTry.java | 2 +- .../lang/scala/ast/ASTTermTryWithHandler.java | 2 +- .../pmd/lang/scala/ast/ASTTermTuple.java | 2 +- .../pmd/lang/scala/ast/ASTTermWhile.java | 2 +- .../pmd/lang/scala/ast/ASTTermXml.java | 2 +- .../pmd/lang/scala/ast/ASTTypeAnd.java | 2 +- .../pmd/lang/scala/ast/ASTTypeAnnotate.java | 2 +- .../pmd/lang/scala/ast/ASTTypeApply.java | 2 +- .../pmd/lang/scala/ast/ASTTypeApplyInfix.java | 2 +- .../pmd/lang/scala/ast/ASTTypeBounds.java | 2 +- .../pmd/lang/scala/ast/ASTTypeByName.java | 2 +- .../lang/scala/ast/ASTTypeExistential.java | 2 +- .../pmd/lang/scala/ast/ASTTypeFunction.java | 2 +- .../scala/ast/ASTTypeImplicitFunction.java | 2 +- .../pmd/lang/scala/ast/ASTTypeLambda.java | 2 +- .../pmd/lang/scala/ast/ASTTypeMethod.java | 2 +- .../pmd/lang/scala/ast/ASTTypeName.java | 2 +- .../pmd/lang/scala/ast/ASTTypeOr.java | 2 +- .../pmd/lang/scala/ast/ASTTypeParam.java | 2 +- .../lang/scala/ast/ASTTypePlaceholder.java | 2 +- .../pmd/lang/scala/ast/ASTTypeProject.java | 2 +- .../pmd/lang/scala/ast/ASTTypeRefine.java | 2 +- .../pmd/lang/scala/ast/ASTTypeRepeated.java | 2 +- .../pmd/lang/scala/ast/ASTTypeSelect.java | 2 +- .../pmd/lang/scala/ast/ASTTypeSingleton.java | 2 +- .../pmd/lang/scala/ast/ASTTypeTuple.java | 2 +- .../pmd/lang/scala/ast/ASTTypeVar.java | 2 +- .../pmd/lang/scala/ast/ASTTypeWith.java | 2 +- .../lang/scala/ast/ScalaParserVisitor.java | 4 +- .../pmd/AbstractRuleSetFactoryTest.java | 12 +-- .../pmd/ant/AbstractAntTestHelper.java | 2 +- .../pmd/lang/vf/rule/security/VfCsrfRule.java | 2 +- .../pmd/lang/vf/ast/OpenTagRegisterTest.java | 2 +- .../sourceforge/pmd/lang/vm/util/LogUtil.java | 6 +- .../sourceforge/pmd/lang/vm/VmParserTest.java | 2 +- 280 files changed, 526 insertions(+), 526 deletions(-) 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 de089b5d89..3a76c745f3 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 96b9b32539..d30f61eb42 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 4c4c40b698..0e68c43273 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 @@ -10,7 +10,7 @@ import net.sourceforge.pmd.util.NumericConstants; /** * 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 563e5a5e8c..da2a496b8a 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 @@ -10,7 +10,7 @@ import net.sourceforge.pmd.util.NumericConstants; /** * 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 578a9f6dd4..5715f58969 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 @@ -14,7 +14,7 @@ import net.sourceforge.pmd.util.NumericConstants; /** * 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 82c4544574..cd9bad69c8 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 b536b34648..03a9493c17 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,23 +15,23 @@ 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() { setProperty(CODECLIMATE_CATEGORIES, "Style"); setProperty(CODECLIMATE_REMEDIATION_MULTIPLIER, 100); setProperty(CODECLIMATE_BLOCK_HIGHLIGHTING, false); - + addRuleChainVisit(ASTLiteralExpression.class); } @@ -59,11 +59,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 17599ebfee..26dc570a41 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 840a5f4f5d..0c818e5c7c 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 0862d83df3..2e7e69ef82 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 { @@ -49,7 +49,7 @@ public class ApexSharingViolationsRule extends AbstractApexRule { /** * Check if class contains any Database.query / Database.insert [ Database.* * ] methods - * + * * @param node * @param data */ @@ -79,7 +79,7 @@ public class ApexSharingViolationsRule extends AbstractApexRule { /** * Check if class has no sharing declared - * + * * @param node * @param data */ @@ -92,7 +92,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 bdb99d156c..1d967faff6 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 07de059ec6..fe4813f12a 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/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/src/main/java/net/sourceforge/pmd/PMD.java b/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java index 4bea022ce4..e93c667ac1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PMD.java @@ -463,11 +463,11 @@ public class PMD { */ public static int run(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(); @@ -493,7 +493,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/Rule.java b/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java index 643e04eb39..00eb948d7a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/Rule.java @@ -426,7 +426,7 @@ public interface Rule extends PropertySource { * the rule context */ void end(RuleContext ctx); - + /** * Creates a new copy of this rule. * @return A new exact copy of this rule 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 ead9f81333..a9229d480f 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 28abb9beb5..f2dd696575 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/ThreadSafeReportListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/ThreadSafeReportListener.java @@ -9,7 +9,7 @@ import net.sourceforge.pmd.stat.Metric; /** * 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/ant/internal/PMDTaskImpl.java b/pmd-core/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java index 3487d05f33..f78d78b8b9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java @@ -101,7 +101,7 @@ public class PMDTaskImpl { private void doTask() { setupClassLoader(); - + // Setup RuleSetFactory and validate RuleSets final ResourceLoader rl = setupResourceLoader(); RuleSetFactory ruleSetFactory = RulesetsFactoryUtils.getRulesetFactory(configuration, rl); 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 6aa88bc486..4174fa991f 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 @@ -22,16 +22,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; @@ -43,54 +43,54 @@ 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 TreeSet> sortedKeySet = new TreeSet<>( new Comparator>() { @@ -100,12 +100,12 @@ public class TextTimingReportRenderer implements TimingReportRenderer { } }); 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); @@ -114,23 +114,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 8bf202fa86..768d43b491 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,7 +37,7 @@ public final class TimeTracker { // noop } }; - + static { TIMER_ENTRIES = new ThreadLocal>() { @Override @@ -46,11 +46,11 @@ public final class TimeTracker { } }; } - + 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. @@ -61,7 +61,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. @@ -70,19 +70,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. */ @@ -90,10 +90,10 @@ public final class TimeTracker { if (!trackTime) { return; } - + startOperation(TimedOperationCategory.UNACCOUNTED); } - + /** * Finishes tracking a thread. */ @@ -101,15 +101,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. @@ -118,7 +118,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. @@ -129,11 +129,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. @@ -157,11 +157,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. */ @@ -169,7 +169,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(); @@ -180,7 +180,7 @@ public final class TimeTracker { return "TimerEntry for " + operation; } } - + /** * Aggregate results measured so far for a given category + label. */ @@ -189,7 +189,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 @@ -198,15 +198,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 @@ -216,14 +216,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 5876a7f77b..42944fb81d 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 @@ -26,7 +26,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 0bb4b61210..aeb4cb372c 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 @@ -21,7 +21,7 @@ import net.sourceforge.pmd.stat.Metric; @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/AntlrTokenizer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AntlrTokenizer.java index 9b668b729e..05b18eea5b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AntlrTokenizer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AntlrTokenizer.java @@ -15,7 +15,7 @@ import net.sourceforge.pmd.lang.ast.TokenMgrError; /** * Generic implementation of a {@link Tokenizer} useful to any Antlr grammar. - * + * * @deprecated This is an internal API. */ @Deprecated 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 e3b9ed5e6c..b8aa8c7e05 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 @@ -436,7 +436,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 398cf5ac5a..8be658244b 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 @@ -377,7 +377,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 0020968a93..773d64a5c0 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 @@ -46,7 +46,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/HTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java index 49e7551fb1..f9ef8b739a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java @@ -194,7 +194,7 @@ public class HTMLRenderer extends AbstractIncrementingRenderer { } writer.write(""); } - + private void glomConfigurationErrors(final Writer writer, final List configErrors) throws IOException { if (configErrors.isEmpty()) { return; 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/TextRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextRenderer.java index f3d3a70eae..6830c97b7c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextRenderer.java @@ -44,7 +44,7 @@ public class TextRenderer extends AbstractIncrementingRenderer { @Override public void end() throws IOException { StringBuilder buf = new StringBuilder(500); - + for (Report.ProcessingError error : errors) { buf.setLength(0); buf.append(determineFileName(error.getFile())); @@ -60,7 +60,7 @@ public class TextRenderer extends AbstractIncrementingRenderer { buf.append(" in ").append(determineFileName(excluded.getRuleViolation().getFilename())).append(PMD.EOL); writer.write(buf.toString()); } - + for (Report.ConfigurationError error : configErrors) { buf.setLength(0); buf.append(error.rule().getName()); 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/renderers/XMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java index 80e70f9a23..eb71e43749 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java @@ -144,7 +144,7 @@ public class XMLRenderer extends AbstractIncrementingRenderer { writer.write(buf.toString()); } } - + // config errors for (final Report.ConfigurationError ce : configErrors) { buf.setLength(0); 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/AbstractRuleTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java index 4850fdcb19..c037fab261 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java @@ -210,7 +210,7 @@ public class AbstractRuleTest { assertEquals("Rules with different messages are still equal", r1, r2); assertEquals("Rules that are equal must have the an equal hashcode", r1.hashCode(), r2.hashCode()); } - + @Test public void testDeepCopyRule() { MyRule r1 = new MyRule(); 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/RuleSetFactoryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java index d405caaebd..4c3fb20802 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetFactoryTest.java @@ -936,7 +936,7 @@ public class RuleSetFactoryTest { + " " + PMD.EOL + " " + PMD.EOL // inexistent property + " " + PMD.EOL + " " + PMD.EOL + ""; - + private static final String REF_INTERNAL_TO_INTERNAL = "" + PMD.EOL + "" + PMD.EOL + " testdesc" + PMD.EOL + " 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/AbstractRuleViolationFactoryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/AbstractRuleViolationFactoryTest.java index beb48181f5..08158b8eac 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/AbstractRuleViolationFactoryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/AbstractRuleViolationFactoryTest.java @@ -46,7 +46,7 @@ public class AbstractRuleViolationFactoryTest { ruleContext = new RuleContext(); factory = new TestRuleViolationFactory(); } - + @Test public void testMessage() { factory.addViolation(ruleContext, new TestRule(), null, "message with \"'{'\"", null); 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 61d6480090..3aa711568a 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 @@ -39,7 +39,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); @@ -66,14 +66,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"); @@ -138,7 +138,7 @@ public class MultiThreadProcessorTest { } } } - + public static class DysfunctionalRule extends AbstractRule { public static final String DYSFUNCTIONAL_RULE_REASON = "dysfunctional rule is dysfunctional"; @@ -147,7 +147,7 @@ public class MultiThreadProcessorTest { public void apply(List nodes, RuleContext ctx) { // noop } - + @Override public String dysfunctionReason() { return DYSFUNCTIONAL_RULE_REASON; @@ -166,7 +166,7 @@ public class MultiThreadProcessorTest { public void metricAdded(Metric metric) { } } - + private static class SimpleRenderer extends AbstractAccumulatingRenderer { /* default */ SimpleRenderer(String name, String description) { @@ -181,7 +181,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/SummaryHTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java index e3715069e1..e4421d2347 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java @@ -98,7 +98,7 @@ public class SummaryHTMLRendererTest extends AbstractRendererTest { + "file" + PMD.EOL + "
" + error.getDetail() + "
" + PMD.EOL + "" + PMD.EOL + "" + PMD.EOL; } - + @Override public String getExpectedError(ConfigurationError error) { return "PMD" + PMD.EOL + "

Summary

" + PMD.EOL 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