Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
f4be76b
[core] add IDE agnostic configuration with Maven Spotless Plugin
Jun 30, 2025
2fd6591
Fix #5770: [java] evolute UnnecessaryLocalBeforeReturnRule to Unneces…
Jul 1, 2025
5912664
Merge branch 'main' into Spotless-pr
Jul 8, 2025
c282a34
Automatically fix Checkstyle violations
Jul 8, 2025
1dca0d6
rewrite-maven-plugin
Jul 8, 2025
9065ca6
rewrite-maven-plugin
Jul 8, 2025
3a4c720
rewrite-maven-plugin
Jul 8, 2025
867420d
rewrite-maven-plugin
Jul 8, 2025
9053a7f
rewrite-maven-plugin
Jul 8, 2025
4407073
rewrite-maven-plugin
Jul 8, 2025
399b284
rewrite-maven-plugin
Jul 8, 2025
90e8597
rewrite-maven-plugin
Jul 8, 2025
1a68f7e
rewrite-maven-plugin
Jul 8, 2025
5ab8e10
rewrite-maven-plugin
Jul 8, 2025
6571961
rewrite-maven-plugin
Jul 8, 2025
82dd4bc
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
0e4f8ce
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
c864ec9
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
790f039
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
b67ea6d
Merge branch 'main' into rewrite-Automatically-fix-Checkstyle-violati…
Jul 11, 2025
3954f63
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
48391c9
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
f53105f
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
57b145d
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
e7558eb
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
be40fc9
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
2a28a95
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
596137b
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
2ad207f
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
d6e551b
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
337dc55
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
e5f9734
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
5299c91
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
9f22a85
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
e4b15ad
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
221b278
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
9e79064
Fix #5852: [java] UnnecessaryImport with multiple static imports from…
Jul 11, 2025
26c1409
s
Jul 11, 2025
8fa1d04
rewrite
Jul 11, 2025
604d5dc
rewrite
Jul 11, 2025
76a6b4d
rewrite
Jul 11, 2025
0521eab
rewrite
Jul 11, 2025
b8b544e
rewrite
Jul 11, 2025
c5add41
rewrite
Jul 11, 2025
2076164
rewrite
Jul 11, 2025
30c9b8a
rewrite
Jul 11, 2025
6af092e
rewrite
Jul 11, 2025
7bf9b0c
rewrite
Jul 11, 2025
fc11aa8
rewrite
Jul 11, 2025
046ce0a
rewrite
Jul 11, 2025
4b7b167
rewrite
Jul 11, 2025
2247589
rewrite
Jul 11, 2025
097ba3f
rewrite
Jul 11, 2025
b6ae2c7
rewrite
Jul 11, 2025
eecea40
rewrite
Jul 11, 2025
217a11e
checkstyle removal
Jul 11, 2025
eb7de01
checkstyle removal
Jul 11, 2025
834f0e5
checkstyle removal
Jul 11, 2025
5b215ca
checkstyle removal
Jul 11, 2025
675eab9
checkstyle removal
Jul 11, 2025
d639165
AutoFormat
Jul 11, 2025
4a62647
AutoFormat
Jul 11, 2025
856a5ad
AutoFormat
Jul 11, 2025
ebc441d
Merge branch 'fork_main' into replace-checkstyle-with-rewrite-pr
Jul 11, 2025
f876c4d
AutoFormat
Jul 11, 2025
46d2aec
AutoFormat
Jul 11, 2025
05dd720
AutoFormat
Jul 11, 2025
ed6433e
AutoFormat
Jul 11, 2025
3dc0560
AutoFormat
Jul 11, 2025
3297f01
AutoFormat
Jul 11, 2025
f7ecb6a
apply
Jul 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 0 additions & 27 deletions .ci/files/project-list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,6 @@
xsi:noNamespaceSchemaLocation="projectlist_1_1_0.xsd">
<description>Standard Projects</description>

<project>
<name>checkstyle</name>
<type>git</type>
<connection>https://github.com/checkstyle/checkstyle</connection>
<tag>checkstyle-9.1</tag>

<exclude-pattern>.*/target/test-classes/com/puppycrawl/tools/checkstyle/.*</exclude-pattern>
<exclude-pattern>.*/target/generated-sources/.*</exclude-pattern>
<exclude-pattern>.*/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/javaparser/InputJavaParserNoFreezeOnDeeplyNestedLambdas.java</exclude-pattern>

