This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-numbers.git
commit c06ba43574a3e70639987a0b8a698aba0aeace0d Author: aherbert <[email protected]> AuthorDate: Wed Apr 1 11:57:02 2020 +0100 Fix some Complex PMD issues. Suppress loss of stack trace in Complex parse exception. --- .../apache/commons/numbers/complex/Complex.java | 2 +- src/main/resources/pmd/pmd-ruleset.xml | 29 ++++++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java index 95cd1e3..dbad564 100644 --- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java +++ b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java @@ -3147,7 +3147,7 @@ public final class Complex implements Serializable { // inner part final double realPart = nthRootOfAbs * Math.cos(innerPart); final double imaginaryPart = nthRootOfAbs * Math.sin(innerPart); - result.add(new Complex(realPart, imaginaryPart)); + result.add(ofCartesian(realPart, imaginaryPart)); innerPart += slice; } diff --git a/src/main/resources/pmd/pmd-ruleset.xml b/src/main/resources/pmd/pmd-ruleset.xml index 56920ca..5ee62ef 100644 --- a/src/main/resources/pmd/pmd-ruleset.xml +++ b/src/main/resources/pmd/pmd-ruleset.xml @@ -70,7 +70,7 @@ <rule ref="category/java/codestyle.xml/ShortMethodName"> <properties> <!-- TODO: Current regex effectively disables this rule. --> - <property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[matches(@Image, '^.*$')]"/> + <property name="violationSuppressXPath" value="//ClassOrInterfaceType[matches(@Image, '^.*$')]"/> </properties> </rule> <rule ref="category/java/codestyle.xml/ClassNamingConventions"> @@ -93,7 +93,7 @@ <rule ref="category/java/design.xml/ExcessivePublicCount"> <properties> <property name="violationSuppressXPath" - value="//ClassOrInterfaceDeclaration[@Image='Complex' + value="//ClassOrInterfaceType[@Image='Complex' or @Image='Fraction' or @Image='BigFraction']"/> </properties> @@ -101,7 +101,7 @@ <rule ref="category/java/design.xml/ExcessiveClassLength"> <properties> <property name="violationSuppressXPath" - value="//ClassOrInterfaceDeclaration[@Image='Complex' + value="//ClassOrInterfaceType[@Image='Complex' or @Image='Fraction' or @Image='BigFraction']"/> </properties> @@ -109,7 +109,7 @@ <rule ref="category/java/design.xml/GodClass"> <properties> <property name="violationSuppressXPath" - value="//ClassOrInterfaceDeclaration[@Image='Fraction']"/> + value="//ClassOrInterfaceType[@Image='Fraction']"/> </properties> </rule> @@ -117,7 +117,7 @@ <properties> <property name="ignoreMagicNumbers" value="-1,0,1" /> <property name="violationSuppressXPath" - value="//ClassOrInterfaceDeclaration[@Image='LogGamma' + value="//ClassOrInterfaceType[@Image='LogGamma' or @Image='LogGammaSum' or @Image='InverseErf' or @Image='InvGamma1pm1']"/> @@ -127,7 +127,7 @@ <rule ref="category/java/errorprone.xml/AvoidFieldNameMatchingMethodName"> <properties> <property name="violationSuppressXPath" - value="//ClassOrInterfaceDeclaration[@Image='Complex']"/> + value="//ClassOrInterfaceType[@Image='Complex']"/> </properties> </rule> @@ -135,7 +135,22 @@ <rule ref="category/java/design.xml/ExcessiveMethodLength"> <properties> <property name="violationSuppressXPath" - value="//ClassOrInterfaceDeclaration[@Image='Complex']"/> + value="//ClassOrInterfaceType[@Image='Complex']"/> + </properties> + </rule> + + <!-- Complex parse deliberately catches and re-throws a new NumberFormatException + to include the full input string in the exception message. --> + <rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException"> + <properties> + <property name="violationSuppressXPath" + value="//ClassOrInterfaceType[@Image='Complex']"/> + </properties> + </rule> + <rule ref="category/java/bestpractices.xml/PreserveStackTrace"> + <properties> + <property name="violationSuppressXPath" + value="//ClassOrInterfaceType[@Image='Complex']"/> </properties> </rule>
