You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2019/02/19 10:12:36 UTC
svn commit: r1853869 - in /santuario/xml-security-java/trunk: etc/
src/main/java/org/apache/jcp/xml/dsig/internal/dom/
src/main/java/org/apache/xml/security/c14n/implementations/
src/main/java/org/apache/xml/security/encryption/ src/main/java/org/apach...
Author: coheigea
Date: Tue Feb 19 10:12:36 2019
New Revision: 1853869
URL: http://svn.apache.org/viewvc?rev=1853869&view=rev
Log:
Finished PMD Work
Modified:
santuario/xml-security-java/trunk/etc/santuario-pmd-ruleset.xml
santuario/xml-security-java/trunk/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMReference.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTable.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/XMLCipherInput.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/DocumentContextImpl.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XMLUtils.java
santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java
santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java
santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/keyinfo/PGPDataTest.java
Modified: santuario/xml-security-java/trunk/etc/santuario-pmd-ruleset.xml
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/etc/santuario-pmd-ruleset.xml?rev=1853869&r1=1853868&r2=1853869&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/etc/santuario-pmd-ruleset.xml (original)
+++ santuario/xml-security-java/trunk/etc/santuario-pmd-ruleset.xml Tue Feb 19 10:12:36 2019
@@ -76,12 +76,9 @@
<exclude name="UseUtilityClass" />
</rule>
- <!-- TODO
<rule ref="category/java/errorprone.xml">
<exclude name="AssignmentInOperand" />
<exclude name="AssignmentToNonFinalStatic" />
- <exclude name="AvoidBranchingStatementAsLastInLoop" />
- <exclude name="AvoidAccessibilityAlteration" />
<exclude name="AvoidCatchingNPE" />
<exclude name="AvoidCatchingThrowable" />
<exclude name="AvoidDuplicateLiterals" />
@@ -92,22 +89,17 @@
<exclude name="ConstructorCallsOverridableMethod" />
<exclude name="DataflowAnomalyAnalysis" />
<exclude name="DoNotCallGarbageCollectionExplicitly" />
- <exclude name="DoNotCallSystemExit" />
<exclude name="EmptyCatchBlock" />
- <exclude name="EmptyIfStmt" />
- <exclude name="EmptySynchronizedBlock" />
<exclude name="InvalidSlf4jMessageFormat" />
<exclude name="JUnitSpelling" />
- <exclude name="MissingBreakInSwitch" />
<exclude name="MissingSerialVersionUID" />
- <exclude name="MoreThanOneLogger" />
<exclude name="NullAssignment" />
- <exclude name="ReturnEmptyArrayRatherThanNull" />
- <exclude name="TestClassWithoutTestCases" />
+ <exclude name="SingletonClassReturningNewInstance" />
+ <exclude name="SingleMethodSingleton" />
+ <exclude name="SuspiciousEqualsMethodName" />
<exclude name="UseLocaleWithCaseConversions" />
<exclude name="UseProperClassLoader" />
</rule>
- -->
<rule ref="category/java/multithreading.xml">
<exclude name="AvoidSynchronizedAtMethodLevel" />
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMReference.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMReference.java?rev=1853869&r1=1853868&r2=1853869&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMReference.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMReference.java Tue Feb 19 10:12:36 2019
@@ -545,7 +545,7 @@ public final class DOMReference extends
throw new XMLSignatureException(e);
} catch (org.apache.xml.security.c14n.CanonicalizationException e) {
throw new XMLSignatureException(e);
- } finally {
+ } finally { //NOPMD
if (dos != null) {
try {
dos.close();
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTable.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTable.java?rev=1853869&r1=1853868&r2=1853869&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTable.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTable.java Tue Feb 19 10:12:36 2019
@@ -60,7 +60,7 @@ public class NameSpaceSymbTable {
level = new ArrayList<>();
//Insert the default binding for xmlns.
try {
- symb = (SymbMap) initialMap.clone();
+ symb = initialMap.clone();
} catch (CloneNotSupportedException e) {
LOG.error("Error cloning the initial map");
}
@@ -77,7 +77,7 @@ public class NameSpaceSymbTable {
NameSpaceSymbEntry n = it.next();
//put them rendered?
if (!n.rendered && n.n != null) {
- n = (NameSpaceSymbEntry) n.clone();
+ n = n.clone();
needsClone();
symb.put(n.prefix, n);
n.lastrendered = n.uri;
@@ -136,7 +136,7 @@ public class NameSpaceSymbTable {
if (!cloned) {
level.set(level.size() - 1, symb);
try {
- symb = (SymbMap) symb.clone();
+ symb = symb.clone();
} catch (CloneNotSupportedException e) {
LOG.error("Error cloning the symbol map");
}
@@ -162,7 +162,7 @@ public class NameSpaceSymbTable {
return null;
}
// Mark this entry as render.
- entry = (NameSpaceSymbEntry) entry.clone();
+ entry = entry.clone();
needsClone();
symb.put(prefix, entry);
entry.rendered = true;
@@ -230,7 +230,7 @@ public class NameSpaceSymbTable {
if (ob != null && uri.equals(ob.uri)) {
if (!ob.rendered) {
- ob = (NameSpaceSymbEntry) ob.clone();
+ ob = ob.clone();
needsClone();
symb.put(prefix, ob);
ob.lastrendered = uri;
@@ -311,9 +311,9 @@ class NameSpaceSymbEntry implements Clon
}
/** {@inheritDoc} */
- public Object clone() {
+ public NameSpaceSymbEntry clone() { //NOPMD
try {
- return super.clone();
+ return (NameSpaceSymbEntry)super.clone();
} catch (CloneNotSupportedException e) {
return null;
}
@@ -398,7 +398,7 @@ class SymbMap implements Cloneable {
}
@Override
- protected Object clone() throws CloneNotSupportedException {
+ public SymbMap clone() throws CloneNotSupportedException {
SymbMap copy = (SymbMap) super.clone();
copy.entries = new NameSpaceSymbEntry[entries.length];
System.arraycopy(entries, 0, copy.entries, 0, entries.length);
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/XMLCipherInput.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/XMLCipherInput.java?rev=1853869&r1=1853868&r2=1853869&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/XMLCipherInput.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/XMLCipherInput.java Tue Feb 19 10:12:36 2019
@@ -96,7 +96,7 @@ public class XMLCipherInput {
* @throws XMLEncryptionException
* @return The decripted bytes.
*/
- public byte[] getBytes() throws XMLEncryptionException {
+ public byte[] getBytes() throws XMLEncryptionException { //NOPMD
if (mode == XMLCipher.DECRYPT_MODE) {
return getDecryptBytes();
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/DocumentContextImpl.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/DocumentContextImpl.java?rev=1853869&r1=1853868&r2=1853869&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/DocumentContextImpl.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/DocumentContextImpl.java Tue Feb 19 10:12:36 2019
@@ -101,8 +101,8 @@ public class DocumentContextImpl impleme
}
@Override
- protected DocumentContextImpl clone() throws CloneNotSupportedException {
- DocumentContextImpl documentContext = new DocumentContextImpl();
+ public DocumentContextImpl clone() throws CloneNotSupportedException {
+ DocumentContextImpl documentContext = (DocumentContextImpl)super.clone();
documentContext.setEncoding(this.encoding);
documentContext.setBaseURI(this.baseURI);
documentContext.setContentTypeMap(getContentTypeMap());
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XMLUtils.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XMLUtils.java?rev=1853869&r1=1853868&r2=1853869&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XMLUtils.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XMLUtils.java Tue Feb 19 10:12:36 2019
@@ -154,7 +154,7 @@ public final class XMLUtils {
if (rootNode == exclude) {
return;
}
- switch (rootNode.getNodeType()) {
+ switch (rootNode.getNodeType()) { //NOPMD
case Node.ELEMENT_NODE:
result.add(rootNode);
Element el = (Element)rootNode;
@@ -179,14 +179,14 @@ public final class XMLUtils {
}
getSetRec(r, result, exclude, com);
}
- return;
+ break;
case Node.COMMENT_NODE:
if (com) {
result.add(rootNode);
}
- return;
+ break;
case Node.DOCUMENT_TYPE_NODE:
- return;
+ break;
default:
result.add(rootNode);
}
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java?rev=1853869&r1=1853868&r2=1853869&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java Tue Feb 19 10:12:36 2019
@@ -288,7 +288,7 @@ public class TestUtils {
}
public byte[] getCalculatedDigestValue() {
- return null;
+ return new byte[0];
}
public DigestMethod getDigestMethod() { return DIG_METHOD; }
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java?rev=1853869&r1=1853868&r2=1853869&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java Tue Feb 19 10:12:36 2019
@@ -156,7 +156,7 @@ public class KeyInfoTest {
@Override
public byte[] getEncoded() {
- return null;
+ return new byte[0];
}
@Override
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/keyinfo/PGPDataTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/keyinfo/PGPDataTest.java?rev=1853869&r1=1853868&r2=1853869&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/keyinfo/PGPDataTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/keyinfo/PGPDataTest.java Tue Feb 19 10:12:36 2019
@@ -125,14 +125,11 @@ public class PGPDataTest {
public void testisFeatureSupported() {
PGPData pd = null;
for (int i = 0; i < 3; i++) {
- switch (i) {
- case 0:
+ if (i == 0) {
pd = fac.newPGPData(values[0]);
- break;
- case 1:
+ } else if (i == 1) {
pd = fac.newPGPData(values[0], values[1], null);
- break;
- case 2:
+ } else {
pd = fac.newPGPData(values[1], null);
}
try {