This is an automated email from the ASF dual-hosted git repository.

ppkarwasz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/commons-xml.git


The following commit(s) were added to refs/heads/main by this push:
     new 37f5ef9  Add Maven PMD plugin. (#8)
37f5ef9 is described below

commit 37f5ef9aed862edf0b43aed0be99c54de2a1abc4
Author: Gary Gregory <[email protected]>
AuthorDate: Tue Jun 23 15:56:39 2026 -0400

    Add Maven PMD plugin. (#8)
---
 pom.xml                                            | 20 ++++++++++-
 src/conf/maven-pmd-plugin.xml                      | 39 ++++++++++++++++++++++
 .../org/apache/commons/xml/AndroidProvider.java    |  2 +-
 src/main/java/org/apache/commons/xml/Limits.java   |  2 +-
 4 files changed, 60 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index 473f305..b433e35 100644
--- a/pom.xml
+++ b/pom.xml
@@ -104,7 +104,7 @@ limitations under the License.
   </dependencies>
 
   <build>
-    <defaultGoal>clean checkstyle:check spotbugs:check verify</defaultGoal>
+    <defaultGoal>clean checkstyle:check spotbugs:check pmd:check 
verify</defaultGoal>
     <pluginManagement>
       <plugins>
         <plugin>
@@ -124,6 +124,15 @@ limitations under the License.
             
<excludeFilterFile>${basedir}/src/conf/spotbugs-exclude-filter.xml</excludeFilterFile>
           </configuration>
         </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-pmd-plugin</artifactId>
+          <configuration>
+            <rulesets>
+              <ruleset>src/conf/maven-pmd-plugin.xml</ruleset>
+            </rulesets>
+          </configuration>
+        </plugin>
       </plugins>
     </pluginManagement>
     <plugins>
@@ -368,6 +377,15 @@ limitations under the License.
           
<excludeFilterFile>${basedir}/src/conf/spotbugs-exclude-filter.xml</excludeFilterFile>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-pmd-plugin</artifactId>
+        <configuration>
+          <rulesets>
+            <ruleset>src/conf/maven-pmd-plugin.xml</ruleset>
+          </rulesets>
+        </configuration>
+      </plugin>
     </plugins>
   </reporting>
  <profiles>
diff --git a/src/conf/maven-pmd-plugin.xml b/src/conf/maven-pmd-plugin.xml
new file mode 100644
index 0000000..afd5b7a
--- /dev/null
+++ b/src/conf/maven-pmd-plugin.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+https://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<ruleset name="Default Maven PMD Plugin Ruleset"
+    xmlns="http://pmd.sourceforge.net/ruleset/2.0.0";
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 
https://pmd.sourceforge.net/ruleset_2_0_0.xsd";>
+    <description>
+        The default ruleset used by the Maven PMD Plugin, when no other 
ruleset is specified.
+        It contains the rules of the old (pre PMD 6.0.0) rulesets java-basic, 
java-empty, java-imports,
+        java-unnecessary, java-unusedcode.
+
+        This ruleset might be used as a starting point for an own customized 
ruleset [0].
+
+        [0] https://pmd.github.io/latest/pmd_userdocs_making_rulesets.html
+    </description>
+    <rule ref="category/java/errorprone.xml/EmptyCatchBlock">
+      <properties>
+        <property name="allowCommentedBlocks" value="true" />
+        <property name="allowExceptionNameRegex" value="^(ignored|expected)$" 
/>
+      </properties>
+    </rule>
+</ruleset>
diff --git a/src/main/java/org/apache/commons/xml/AndroidProvider.java 
b/src/main/java/org/apache/commons/xml/AndroidProvider.java
index 34abb5d..c71aacb 100644
--- a/src/main/java/org/apache/commons/xml/AndroidProvider.java
+++ b/src/main/java/org/apache/commons/xml/AndroidProvider.java
@@ -188,7 +188,7 @@ static XMLReader configure(final XMLReader reader) {
         reader.setEntityResolver(resolver);
         try {
             reader.setProperty(LEXICAL_HANDLER_PROPERTY, resolver);
-        } catch (final SAXException e) {
+        } catch (final SAXException ignore) {
             // ExpatReader recognises the lexical-handler property; if a 
future replacement does not, fall through and lose subset-vs-entity 
discrimination.
         }
         return new GuardedXMLReader(reader);
diff --git a/src/main/java/org/apache/commons/xml/Limits.java 
b/src/main/java/org/apache/commons/xml/Limits.java
index d84f8e0..c1f9a8f 100644
--- a/src/main/java/org/apache/commons/xml/Limits.java
+++ b/src/main/java/org/apache/commons/xml/Limits.java
@@ -299,7 +299,7 @@ static void applyToXerces(final Object securityManager) {
             final Class<?> clazz = securityManager.getClass();
             clazz.getMethod("setEntityExpansionLimit", 
int.class).invoke(securityManager, getEntityExpansionLimit());
             clazz.getMethod("setMaxOccurNodeLimit", 
int.class).invoke(securityManager, getMaxOccurLimit());
-        } catch (final ReflectiveOperationException e) {
+        } catch (final ReflectiveOperationException ignore) {
             // Class on the classpath is not the expected Xerces 
SecurityManager; leave the limits at whatever defaults it carries.
         }
     }

Reply via email to