<build-command><![CDATA[#!/usr/bin/env bash
if test -e classpath.txt; then
exit
fi

set -e

# Make sure to use java11. This is already installed by build.yml/publish-snapshot.yml/publish-release.yml
export JAVA_HOME=${HOME}/openjdk11
export PATH=$JAVA_HOME/bin:$PATH

mvn test-compile -B
mvn dependency:build-classpath -DincludeScope=test -Dmdep.outputFile=classpath.txt -B
]]></build-command>
<auxclasspath-command>echo -n "$(pwd)/target/classes:$(pwd)/target/test-classes:"; cat classpath.txt</auxclasspath-command>
</project>

<project>
<name>spring-framework</name>
<type>git</type>
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ target/
bin/
.project
.classpath
.checkstyle
.pmd
.pmdruleset.xml
.ruleset
Expand Down
6 changes: 1 addition & 5 deletions docs/pages/pmd/devdocs/contributing/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ There are various channels, on which you can ask questions:

## Code Style

PMD uses [Checkstyle](https://checkstyle.org/) to enforce a common code style.

See [pmd-checkstyle-config.xml](https://github.com/pmd/build-tools/blob/main/src/main/resources/net/sourceforge/pmd/pmd-checkstyle-config.xml) for the configuration and
[the eclipse configuration files](https://github.com/pmd/build-tools/tree/main/eclipse) that can
be imported into a fresh workspace.
PMD uses Rewrite.

## Add yourself as contributor

Expand Down
17 changes: 6 additions & 11 deletions pmd-ant/src/main/java/net/sourceforge/pmd/ant/CPDTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public class CPDTask extends Task {

private static final String TEXT_FORMAT = "text";
private static final String XML_FORMAT = "xml";
@Deprecated
private static final String XMLOLD_FORMAT = "xmlold";
@Deprecated private static final String XMLOLD_FORMAT = "xmlold";
private static final String CSV_FORMAT = "csv";

private String format = TEXT_FORMAT;
Expand All @@ -78,8 +77,7 @@ public class CPDTask extends Task {
private boolean ignoreIdentifiers;
private boolean ignoreAnnotations;
private boolean ignoreUsings;
@Deprecated
private boolean skipLexicalErrors;
@Deprecated private boolean skipLexicalErrors;
private boolean skipDuplicateFiles;
private boolean skipBlocks = true;
private String skipBlocksPattern;
Expand All @@ -88,8 +86,7 @@ public class CPDTask extends Task {
private List<FileSet> filesets = new ArrayList<>();
private boolean failOnError = true;

@Override
public void execute() throws BuildException {
@Override public void execute() throws BuildException {
ClassLoader oldClassloader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(CPDTask.class.getClassLoader());

Expand Down Expand Up @@ -243,8 +240,7 @@ public void setIgnoreUsings(boolean value) {
/**
* @deprecated Use {@link #setFailOnError(boolean)} instead.
*/
@Deprecated
public void setSkipLexicalErrors(boolean skipLexicalErrors) {
@Deprecated public void setSkipLexicalErrors(boolean skipLexicalErrors) {
this.skipLexicalErrors = skipLexicalErrors;
}

Expand Down Expand Up @@ -286,10 +282,9 @@ public void setFailOnError(boolean failOnError) {
}

public static class FormatAttribute extends EnumeratedAttribute {
private static final String[] FORMATS = new String[] { XML_FORMAT, TEXT_FORMAT, CSV_FORMAT, XMLOLD_FORMAT };
private static final String[] FORMATS = new String[]{XML_FORMAT, TEXT_FORMAT, CSV_FORMAT, XMLOLD_FORMAT};

@Override
public String[] getValues() {
@Override public String[] getValues() {
return FORMATS;
}
}
Expand Down
15 changes: 5 additions & 10 deletions pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ boolean isNoOutputSupplied() {
return toFile == null && !toConsole;
}

@Override
public String toString() {
@Override public String toString() {
return "file = " + toFile + "; renderer = " + type;
}

Expand Down Expand Up @@ -272,23 +271,19 @@ GlobalAnalysisListener newListener(Project project) throws IOException {
return new GlobalAnalysisListener() {
final GlobalAnalysisListener listener = renderer.newListener();

@Override
public ListenerInitializer initializer() {
@Override public ListenerInitializer initializer() {
return new ListenerInitializer() {
@Override
public void setFileNameRenderer(FileNameRenderer fileNameRenderer) {
@Override public void setFileNameRenderer(FileNameRenderer fileNameRenderer) {
renderer.setFileNameRenderer(fileNameRenderer);
}
};
}

@Override
public FileAnalysisListener startFileAnalysis(TextFile file) {
@Override public FileAnalysisListener startFileAnalysis(TextFile file) {
return listener.startFileAnalysis(file);
}

@Override
public void close() throws Exception {
@Override public void close() throws Exception {
listener.close();
if (!toConsole) {
writer.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
*/
@InternalApi
public final class InternalApiBridge {
private InternalApiBridge() {}
private InternalApiBridge() {
}

public static GlobalAnalysisListener newListener(Formatter formatter, Project project) throws IOException {
return formatter.newListener(project);
Expand Down
5 changes: 2 additions & 3 deletions pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public class PMDTask extends Task {
private boolean noCache;
private final Collection<RuleSetWrapper> nestedRules = new ArrayList<>();

@Override
public void execute() throws BuildException {
@Override public void execute() throws BuildException {
validate();

ClassLoader oldClassloader = Thread.currentThread().getContextClassLoader();
Expand Down Expand Up @@ -108,7 +107,7 @@ private void validate() throws BuildException {

private String getNestedRuleSetFiles() {
final StringBuilder sb = new StringBuilder();
for (Iterator<RuleSetWrapper> it = nestedRules.iterator(); it.hasNext();) {
for (Iterator<RuleSetWrapper> it = nestedRules.iterator(); it.hasNext(); ) {
RuleSetWrapper rs = it.next();
sb.append(rs.getFile());
if (it.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public void setName(String name) {
this.name = name;
}

@Override
public String toString() {
@Override public String toString() {
return "<sourceLanguage name=\"" + this.name + "\" version=\"" + this.version + "\" />";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private void doTask() {
ReportStats stats;
try (PmdAnalysis pmd = PmdAnalysis.create(configuration)) {
RuleSetLoader rulesetLoader =
pmd.newRuleSetLoader().loadResourcesWith(setupResourceLoader());
pmd.newRuleSetLoader().loadResourcesWith(setupResourceLoader());
pmd.addRuleSets(loadRuleSetsWithoutException(rulesetLoader, ruleSetPaths));

for (FileSet fileset : filesets) {
Expand All @@ -137,8 +137,7 @@ private void doTask() {
}


@SuppressWarnings("PMD.CloseResource")
ReportStatsListener reportStatsListener = new ReportStatsListener();
@SuppressWarnings("PMD.CloseResource") ReportStatsListener reportStatsListener = new ReportStatsListener();
pmd.addListener(getListener(reportStatsListener));

pmd.performAnalysis();
Expand Down Expand Up @@ -192,15 +191,13 @@ private List<String> expandRuleSetPaths(List<String> ruleSetPaths) {
private GlobalAnalysisListener makeLogListener() {
return new GlobalAnalysisListener() {

@Override
public FileAnalysisListener startFileAnalysis(TextFile dataSource) {
@Override public FileAnalysisListener startFileAnalysis(TextFile dataSource) {
String name = dataSource.getFileId().getUriString();
project.log("Processing file " + name, Project.MSG_VERBOSE);
return FileAnalysisListener.noop();
}

@Override
public void close() {
@Override public void close() {
// nothing to do
}
};
Expand All @@ -224,7 +221,7 @@ private ClassLoader setupResourceLoader() {
// and exist in multiple class loaders
final boolean parentFirst = true;
return new AntClassLoader(Thread.currentThread().getContextClassLoader(),
project, classpath, parentFirst);
project, classpath, parentFirst);
}

private void setupClassLoader() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@
import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration;

public final class Slf4jSimpleConfigurationForAnt {
private Slf4jSimpleConfigurationForAnt() { }
private Slf4jSimpleConfigurationForAnt() {
}

private static final Level DEFAULT_LEVEL = Level.INFO;

// Maps from ant's Project.MSG_* to org.slf4j.event.Level
private static final Level[] LOG_LEVELS = {
Level.ERROR, // Project.MSG_ERR=0
Level.WARN, // Project.MSG_WARN=1
Level.INFO, // Project.MSG_INFO=2
Level.DEBUG, // Project.MSG_VERBOSE=3
Level.TRACE, // Project.MSG_DEBUG=4
Level.ERROR, // Project.MSG_ERR=0
Level.WARN, // Project.MSG_WARN=1
Level.INFO, // Project.MSG_INFO=2
Level.DEBUG, // Project.MSG_VERBOSE=3
Level.TRACE, // Project.MSG_DEBUG=4
};

@SuppressWarnings("PMD.CloseResource")
public static Level reconfigureLoggingForAnt(Project antProject) {
@SuppressWarnings("PMD.CloseResource") public static Level reconfigureLoggingForAnt(Project antProject) {
if (!Slf4jSimpleConfiguration.isSimpleLogger()) {
// do nothing, not even set system properties, if not Simple Logger is in use
return DEFAULT_LEVEL;
Expand Down Expand Up @@ -83,13 +83,11 @@ private static final class SimpleLoggerToAntBridge extends PrintStream {
this.antProject = antProject;
}

@Override
public void println(String x) {
@Override public void println(String x) {
buffer.append(x).append(System.lineSeparator());
}

@Override
public void flush() {
@Override public void flush() {
String logLevel = determineLogLevel();
int antLogLevel = ANT_LOG_LEVELS.getOrDefault(logLevel, Project.MSG_INFO);
antProject.log(buffer.toString(), antLogLevel);
Expand Down Expand Up @@ -162,13 +160,13 @@ private static Level determineGradleLogLevel(Project project, BuildListener l) {

Object[] logLevels = gradleLogLevel.getEnumConstants();
// the log levels in gradle are declared in the order DEBUG, INFO, LIFECYCLE, WARN, QUIET, ERROR
Level[] mapping = new Level[] {
Level.TRACE, // DEBUG
Level.DEBUG, // INFO
Level.INFO, // LIFECYCLE
Level.WARN, // WARN
Level.ERROR, // QUIET
Level.ERROR, // ERROR
Level[] mapping = new Level[]{
Level.TRACE, // DEBUG
Level.DEBUG, // INFO
Level.INFO, // LIFECYCLE
Level.WARN, // WARN
Level.ERROR, // QUIET
Level.ERROR, // ERROR
};

for (int i = 0; i < Math.min(logLevels.length, mapping.length); i++) {
Expand Down
24 changes: 8 additions & 16 deletions pmd-ant/src/test/java/net/sourceforge/pmd/ant/AbstractAntTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ protected void configureProject(String filename) {
ProjectHelper.configureProject(project, antFile);
}

@AfterAll
static void resetLogging() {
@AfterAll static void resetLogging() {
Slf4jSimpleConfiguration.reconfigureDefaultLogLevel(null);
}

Expand Down Expand Up @@ -87,32 +86,25 @@ private AntBuildListener(int logLevel) {
}


@Override
public void buildStarted(BuildEvent event) {
@Override public void buildStarted(BuildEvent event) {
}

@Override
public void buildFinished(BuildEvent event) {
@Override public void buildFinished(BuildEvent event) {
}

@Override
public void targetStarted(BuildEvent event) {
@Override public void targetStarted(BuildEvent event) {
}

@Override
public void targetFinished(BuildEvent event) {
@Override public void targetFinished(BuildEvent event) {
}

@Override
public void taskStarted(BuildEvent event) {
@Override public void taskStarted(BuildEvent event) {
}

@Override
public void taskFinished(BuildEvent event) {
@Override public void taskFinished(BuildEvent event) {
}

@Override
public void messageLogged(BuildEvent event) {
@Override public void messageLogged(BuildEvent event) {
if (event.getPriority() > logLevel) {
return;
}
Expand Down
12 changes: 4 additions & 8 deletions pmd-ant/src/test/java/net/sourceforge/pmd/ant/CPDTaskTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,22 @@
*/
class CPDTaskTest extends AbstractAntTest {

@BeforeEach
void setUp() {
@BeforeEach void setUp() {
configureProject("src/test/resources/net/sourceforge/pmd/ant/xml/cpdtasktest.xml");
}

@Test
void testBasic() throws IOException {
@Test void testBasic() throws IOException {
executeTarget("testBasic");
assertReport("target/cpd.ant.tests");
}

@Test
void failOnErrorDefault() throws IOException {
@Test void failOnErrorDefault() throws IOException {
BuildException buildException = assertThrows(BuildException.class, () -> executeTarget("failOnErrorDefault"));
assertThat(buildException.getMessage(), containsString("There were 1 recovered errors during analysis."));
assertReport("target/cpd.ant.tests");
}

@Test
void failOnErrorIgnore() throws IOException {
@Test void failOnErrorIgnore() throws IOException {
executeTarget("failOnErrorIgnore");
assertReport("target/cpd.ant.tests");
assertThat(log.toString(), containsString("There were 1 recovered errors during analysis."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

class FormatterTest {

@Test
void testType() {
@Test void testType() {
Formatter f = new Formatter();
f.setType("xml");
assertTrue(f.createRenderer() instanceof XMLRenderer);
Expand All @@ -39,8 +38,7 @@ void testType() {
}
}

@Test
void testNull() {
@Test void testNull() {
Formatter f = new Formatter();
assertTrue(f.isNoOutputSupplied(), "Formatter toFile should start off null!");
f.setToFile(new File("foo"));
Expand Down
Loading
Loading