Skip to content

Commit cf2e20f

Browse files
committed
Update to latest PMD 7.0.0-SNAPSHOT
1 parent 35a36c8 commit cf2e20f

File tree

16 files changed

+256
-140
lines changed

16 files changed

+256
-140
lines changed

custom-rules/maven-java/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ The result is a zip file: `target/pmd-java-bin-1.0.0-SNAPSHOT.zip`.
5757

5858
```xml
5959
<properties>
60-
<pmd.version>7.0.0-rc3</pmd.version>
60+
<pmd.version>7.0.0-SNAPSHOT</pmd.version>
6161
</properties>
6262
...
6363
<plugin>
6464
<groupId>org.apache.maven.plugins</groupId>
6565
<artifactId>maven-pmd-plugin</artifactId>
66-
<version>3.21.1-pmd-7-SNAPSHOT</version>
66+
<version>3.21.2</version>
6767
<executions>
6868
<execution>
6969
<phase>verify</phase>
@@ -86,6 +86,11 @@ The result is a zip file: `target/pmd-java-bin-1.0.0-SNAPSHOT.zip`.
8686
<artifactId>pmd-java-custom</artifactId>
8787
<version>1.0.0-SNAPSHOT</version>
8888
</dependency>
89+
<dependency>
90+
<groupId>net.sourceforge.pmd</groupId>
91+
<artifactId>pmd-compat6</artifactId>
92+
<version>${pmd.version}</version>
93+
</dependency>
8994
<dependency>
9095
<groupId>net.sourceforge.pmd</groupId>
9196
<artifactId>pmd-core</artifactId>

custom-rules/maven-java/pmd-java-custom/src/main/java/net/sourceforge/pmd/examples/java/rules/MyRule.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import org.checkerframework.checker.nullness.qual.NonNull;
44

5-
import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId;
5+
import net.sourceforge.pmd.lang.java.ast.ASTVariableId;
66
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
77
import net.sourceforge.pmd.lang.rule.RuleTargetSelector;
88
import net.sourceforge.pmd.properties.PropertyDescriptor;
@@ -21,11 +21,11 @@ public MyRule() {
2121

2222
@Override
2323
protected @NonNull RuleTargetSelector buildTargetSelector() {
24-
return RuleTargetSelector.forTypes(ASTVariableDeclaratorId.class);
24+
return RuleTargetSelector.forTypes(ASTVariableId.class);
2525
}
2626

2727
@Override
28-
public Object visit(ASTVariableDeclaratorId node, Object data) {
28+
public Object visit(ASTVariableId node, Object data) {
2929
String badName = getProperty(BAD_NAME);
3030
if (badName.equals(node.getName())) {
3131
asCtx(data).addViolation(node, node.getName());

custom-rules/maven-java/pmd-java-custom/src/main/resources/net/sourceforge/pmd/examples/java/rules/VariableNaming.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Rule set which defines VariableNamingRule
1111

1212
<rule name="VariableNaming"
1313
language="java"
14-
class="net.sourceforge.pmd.lang.rule.XPathRule"
14+
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
1515
message="Variables should be all lowercase">
1616
<description>
1717
Variables should be all lowercase.
@@ -21,11 +21,10 @@ Variables should be all lowercase.
2121
<property name="xpath">
2222
<value>
2323
<![CDATA[
24-
//VariableDeclaratorId[not(matches(@Name, $pattern))]
24+
//VariableId[not(matches(@Name, $pattern))]
2525
]]>
2626
</value>
2727
</property>
28-
<property name="version" value="2.0" />
2928
<property name="pattern" type="Regex" value="^[a-z_]+$" description="Pattern for valid variable names"/>
3029
</properties>
3130
<example>

custom-rules/maven-java/pmd-java-dist/pom.xml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,21 @@
4848
</plugin>
4949
<plugin>
5050
<artifactId>maven-assembly-plugin</artifactId>
51-
<dependencies>
52-
<dependency>
53-
<groupId>net.sourceforge.pmd</groupId>
54-
<artifactId>pmd-dist</artifactId>
55-
<version>${pmd.version}</version>
56-
</dependency>
57-
</dependencies>
51+
<!-- <dependencies>-->
52+
<!-- <dependency>-->
53+
<!-- <groupId>net.sourceforge.pmd</groupId>-->
54+
<!-- <artifactId>pmd-dist</artifactId>-->
55+
<!-- <version>${pmd.version}</version>-->
56+
<!-- </dependency>-->
57+
<!-- </dependencies>-->
5858
<configuration>
5959
<attach>false</attach>
6060
<archiverConfig>
6161
<defaultDirectoryMode>493</defaultDirectoryMode> <!-- 0755 -->
6262
</archiverConfig>
63-
<descriptorRefs>
64-
<descriptorRef>pmd-bin</descriptorRef>
65-
</descriptorRefs>
63+
<descriptors>
64+
<descriptor>src/main/resources/assemblies/pmd-bin-without-sbom.xml</descriptor>
65+
</descriptors>
6666
</configuration>
6767
<executions>
6868
<execution>
@@ -99,13 +99,6 @@
9999
<groupId>net.sourceforge.pmd</groupId>
100100
<artifactId>pmd-cli</artifactId>
101101
</dependency>
102-
<!-- include bash/zsh completions -->
103-
<dependency>
104-
<groupId>net.sourceforge.pmd</groupId>
105-
<artifactId>pmd-cli</artifactId>
106-
<type>sh</type>
107-
<classifier>completion</classifier>
108-
</dependency>
109102
</dependencies>
110103

111104
</project>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.1 https://maven.apache.org/xsd/assembly-2.1.1.xsd">
3+
4+
<id>bin</id>
5+
<formats>
6+
<format>zip</format>
7+
</formats>
8+
9+
<includeBaseDirectory>true</includeBaseDirectory>
10+
<baseDirectory>${pmd.dist.bin.baseDirectory}</baseDirectory>
11+
12+
<fileSets>
13+
<fileSet>
14+
<includes>
15+
<include>*.bat</include>
16+
</includes>
17+
<directory>target/extra-resources/scripts</directory>
18+
<outputDirectory>bin</outputDirectory>
19+
<fileMode>0755</fileMode>
20+
<directoryMode>0755</directoryMode>
21+
<lineEnding>dos</lineEnding>
22+
</fileSet>
23+
24+
<fileSet>
25+
<includes>
26+
<include>pmd</include>
27+
</includes>
28+
<directory>target/extra-resources/scripts</directory>
29+
<outputDirectory>bin</outputDirectory>
30+
<fileMode>0755</fileMode>
31+
<directoryMode>0755</directoryMode>
32+
<lineEnding>unix</lineEnding>
33+
</fileSet>
34+
35+
<fileSet>
36+
<includes>
37+
<include>LICENSE</include>
38+
</includes>
39+
<directory>target/extra-resources</directory>
40+
<outputDirectory>.</outputDirectory>
41+
<directoryMode>0755</directoryMode>
42+
<fileMode>0644</fileMode>
43+
</fileSet>
44+
45+
<fileSet>
46+
<includes>
47+
<include>simplelogger.properties</include>
48+
</includes>
49+
<directory>target/extra-resources/conf</directory>
50+
<outputDirectory>conf</outputDirectory>
51+
<directoryMode>0755</directoryMode>
52+
<fileMode>0644</fileMode>
53+
</fileSet>
54+
</fileSets>
55+
56+
<dependencySets>
57+
<!-- jar dependencies go to lib/ -->
58+
<dependencySet>
59+
<scope>runtime</scope>
60+
<excludes>
61+
<exclude>net.sourceforge.pmd:pmd-apex-jorje:pom</exclude>
62+
<exclude>net.sourceforge.pmd:pmd-languages-deps:pom</exclude>
63+
</excludes>
64+
<outputDirectory>lib</outputDirectory>
65+
<directoryMode>0755</directoryMode>
66+
<fileMode>0644</fileMode>
67+
<useProjectArtifact>false</useProjectArtifact>
68+
</dependencySet>
69+
</dependencySets>
70+
</assembly>

custom-rules/maven-java/pom.xml

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
<java.version>8</java.version>
1616
<maven.compiler.release>${java.version}</maven.compiler.release>
17-
<pmd.version>7.0.0-rc3</pmd.version>
18-
<pmd.ui.version>7.0.0-rc1</pmd.ui.version>
17+
<pmd.version>7.0.0-SNAPSHOT</pmd.version>
18+
<pmd.ui.version>7.0.0-SNAPSHOT</pmd.ui.version>
1919
</properties>
2020

2121
<dependencyManagement>
@@ -48,22 +48,6 @@
4848
</exclusion>
4949
</exclusions>
5050
</dependency>
51-
<!-- include bash/zsh completions -->
52-
<dependency>
53-
<groupId>net.sourceforge.pmd</groupId>
54-
<artifactId>pmd-cli</artifactId>
55-
<version>${pmd.version}</version>
56-
<type>sh</type>
57-
<classifier>completion</classifier>
58-
<scope>runtime</scope>
59-
<exclusions>
60-
<!-- exclude pmd-languages-deps because we only want to include pmd-java in our custom distribution -->
61-
<exclusion>
62-
<groupId>net.sourceforge.pmd</groupId>
63-
<artifactId>pmd-languages-deps</artifactId>
64-
</exclusion>
65-
</exclusions>
66-
</dependency>
6751
<dependency>
6852
<groupId>net.sourceforge.pmd</groupId>
6953
<artifactId>pmd-test</artifactId>
@@ -97,34 +81,36 @@
9781
<artifactId>maven-dependency-plugin</artifactId>
9882
<version>3.6.0</version>
9983
</plugin>
100-
<plugin>
101-
<groupId>org.cyclonedx</groupId>
102-
<artifactId>cyclonedx-maven-plugin</artifactId>
103-
<version>2.7.6</version>
104-
</plugin>
84+
<!-- Optional: -->
85+
<!-- <plugin>-->
86+
<!-- <groupId>org.cyclonedx</groupId>-->
87+
<!-- <artifactId>cyclonedx-maven-plugin</artifactId>-->
88+
<!-- <version>2.7.6</version>-->
89+
<!-- </plugin>-->
10590
</plugins>
10691
</pluginManagement>
10792
<plugins>
108-
<plugin>
109-
<groupId>org.cyclonedx</groupId>
110-
<artifactId>cyclonedx-maven-plugin</artifactId>
111-
<executions>
112-
<execution>
113-
<phase>package</phase>
114-
<goals>
115-
<goal>makeAggregateBom</goal>
116-
</goals>
117-
</execution>
118-
</executions>
93+
<!-- Optional: -->
94+
<!-- <plugin>-->
95+
<!-- <groupId>org.cyclonedx</groupId>-->
96+
<!-- <artifactId>cyclonedx-maven-plugin</artifactId>-->
97+
<!-- <executions>-->
98+
<!-- <execution>-->
99+
<!-- <phase>package</phase>-->
100+
<!-- <goals>-->
101+
<!-- <goal>makeAggregateBom</goal>-->
102+
<!-- </goals>-->
103+
<!-- </execution>-->
104+
<!-- </executions>-->
119105
<!-- https://github.com/CycloneDX/cyclonedx-maven-plugin/issues/326 -->
120-
<dependencies>
121-
<dependency>
122-
<groupId>org.ow2.asm</groupId>
123-
<artifactId>asm</artifactId>
124-
<version>9.5</version>
125-
</dependency>
126-
</dependencies>
127-
</plugin>
106+
<!-- <dependencies>-->
107+
<!-- <dependency>-->
108+
<!-- <groupId>org.ow2.asm</groupId>-->
109+
<!-- <artifactId>asm</artifactId>-->
110+
<!-- <version>9.5</version>-->
111+
<!-- </dependency>-->
112+
<!-- </dependencies>-->
113+
<!-- </plugin>-->
128114
</plugins>
129115
</build>
130116

custom-rules/maven-plsql/pmd-plsql-custom/src/main/java/net/sourceforge/pmd/examples/plsql/rules/ShortVariableRule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import net.sourceforge.pmd.lang.plsql.ast.ASTVariableOrConstantDeclaratorId;
1111
import net.sourceforge.pmd.lang.plsql.rule.AbstractPLSQLRule;
1212
import net.sourceforge.pmd.lang.rule.RuleTargetSelector;
13+
import net.sourceforge.pmd.properties.NumericConstraints;
1314
import net.sourceforge.pmd.properties.PropertyDescriptor;
1415
import net.sourceforge.pmd.properties.PropertyFactory;
15-
import net.sourceforge.pmd.properties.constraints.NumericConstraints;
1616

1717
public class ShortVariableRule extends AbstractPLSQLRule {
1818

custom-rules/maven-plsql/pmd-plsql-custom/src/main/resources/net/sourceforge/pmd/examples/plsql/rules/VariableNaming.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Rule set which defines VariableNamingRule
1212
<rule name="VariableNaming"
1313
language="plsql"
1414
message="Variables should be all lowercase"
15-
class="net.sourceforge.pmd.lang.rule.XPathRule">
15+
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
1616
<description>
1717
Variables should be all lowercase.
1818
</description>
@@ -25,7 +25,6 @@ Variables should be all lowercase.
2525
]]>
2626
</value>
2727
</property>
28-
<property name="version" value="2.0" />
2928
<property name="pattern" type="Regex" value="^[a-z_]+$" description="Pattern for valid variable names"/>
3029
</properties>
3130
<example>

custom-rules/maven-plsql/pmd-plsql-dist/pom.xml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,23 @@
4848
</plugin>
4949
<plugin>
5050
<artifactId>maven-assembly-plugin</artifactId>
51-
<dependencies>
52-
<dependency>
53-
<groupId>net.sourceforge.pmd</groupId>
54-
<artifactId>pmd-dist</artifactId>
55-
<version>${pmd.version}</version>
56-
</dependency>
57-
</dependencies>
51+
<!-- <dependencies>-->
52+
<!-- <dependency>-->
53+
<!-- <groupId>net.sourceforge.pmd</groupId>-->
54+
<!-- <artifactId>pmd-dist</artifactId>-->
55+
<!-- <version>${pmd.version}</version>-->
56+
<!-- </dependency>-->
57+
<!-- </dependencies>-->
5858
<configuration>
5959
<appendAssemblyId>false</appendAssemblyId>
6060
<attach>false</attach>
6161
<archiverConfig>
6262
<defaultDirectoryMode>493</defaultDirectoryMode> <!-- 0755 -->
6363
</archiverConfig>
6464
<finalName>${pmd.dist.bin.baseDirectory}</finalName>
65-
<descriptorRefs>
66-
<descriptorRef>pmd-bin</descriptorRef>
67-
</descriptorRefs>
65+
<descriptors>
66+
<descriptor>src/main/resources/assemblies/pmd-bin-without-sbom.xml</descriptor>
67+
</descriptors>
6868
</configuration>
6969
<executions>
7070
<execution>
@@ -101,13 +101,6 @@
101101
<groupId>net.sourceforge.pmd</groupId>
102102
<artifactId>pmd-cli</artifactId>
103103
</dependency>
104-
<!-- include bash/zsh completions -->
105-
<dependency>
106-
<groupId>net.sourceforge.pmd</groupId>
107-
<artifactId>pmd-cli</artifactId>
108-
<type>sh</type>
109-
<classifier>completion</classifier>
110-
</dependency>
111104
</dependencies>
112105

113106
</project>

0 commit comments

Comments
 (0)