From 1b5f7e8baedb07e0ea2067adb384cddf3e100dea Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 13 May 2022 19:56:47 +0200 Subject: [PATCH 01/45] [core] Remember forced language per file Fixes #3970 --- docs/pages/release_notes.md | 2 ++ .../sourceforge/pmd/SourceCodeProcessor.java | 2 +- .../pmd/lang/LanguageVersionDiscoverer.java | 28 ++++++++++++--- .../pmd/lang/document/FileCollector.java | 4 ++- .../net/sourceforge/pmd/PmdAnalysisTest.java | 35 +++++++++++++++++++ .../pmd/lang/Dummy2LanguageModule.java | 4 +++ .../resources/sample-source/dummy/foo.txt | 1 + 7 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 pmd-core/src/test/resources/sample-source/dummy/foo.txt diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index c31a705241..1770a48672 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -16,6 +16,8 @@ This is a {{ site.pmd.release_type }} release. ### Fixed Issues +* core + * [#3970](https://github.com/pmd/pmd/issues/3970): \[core] FileCollector.addFile ignores language parameter * javascript * [#3948](https://github.com/pmd/pmd/issues/3948): \[js] Invalid operator error for method property in object literal diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/SourceCodeProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/SourceCodeProcessor.java index 7d1838c297..f52b0f2a2a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/SourceCodeProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/SourceCodeProcessor.java @@ -222,7 +222,7 @@ public class SourceCodeProcessor { ctx.setLanguageVersion(forceLanguage); } else { // otherwise determine by file extension - LanguageVersion languageVersion = configuration.getLanguageVersionOfFile(ctx.getSourceCodeFilename()); + LanguageVersion languageVersion = configuration.getLanguageVersionOfFile(ctx.getSourceCodeFile().toString()); ctx.setLanguageVersion(languageVersion); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java index 4e22b03a4f..27c72898e1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java @@ -5,6 +5,8 @@ package net.sourceforge.pmd.lang; import java.io.File; +import java.io.IOException; +import java.nio.file.Path; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -12,6 +14,7 @@ import java.util.Objects; import org.apache.commons.lang3.StringUtils; +import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.internal.util.AssertionUtil; /** @@ -24,6 +27,8 @@ public class LanguageVersionDiscoverer { private LanguageVersion forcedVersion; + private Map forcedVersionByFile = new HashMap<>(); + public LanguageVersionDiscoverer() { this(null); } @@ -97,10 +102,13 @@ public class LanguageVersionDiscoverer { * file. */ public LanguageVersion getDefaultLanguageVersionForFile(String fileName) { - List languages = getLanguagesForFile(fileName); - LanguageVersion languageVersion = null; - if (!languages.isEmpty()) { - languageVersion = getDefaultLanguageVersion(languages.get(0)); + LanguageVersion languageVersion = forcedVersionByFile.get(fileName); + + if (languageVersion == null) { + List languages = getLanguagesForFile(fileName); + if (!languages.isEmpty()) { + languageVersion = getDefaultLanguageVersion(languages.get(0)); + } } return languageVersion; } @@ -142,4 +150,16 @@ public class LanguageVersionDiscoverer { } + + @InternalApi + @Deprecated + public void recordLanguageVersionForFile(Path file, LanguageVersion languageVersion) { + String fileName; + try { + fileName = file.toRealPath().toString(); + } catch (IOException e) { + fileName = file.toAbsolutePath().toString(); + } + forcedVersionByFile.put(fileName, languageVersion); + } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java index 8db97175c3..51d84106c4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java @@ -155,8 +155,10 @@ public final class FileCollector implements AutoCloseable { reporter.error("Not a regular file {0}", file); return false; } - NioTextFile nioTextFile = new NioTextFile(file, charset, discoverer.getDefaultLanguageVersion(language), getDisplayName(file)); + LanguageVersion languageVersion = discoverer.getDefaultLanguageVersion(language); + NioTextFile nioTextFile = new NioTextFile(file, charset, languageVersion, getDisplayName(file)); addFileImpl(nioTextFile); + discoverer.recordLanguageVersionForFile(file, languageVersion); return true; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java index 4ec5555cf9..797f4e0569 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java @@ -14,10 +14,17 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import java.io.IOException; +import java.nio.file.Paths; +import java.util.List; +import org.junit.Assert; import org.junit.Test; import org.mockito.ArgumentMatchers; +import net.sourceforge.pmd.lang.Dummy2LanguageModule; +import net.sourceforge.pmd.lang.Language; +import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.renderers.Renderer; /** @@ -72,4 +79,32 @@ public class PmdAnalysisTest { } } + @Test + public void testFileWithSpecificLanguage() { + final Language language = Dummy2LanguageModule.getInstance(); + PMDConfiguration config = new PMDConfiguration(); + config.setIgnoreIncrementalAnalysis(true); + RuleSet ruleset = RuleSet.forSingleRule(new TestRule()); + + try (PmdAnalysis pmd = PmdAnalysis.create(config)) { + pmd.addRuleSet(ruleset); + pmd.files().addFile(Paths.get("src", "test", "resources", "sample-source", "dummy", "foo.txt"), language); + Report report = pmd.performAnalysisAndCollectReport(); + Assert.assertEquals(0, report.getProcessingErrors().size()); + Assert.assertEquals(1, report.getViolations().size()); + } + } + + public static class TestRule extends AbstractRule { + public TestRule() { + setLanguage(Dummy2LanguageModule.getInstance()); + setMessage("dummy 2 test rule"); + } + + @Override + public void apply(List nodes, RuleContext ctx) { + ctx.addViolation(nodes.get(0)); + } + } + } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/Dummy2LanguageModule.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/Dummy2LanguageModule.java index e5a8de77cb..9d71d22010 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/Dummy2LanguageModule.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/Dummy2LanguageModule.java @@ -16,4 +16,8 @@ public class Dummy2LanguageModule extends BaseLanguageModule { super(NAME, null, TERSE_NAME, "dummy2"); addVersion("1.0", new DummyLanguageModule.Handler(), true); } + + public static Language getInstance() { + return LanguageRegistry.getLanguage(NAME); + } } diff --git a/pmd-core/src/test/resources/sample-source/dummy/foo.txt b/pmd-core/src/test/resources/sample-source/dummy/foo.txt new file mode 100644 index 0000000000..adaad87177 --- /dev/null +++ b/pmd-core/src/test/resources/sample-source/dummy/foo.txt @@ -0,0 +1 @@ +A dummy file with file extension txt. From 815242a39af6d9e84eaaf638d5c62d73e1fd541e Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 29 Jul 2022 12:12:39 +0200 Subject: [PATCH 02/45] [core] Store languageVersion in DataSource in order to support FileCollector.addFile with language Fixes #3970 --- .../sourceforge/pmd/SourceCodeProcessor.java | 2 +- .../pmd/lang/LanguageVersionDiscoverer.java | 28 +++---------------- .../pmd/lang/document/FileCollector.java | 4 +-- .../pmd/lang/document/NioTextFile.java | 4 +-- .../pmd/lang/document/StringTextFile.java | 7 +++-- .../pmd/processor/PmdRunnable.java | 4 +++ .../internal/FileDataSourceWithLanguage.java | 26 +++++++++++++++++ .../internal/LanguageAwareDataSource.java | 13 +++++++++ .../ReaderDataSourceWithLanguage.java | 26 +++++++++++++++++ .../net/sourceforge/pmd/PmdAnalysisTest.java | 23 +++++++++++++++ .../pmd/lang/document/SimpleTestTextFile.java | 17 +++++++++++ 11 files changed, 121 insertions(+), 33 deletions(-) create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/FileDataSourceWithLanguage.java create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/LanguageAwareDataSource.java create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/ReaderDataSourceWithLanguage.java create mode 100644 pmd-core/src/test/java/net/sourceforge/pmd/lang/document/SimpleTestTextFile.java diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/SourceCodeProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/SourceCodeProcessor.java index f52b0f2a2a..7d1838c297 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/SourceCodeProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/SourceCodeProcessor.java @@ -222,7 +222,7 @@ public class SourceCodeProcessor { ctx.setLanguageVersion(forceLanguage); } else { // otherwise determine by file extension - LanguageVersion languageVersion = configuration.getLanguageVersionOfFile(ctx.getSourceCodeFile().toString()); + LanguageVersion languageVersion = configuration.getLanguageVersionOfFile(ctx.getSourceCodeFilename()); ctx.setLanguageVersion(languageVersion); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java index 27c72898e1..4e22b03a4f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java @@ -5,8 +5,6 @@ package net.sourceforge.pmd.lang; import java.io.File; -import java.io.IOException; -import java.nio.file.Path; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -14,7 +12,6 @@ import java.util.Objects; import org.apache.commons.lang3.StringUtils; -import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.internal.util.AssertionUtil; /** @@ -27,8 +24,6 @@ public class LanguageVersionDiscoverer { private LanguageVersion forcedVersion; - private Map forcedVersionByFile = new HashMap<>(); - public LanguageVersionDiscoverer() { this(null); } @@ -102,13 +97,10 @@ public class LanguageVersionDiscoverer { * file. */ public LanguageVersion getDefaultLanguageVersionForFile(String fileName) { - LanguageVersion languageVersion = forcedVersionByFile.get(fileName); - - if (languageVersion == null) { - List languages = getLanguagesForFile(fileName); - if (!languages.isEmpty()) { - languageVersion = getDefaultLanguageVersion(languages.get(0)); - } + List languages = getLanguagesForFile(fileName); + LanguageVersion languageVersion = null; + if (!languages.isEmpty()) { + languageVersion = getDefaultLanguageVersion(languages.get(0)); } return languageVersion; } @@ -150,16 +142,4 @@ public class LanguageVersionDiscoverer { } - - @InternalApi - @Deprecated - public void recordLanguageVersionForFile(Path file, LanguageVersion languageVersion) { - String fileName; - try { - fileName = file.toRealPath().toString(); - } catch (IOException e) { - fileName = file.toAbsolutePath().toString(); - } - forcedVersionByFile.put(fileName, languageVersion); - } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java index 51d84106c4..8db97175c3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java @@ -155,10 +155,8 @@ public final class FileCollector implements AutoCloseable { reporter.error("Not a regular file {0}", file); return false; } - LanguageVersion languageVersion = discoverer.getDefaultLanguageVersion(language); - NioTextFile nioTextFile = new NioTextFile(file, charset, languageVersion, getDisplayName(file)); + NioTextFile nioTextFile = new NioTextFile(file, charset, discoverer.getDefaultLanguageVersion(language), getDisplayName(file)); addFileImpl(nioTextFile); - discoverer.recordLanguageVersionForFile(file, languageVersion); return true; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java index c7d77e1de8..8fc154967a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java @@ -17,7 +17,7 @@ import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.util.IOUtil; import net.sourceforge.pmd.util.datasource.DataSource; -import net.sourceforge.pmd.util.datasource.FileDataSource; +import net.sourceforge.pmd.util.datasource.internal.FileDataSourceWithLanguage; /** * A {@link TextFile} backed by a file in some {@link FileSystem}. @@ -73,7 +73,7 @@ class NioTextFile implements TextFile { @Override public DataSource toDataSourceCompat() { - return new FileDataSource(path.toFile()); + return new FileDataSourceWithLanguage(path.toFile(), languageVersion); } @Override diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java index 598823e555..db2f537eee 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java @@ -11,7 +11,7 @@ import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.util.datasource.DataSource; -import net.sourceforge.pmd.util.datasource.ReaderDataSource; +import net.sourceforge.pmd.util.datasource.internal.ReaderDataSourceWithLanguage; /** * Read-only view on a string. @@ -64,9 +64,10 @@ class StringTextFile implements TextFile { @Override public DataSource toDataSourceCompat() { - return new ReaderDataSource( + return new ReaderDataSourceWithLanguage( new StringReader(content), - pathId + pathId, + languageVersion ); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java b/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java index da91fbd95a..e4b1d75de6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/processor/PmdRunnable.java @@ -21,6 +21,7 @@ import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.benchmark.TimeTracker; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.util.datasource.DataSource; +import net.sourceforge.pmd.util.datasource.internal.LanguageAwareDataSource; /** * @@ -82,6 +83,9 @@ public class PmdRunnable implements Callable { try (InputStream stream = new BufferedInputStream(dataSource.getInputStream())) { tc.ruleContext.setLanguageVersion(null); + if (dataSource instanceof LanguageAwareDataSource) { + tc.ruleContext.setLanguageVersion(((LanguageAwareDataSource) dataSource).getLanguageVersion()); + } sourceCodeProcessor.processSourceCode(stream, tc.ruleSets, tc.ruleContext); } catch (PMDException pmde) { addError(report, pmde, "Error while processing file: " + fileName); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/FileDataSourceWithLanguage.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/FileDataSourceWithLanguage.java new file mode 100644 index 0000000000..7ca0e1c8a4 --- /dev/null +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/FileDataSourceWithLanguage.java @@ -0,0 +1,26 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.util.datasource.internal; + +import java.io.File; + +import net.sourceforge.pmd.annotation.InternalApi; +import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.util.datasource.FileDataSource; + +@InternalApi +public class FileDataSourceWithLanguage extends FileDataSource implements LanguageAwareDataSource { + private final LanguageVersion languageVersion; + + public FileDataSourceWithLanguage(File file, LanguageVersion languageVersion) { + super(file); + this.languageVersion = languageVersion; + } + + @Override + public LanguageVersion getLanguageVersion() { + return languageVersion; + } +} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/LanguageAwareDataSource.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/LanguageAwareDataSource.java new file mode 100644 index 0000000000..69dbf67059 --- /dev/null +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/LanguageAwareDataSource.java @@ -0,0 +1,13 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.util.datasource.internal; + +import net.sourceforge.pmd.annotation.InternalApi; +import net.sourceforge.pmd.lang.LanguageVersion; + +@InternalApi +public interface LanguageAwareDataSource { + LanguageVersion getLanguageVersion(); +} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/ReaderDataSourceWithLanguage.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/ReaderDataSourceWithLanguage.java new file mode 100644 index 0000000000..e96429e65d --- /dev/null +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/ReaderDataSourceWithLanguage.java @@ -0,0 +1,26 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.util.datasource.internal; + +import java.io.Reader; + +import net.sourceforge.pmd.annotation.InternalApi; +import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.util.datasource.ReaderDataSource; + +@InternalApi +public class ReaderDataSourceWithLanguage extends ReaderDataSource implements LanguageAwareDataSource { + private final LanguageVersion languageVersion; + + public ReaderDataSourceWithLanguage(Reader reader, String dataSourceName, LanguageVersion languageVersion) { + super(reader, dataSourceName); + this.languageVersion = languageVersion; + } + + @Override + public LanguageVersion getLanguageVersion() { + return languageVersion; + } +} diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java index 797f4e0569..a1f2f0f156 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java @@ -24,6 +24,7 @@ import org.mockito.ArgumentMatchers; import net.sourceforge.pmd.lang.Dummy2LanguageModule; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.document.SimpleTestTextFile; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.renderers.Renderer; @@ -90,6 +91,28 @@ public class PmdAnalysisTest { pmd.addRuleSet(ruleset); pmd.files().addFile(Paths.get("src", "test", "resources", "sample-source", "dummy", "foo.txt"), language); Report report = pmd.performAnalysisAndCollectReport(); + for (Report.ProcessingError error : report.getProcessingErrors()) { + System.out.println("error = " + error.getMsg() + ": " + error.getDetail()); + } + Assert.assertEquals(0, report.getProcessingErrors().size()); + Assert.assertEquals(1, report.getViolations().size()); + } + } + + @Test + public void testTextFileWithSpecificLanguage() { + final Language language = Dummy2LanguageModule.getInstance(); + PMDConfiguration config = new PMDConfiguration(); + config.setIgnoreIncrementalAnalysis(true); + RuleSet ruleset = RuleSet.forSingleRule(new TestRule()); + + try (PmdAnalysis pmd = PmdAnalysis.create(config)) { + pmd.addRuleSet(ruleset); + pmd.files().addFile(new SimpleTestTextFile("test content foo", "foo.txt", "foo.txt", language.getDefaultVersion())); + Report report = pmd.performAnalysisAndCollectReport(); + for (Report.ProcessingError error : report.getProcessingErrors()) { + System.out.println("error = " + error.getMsg() + ": " + error.getDetail()); + } Assert.assertEquals(0, report.getProcessingErrors().size()); Assert.assertEquals(1, report.getViolations().size()); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/SimpleTestTextFile.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/SimpleTestTextFile.java new file mode 100644 index 0000000000..6f66347142 --- /dev/null +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/SimpleTestTextFile.java @@ -0,0 +1,17 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.document; + +import net.sourceforge.pmd.lang.LanguageVersion; + +/** + * Makes {@link StringTextFile} publicly available for unit tests. + */ +public class SimpleTestTextFile extends StringTextFile { + + public SimpleTestTextFile(String content, String pathId, String displayName, LanguageVersion languageVersion) { + super(content, pathId, displayName, languageVersion); + } +} From ca87fe51e37676d613f68c1a9d9d7bd222dbee69 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 29 Jul 2022 15:24:30 +0200 Subject: [PATCH 03/45] Fixups from review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: ClΓ©ment Fournier --- .../pmd/lang/document/NioTextFile.java | 5 +-- .../pmd/lang/document/StringTextFile.java | 7 ++-- .../internal/FileDataSourceWithLanguage.java | 26 --------------- .../internal/LanguageAwareDataSource.java | 33 +++++++++++++++++-- .../ReaderDataSourceWithLanguage.java | 26 --------------- 5 files changed, 38 insertions(+), 59 deletions(-) delete mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/FileDataSourceWithLanguage.java delete mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/ReaderDataSourceWithLanguage.java diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java index 8fc154967a..16ab46f93f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java @@ -17,7 +17,8 @@ import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.util.IOUtil; import net.sourceforge.pmd.util.datasource.DataSource; -import net.sourceforge.pmd.util.datasource.internal.FileDataSourceWithLanguage; +import net.sourceforge.pmd.util.datasource.FileDataSource; +import net.sourceforge.pmd.util.datasource.internal.LanguageAwareDataSource; /** * A {@link TextFile} backed by a file in some {@link FileSystem}. @@ -73,7 +74,7 @@ class NioTextFile implements TextFile { @Override public DataSource toDataSourceCompat() { - return new FileDataSourceWithLanguage(path.toFile(), languageVersion); + return new LanguageAwareDataSource(new FileDataSource(path.toFile()), languageVersion); } @Override diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java index db2f537eee..c4d286d895 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java @@ -11,7 +11,8 @@ import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.util.datasource.DataSource; -import net.sourceforge.pmd.util.datasource.internal.ReaderDataSourceWithLanguage; +import net.sourceforge.pmd.util.datasource.ReaderDataSource; +import net.sourceforge.pmd.util.datasource.internal.LanguageAwareDataSource; /** * Read-only view on a string. @@ -64,9 +65,9 @@ class StringTextFile implements TextFile { @Override public DataSource toDataSourceCompat() { - return new ReaderDataSourceWithLanguage( + return new LanguageAwareDataSource(new ReaderDataSource( new StringReader(content), - pathId, + pathId), languageVersion ); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/FileDataSourceWithLanguage.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/FileDataSourceWithLanguage.java deleted file mode 100644 index 7ca0e1c8a4..0000000000 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/FileDataSourceWithLanguage.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -package net.sourceforge.pmd.util.datasource.internal; - -import java.io.File; - -import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.lang.LanguageVersion; -import net.sourceforge.pmd.util.datasource.FileDataSource; - -@InternalApi -public class FileDataSourceWithLanguage extends FileDataSource implements LanguageAwareDataSource { - private final LanguageVersion languageVersion; - - public FileDataSourceWithLanguage(File file, LanguageVersion languageVersion) { - super(file); - this.languageVersion = languageVersion; - } - - @Override - public LanguageVersion getLanguageVersion() { - return languageVersion; - } -} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/LanguageAwareDataSource.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/LanguageAwareDataSource.java index 69dbf67059..407001e102 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/LanguageAwareDataSource.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/LanguageAwareDataSource.java @@ -4,10 +4,39 @@ package net.sourceforge.pmd.util.datasource.internal; +import java.io.IOException; +import java.io.InputStream; + import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.util.datasource.DataSource; @InternalApi -public interface LanguageAwareDataSource { - LanguageVersion getLanguageVersion(); +public class LanguageAwareDataSource implements DataSource { + private final DataSource base; // delegate DataSource methods to this + private final LanguageVersion version; + + public LanguageAwareDataSource(DataSource base, LanguageVersion version) { + this.base = base; + this.version = version; + } + + public LanguageVersion getLanguageVersion() { + return version; + } + + @Override + public InputStream getInputStream() throws IOException { + return base.getInputStream(); + } + + @Override + public String getNiceFileName(boolean shortNames, String inputFileName) { + return base.getNiceFileName(shortNames, inputFileName); + } + + @Override + public void close() throws IOException { + base.close(); + } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/ReaderDataSourceWithLanguage.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/ReaderDataSourceWithLanguage.java deleted file mode 100644 index e96429e65d..0000000000 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/internal/ReaderDataSourceWithLanguage.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -package net.sourceforge.pmd.util.datasource.internal; - -import java.io.Reader; - -import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.lang.LanguageVersion; -import net.sourceforge.pmd.util.datasource.ReaderDataSource; - -@InternalApi -public class ReaderDataSourceWithLanguage extends ReaderDataSource implements LanguageAwareDataSource { - private final LanguageVersion languageVersion; - - public ReaderDataSourceWithLanguage(Reader reader, String dataSourceName, LanguageVersion languageVersion) { - super(reader, dataSourceName); - this.languageVersion = languageVersion; - } - - @Override - public LanguageVersion getLanguageVersion() { - return languageVersion; - } -} From dedb263fe781ad3ccdd5d91af705079feb9e6fd0 Mon Sep 17 00:00:00 2001 From: Simon Abykov Date: Fri, 5 Aug 2022 11:34:01 +0100 Subject: [PATCH 04/45] [java] UnnecessaryImport false positive for on-demand imports of nested classes Fixes #4082 --- .../rule/codestyle/UnnecessaryImportRule.java | 28 +++++++++++++++++++ .../unnecessaryimport/package2/C.java | 4 +++ .../rule/codestyle/xml/UnnecessaryImport.xml | 28 +++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryImportRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryImportRule.java index 3359462489..28ff548dbc 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryImportRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryImportRule.java @@ -210,6 +210,20 @@ public class UnnecessaryImportRule extends AbstractJavaRule { } } + // check on-demand imports for inner classes + it = imports.iterator(); + while (it.hasNext()) { + ImportWrapper i = it.next(); + if (!i.isStaticOnDemand() && i.isOnDemand()) { + String possibleClassName = i.getFullName() + "$" + candName; + Class possibleClazz = referenceNode.getRoot().getClassTypeResolver() + .loadClassOrNull(possibleClassName); + if (possibleClazz != null) { + it.remove(); + } + } + } + // check static on-demand imports it = imports.iterator(); while (it.hasNext()) { @@ -220,6 +234,20 @@ public class UnnecessaryImportRule extends AbstractJavaRule { } } + // check static on-demand imports for static inner classes + it = imports.iterator(); + while (it.hasNext()) { + ImportWrapper i = it.next(); + if (i.isStaticOnDemand()) { + String possibleClassName = i.getFullName() + "$" + candName; + Class possibleClazz = referenceNode.getRoot().getClassTypeResolver() + .loadClassOrNull(possibleClassName); + if (possibleClazz != null) { + it.remove(); + } + } + } + if (referenceNode instanceof TypeNode && ((TypeNode) referenceNode).getType() != null) { Class c = ((TypeNode) referenceNode).getType(); if (c.getPackage() != null) { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/package2/C.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/package2/C.java index 19710af874..43be196748 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/package2/C.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/package2/C.java @@ -7,5 +7,9 @@ package net.sourceforge.pmd.lang.java.rule.codestyle.unnecessaryimport.package2; public class C { private C() { } + public class IC {} + + public static class ISC {} + public static final String V = ""; } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryImport.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryImport.xml index c1c8fb2e30..d18dbdd54e 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryImport.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/UnnecessaryImport.xml @@ -916,6 +916,34 @@ public class U { ]]> + + [java] UnnecessaryImport false positive for on-demand imports of non-static nested classes + 0 + + + + + [java] UnnecessaryImport false positive for static on-demand imports of static nested classes + 0 + + + Necessary imports for @snippet tags introduced with JEP 413 in Java 18 0 From b63368fe8d962d3dda08e92a7628399c06f80cad Mon Sep 17 00:00:00 2001 From: Simon Abykov Date: Fri, 5 Aug 2022 13:43:51 +0100 Subject: [PATCH 05/45] Fixed checkstyle errors --- .../java/rule/codestyle/unnecessaryimport/package2/C.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/package2/C.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/package2/C.java index 43be196748..92104cbbb1 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/package2/C.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/unnecessaryimport/package2/C.java @@ -7,9 +7,9 @@ package net.sourceforge.pmd.lang.java.rule.codestyle.unnecessaryimport.package2; public class C { private C() { } - public class IC {} + public class IC { } - public static class ISC {} + public static class ISC { } public static final String V = ""; } From 8a41e13bdbaa163727f6402484727b63717d94c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Wed, 10 Aug 2022 00:18:21 +0200 Subject: [PATCH 06/45] test-schema: fix wrong warning message --- .../net/sourceforge/pmd/test/schema/BaseTestParserImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/BaseTestParserImpl.java b/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/BaseTestParserImpl.java index 192b11ba4a..761fa508bf 100644 --- a/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/BaseTestParserImpl.java +++ b/pmd-test-schema/src/main/java/net/sourceforge/pmd/test/schema/BaseTestParserImpl.java @@ -96,7 +96,7 @@ class BaseTestParserImpl { parseBoolAttribute(testCode, "useAuxClasspath", true, err, "Attribute 'useAuxClasspath' is deprecated and ignored, assumed true"); boolean disabled = parseBoolAttribute(testCode, "disabled", false, err, null) - | !parseBoolAttribute(testCode, "regressionTest", true, err, "Attribute ''regressionTest'' is deprecated, use ''ignored'' with inverted value"); + | !parseBoolAttribute(testCode, "regressionTest", true, err, "Attribute ''regressionTest'' is deprecated, use ''disabled'' with inverted value"); descriptor.setDisabled(disabled); From 2977bd8764ef01152e9f74b2786ee43b937b5379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Wed, 10 Aug 2022 17:26:20 +0200 Subject: [PATCH 07/45] test-schema: fix tests --- .../net/sourceforge/pmd/test/schema/TestSchemaParserTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-test-schema/src/test/java/net/sourceforge/pmd/test/schema/TestSchemaParserTest.java b/pmd-test-schema/src/test/java/net/sourceforge/pmd/test/schema/TestSchemaParserTest.java index 1b38d243f6..286b61cd8e 100644 --- a/pmd-test-schema/src/test/java/net/sourceforge/pmd/test/schema/TestSchemaParserTest.java +++ b/pmd-test-schema/src/test/java/net/sourceforge/pmd/test/schema/TestSchemaParserTest.java @@ -82,7 +82,7 @@ public class TestSchemaParserTest { assertEquals(1, parsed.getTests().size()); MatcherAssert.assertThat(errStreamCaptor.getLog(), containsString(" 6| \n" - + " ^^^^^^^^^^^^^^ Attribute 'regressionTest' is deprecated, use 'ignored' with inverted value\n")); + + " ^^^^^^^^^^^^^^ Attribute 'regressionTest' is deprecated, use 'disabled' with inverted value\n")); } @Test From ea455fa356ff0805ff86527762c990869ad28294 Mon Sep 17 00:00:00 2001 From: Edward Klimoshenko Date: Tue, 19 Jul 2022 04:30:05 +0000 Subject: [PATCH 08/45] Remove Jorje leaks outside `ast` package Operators - Create operator enums to wrap internal Jorje operators. - Create getters returning new operator enums in operator-expression nodes. Deprecate old getters. - Refactor metrics classes to use new operator enums. Tests - Remove references to internal Jorje nodes. --- .../apex/ast/ASTAssignmentExpression.java | 5 ++ .../lang/apex/ast/ASTBinaryExpression.java | 5 ++ .../lang/apex/ast/ASTBooleanExpression.java | 5 +- .../lang/apex/ast/ASTPostfixExpression.java | 6 +- .../lang/apex/ast/ASTPrefixExpression.java | 6 +- .../pmd/lang/apex/ast/ApexRootNode.java | 4 +- .../pmd/lang/apex/ast/AssignmentOperator.java | 67 +++++++++++++++++++ .../pmd/lang/apex/ast/BinaryOperator.java | 64 ++++++++++++++++++ .../pmd/lang/apex/ast/BooleanOperator.java | 67 +++++++++++++++++++ .../pmd/lang/apex/ast/PostfixOperator.java | 40 +++++++++++ .../pmd/lang/apex/ast/PrefixOperator.java | 52 ++++++++++++++ .../lang/apex/metrics/impl/CycloMetric.java | 7 +- .../visitors/CognitiveComplexityVisitor.java | 17 +++-- .../pmd/lang/apex/ast/ASTFieldTest.java | 8 +-- .../pmd/lang/apex/ast/ASTMethodTest.java | 4 +- .../ASTNewKeyValueObjectExpressionTest.java | 4 +- .../lang/apex/ast/ASTSoqlExpressionTest.java | 4 +- .../lang/apex/ast/ASTSwitchStatementTest.java | 4 +- .../ASTTryCatchFinallyBlockStatementTest.java | 8 +-- .../pmd/lang/apex/ast/ASTUserClassTest.java | 6 +- .../pmd/lang/apex/ast/ASTUserEnumTest.java | 4 +- .../lang/apex/ast/ASTUserInterfaceTest.java | 6 +- .../pmd/lang/apex/ast/ApexParserTest.java | 22 +++--- .../pmd/lang/apex/ast/ApexParserTestBase.java | 6 +- .../lang/apex/ast/ApexQualifiedNameTest.java | 17 ++--- .../apex/metrics/ApexProjectMirrorTest.java | 6 +- .../multifile/ApexMultifileVisitorTest.java | 4 +- .../lang/apex/rule/AbstractApexRuleTest.java | 4 +- 28 files changed, 366 insertions(+), 86 deletions(-) create mode 100644 pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AssignmentOperator.java create mode 100644 pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BinaryOperator.java create mode 100644 pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BooleanOperator.java create mode 100644 pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PostfixOperator.java create mode 100644 pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PrefixOperator.java diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAssignmentExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAssignmentExpression.java index 64db7c1687..73b3b10740 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAssignmentExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAssignmentExpression.java @@ -22,7 +22,12 @@ public class ASTAssignmentExpression extends AbstractApexNode { return visitor.visit(this, data); } + @Deprecated public BinaryOp getOperator() { return node.getOp(); } + + public BinaryOperator getOp() { + return BinaryOperator.valueOf(node.getOp()); + } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBooleanExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBooleanExpression.java index c6ab8b415e..f258a389c8 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBooleanExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBooleanExpression.java @@ -24,9 +24,12 @@ public class ASTBooleanExpression extends AbstractApexNode { return visitor.visit(this, data); } - + @Deprecated public BooleanOp getOperator() { return this.node.getOp(); } + public BooleanOperator getOp() { + return BooleanOperator.valueOf(this.node.getOp()); + } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPostfixExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPostfixExpression.java index 5d3c288fbc..8ef0b8770b 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPostfixExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPostfixExpression.java @@ -24,8 +24,12 @@ public class ASTPostfixExpression extends AbstractApexNode { return visitor.visit(this, data); } - + @Deprecated public PostfixOp getOperator() { return node.getOp(); } + + public PostfixOperator getOp() { + return PostfixOperator.valueOf(node.getOp()); + } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPrefixExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPrefixExpression.java index c79fa8214f..bc8c4fdf29 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPrefixExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPrefixExpression.java @@ -22,8 +22,12 @@ public class ASTPrefixExpression extends AbstractApexNode { return visitor.visit(this, data); } - + @Deprecated public PrefixOp getOperator() { return node.getOp(); } + + public PrefixOperator getOp() { + return PrefixOperator.valueOf(node.getOp()); + } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexRootNode.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexRootNode.java index a14c241b44..916e7cd3e5 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexRootNode.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexRootNode.java @@ -8,12 +8,12 @@ import net.sourceforge.pmd.annotation.InternalApi; import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.ast.SourceCodePositioner; -import apex.jorje.semantic.ast.AstNode; +import apex.jorje.semantic.ast.compilation.Compilation; import apex.jorje.services.Version; @Deprecated @InternalApi -public abstract class ApexRootNode extends AbstractApexNode implements RootNode { +public abstract class ApexRootNode extends AbstractApexNode implements RootNode { @Deprecated @InternalApi public ApexRootNode(T node) { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AssignmentOperator.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AssignmentOperator.java new file mode 100644 index 0000000000..6ee2bf6910 --- /dev/null +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AssignmentOperator.java @@ -0,0 +1,67 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.apex.ast; + +import apex.jorje.data.ast.AssignmentOp; + +/** + * Apex assignment operator + */ +public enum AssignmentOperator { + EQUALS("="), + ADDITION_EQUALS("+="), + SUBTRACTION_EQUALS("-="), + MULTIPLICATION_EQUALS("*="), + DIVISION_EQUALS("/="), + LEFT_SHIFT_EQUALS("<<="), + RIGHT_SHIFT_SIGNED_EQUALS(">>="), + RIGHT_SHIFT_UNSIGNED_EQUALS(">>>="), + BITWISE_AND_EQUALS("&="), + BITWISE_OR_EQUALS("|="), + BITWISE_XOR_EQUALS("^="); + + private final String symbol; + + AssignmentOperator(String symbol) { + this.symbol = symbol; + } + + @Override + public String toString() { + return this.symbol; + } + + /** + * Returns a {@link AssignmentOperator} corresponding to the given {@link AssignmentOp}. + */ + public static AssignmentOperator valueOf(AssignmentOp op) { + switch (op) { + case EQUALS: + return EQUALS; + case ADDITION_EQUALS: + return ADDITION_EQUALS; + case SUBTRACTION_EQUALS: + return SUBTRACTION_EQUALS; + case MULTIPLICATION_EQUALS: + return MULTIPLICATION_EQUALS; + case DIVISION_EQUALS: + return DIVISION_EQUALS; + case LEFT_SHIFT_EQUALS: + return LEFT_SHIFT_EQUALS; + case RIGHT_SHIFT_EQUALS: + return RIGHT_SHIFT_SIGNED_EQUALS; + case UNSIGNED_RIGHT_SHIFT_EQUALS: + return RIGHT_SHIFT_UNSIGNED_EQUALS; + case AND_EQUALS: + return BITWISE_AND_EQUALS; + case OR_EQUALS: + return BITWISE_OR_EQUALS; + case XOR_EQUALS: + return BITWISE_XOR_EQUALS; + default: + throw new IllegalArgumentException("Invalid assignment operator " + op); + } + } +} diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BinaryOperator.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BinaryOperator.java new file mode 100644 index 0000000000..ea18dce06b --- /dev/null +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BinaryOperator.java @@ -0,0 +1,64 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.apex.ast; + +import apex.jorje.data.ast.BinaryOp; + +/** + * Apex binary operator + */ +public enum BinaryOperator { + ADDITION("+"), + SUBTRACTION("-"), + MULTIPLICATION("*"), + DIVISION("/"), + LEFT_SHIFT("<<"), + RIGHT_SHIFT_SIGNED(">>"), + RIGHT_SHIFT_UNSIGNED(">>>"), + BITWISE_AND("&"), + BITWISE_OR("|"), + BITWISE_XOR("^"); + + private final String symbol; + + BinaryOperator(String symbol) { + this.symbol = symbol; + } + + @Override + public String toString() { + return this.symbol; + } + + /** + * Returns a {@link BinaryOperator} corresponding to the given {@link BinaryOp}. + */ + public static BinaryOperator valueOf(BinaryOp op) { + switch (op) { + case ADDITION: + return ADDITION; + case SUBTRACTION: + return SUBTRACTION; + case MULTIPLICATION: + return MULTIPLICATION; + case DIVISION: + return DIVISION; + case LEFT_SHIFT: + return LEFT_SHIFT; + case RIGHT_SHIFT: + return RIGHT_SHIFT_SIGNED; + case UNSIGNED_RIGHT_SHIFT: + return RIGHT_SHIFT_UNSIGNED; + case AND: + return BITWISE_AND; + case OR: + return BITWISE_OR; + case XOR: + return BITWISE_XOR; + default: + throw new IllegalArgumentException("Invalid binary operator " + op); + } + } +} diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BooleanOperator.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BooleanOperator.java new file mode 100644 index 0000000000..e463eb2790 --- /dev/null +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BooleanOperator.java @@ -0,0 +1,67 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.apex.ast; + +import apex.jorje.data.ast.BooleanOp; + +/** + * Apex boolean operator + */ +public enum BooleanOperator { + EQUAL("=="), + NOT_EQUAL("!="), + ALT_NOT_EQUAL("<>"), + EXACTLY_EQUAL("==="), + EXACTLY_NOT_EQUAL("!=="), + LESS_THAN("<"), + GREATER_THAN(">"), + LESS_THAN_OR_EQUAL("<="), + GREATER_THAN_OR_EQUAL(">="), + LOGICAL_AND("&&"), + LOGICAL_OR("||"); + + private final String symbol; + + BooleanOperator(String symbol) { + this.symbol = symbol; + } + + @Override + public String toString() { + return this.symbol; + } + + /** + * Returns a {@link BooleanOperator} corresponding to the given {@link BooleanOp}. + */ + public static BooleanOperator valueOf(BooleanOp op) { + switch (op) { + case DOUBLE_EQUAL: + return EQUAL; + case NOT_EQUAL: + return NOT_EQUAL; + case ALT_NOT_EQUAL: + return ALT_NOT_EQUAL; + case TRIPLE_EQUAL: + return EXACTLY_EQUAL; + case NOT_TRIPLE_EQUAL: + return EXACTLY_NOT_EQUAL; + case LESS_THAN: + return LESS_THAN; + case GREATER_THAN: + return GREATER_THAN; + case LESS_THAN_EQUAL: + return LESS_THAN_OR_EQUAL; + case GREATER_THAN_EQUAL: + return GREATER_THAN_OR_EQUAL; + case AND: + return LOGICAL_AND; + case OR: + return LOGICAL_OR; + default: + throw new IllegalArgumentException("Invalid boolean operator " + op); + } + } +} diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PostfixOperator.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PostfixOperator.java new file mode 100644 index 0000000000..5aa5a22756 --- /dev/null +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PostfixOperator.java @@ -0,0 +1,40 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.apex.ast; + +import apex.jorje.data.ast.PostfixOp; + +/** + * Apex postfix operator + */ +public enum PostfixOperator { + INCREMENT("++"), + DECREMENT("--"); + + private final String symbol; + + PostfixOperator(String symbol) { + this.symbol = symbol; + } + + @Override + public String toString() { + return this.symbol; + } + + /** + * Returns a {@link PostfixOperator} corresponding to the given {@link PostfixOp}. + */ + public static PostfixOperator valueOf(PostfixOp op) { + switch (op) { + case INC: + return INCREMENT; + case DEC: + return DECREMENT; + default: + throw new IllegalArgumentException("Invalid postfix operator " + op); + } + } +} diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PrefixOperator.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PrefixOperator.java new file mode 100644 index 0000000000..03c3b8379a --- /dev/null +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PrefixOperator.java @@ -0,0 +1,52 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.apex.ast; + +import apex.jorje.data.ast.PrefixOp; + +/** + * Apex prefix operator + */ +public enum PrefixOperator { + POSITIVE("+"), + NEGATIVE("-"), + LOGICAL_NOT("!"), + BITWISE_NOT("~"), + INCREMENT("++"), + DECREMENT("--"); + + private final String symbol; + + PrefixOperator(String symbol) { + this.symbol = symbol; + } + + @Override + public String toString() { + return this.symbol; + } + + /** + * Returns a {@link PrefixOperator} corresponding to the given {@link PrefixOp}. + */ + public static PrefixOperator valueOf(PrefixOp op) { + switch (op) { + case POSITIVE: + return POSITIVE; + case NEGATIVE: + return NEGATIVE; + case NOT: + return LOGICAL_NOT; + case BITWISE_COMPLEMENT: + return BITWISE_NOT; + case INC: + return INCREMENT; + case DEC: + return DECREMENT; + default: + throw new IllegalArgumentException("Invalid prefix operator " + op); + } + } +} diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/CycloMetric.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/CycloMetric.java index 6e60120f87..7c4f87de4a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/CycloMetric.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/CycloMetric.java @@ -12,11 +12,10 @@ import org.apache.commons.lang3.mutable.MutableInt; import net.sourceforge.pmd.lang.apex.ast.ASTBooleanExpression; import net.sourceforge.pmd.lang.apex.ast.ASTMethod; import net.sourceforge.pmd.lang.apex.ast.ASTStandardCondition; +import net.sourceforge.pmd.lang.apex.ast.BooleanOperator; import net.sourceforge.pmd.lang.apex.metrics.impl.visitors.StandardCycloVisitor; import net.sourceforge.pmd.lang.metrics.MetricOptions; -import apex.jorje.data.ast.BooleanOp; - /** * See the doc for the Java metric. * @@ -44,8 +43,8 @@ public class CycloMetric extends AbstractApexOperationMetric { int complexity = 0; for (ASTBooleanExpression sub : subs) { - BooleanOp op = sub.getOperator(); - if (op != null && (op == BooleanOp.AND || op == BooleanOp.OR)) { + BooleanOperator op = sub.getOp(); + if (op == BooleanOperator.LOGICAL_AND || op == BooleanOperator.LOGICAL_OR) { complexity++; } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/visitors/CognitiveComplexityVisitor.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/visitors/CognitiveComplexityVisitor.java index 0fe1062d34..51b19aa9b1 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/visitors/CognitiveComplexityVisitor.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/impl/visitors/CognitiveComplexityVisitor.java @@ -19,9 +19,8 @@ import net.sourceforge.pmd.lang.apex.ast.ASTTernaryExpression; import net.sourceforge.pmd.lang.apex.ast.ASTWhileLoopStatement; import net.sourceforge.pmd.lang.apex.ast.ApexNode; import net.sourceforge.pmd.lang.apex.ast.ApexParserVisitorAdapter; - -import apex.jorje.data.ast.BooleanOp; -import apex.jorje.data.ast.PrefixOp; +import net.sourceforge.pmd.lang.apex.ast.BooleanOperator; +import net.sourceforge.pmd.lang.apex.ast.PrefixOperator; /** * @author Gwilym Kuiper @@ -31,7 +30,7 @@ public class CognitiveComplexityVisitor extends ApexParserVisitorAdapter { private int complexity = 0; private int nestingLevel = 0; - private BooleanOp currentBooleanOperation = null; + private BooleanOperator currentBooleanOperation = null; private String methodName = null; public double getComplexity() { @@ -53,7 +52,7 @@ public class CognitiveComplexityVisitor extends ApexParserVisitorAdapter { complexity++; } - void booleanOperation(BooleanOp op) { + void booleanOperation(BooleanOperator op) { if (currentBooleanOperation != op) { if (op != null) { fundamentalComplexity(); @@ -177,8 +176,8 @@ public class CognitiveComplexityVisitor extends ApexParserVisitorAdapter { public Object visit(ASTBooleanExpression node, Object data) { State state = (State) data; - BooleanOp op = node.getOperator(); - if (op == BooleanOp.AND || op == BooleanOp.OR) { + BooleanOperator op = node.getOp(); + if (op == BooleanOperator.LOGICAL_AND || op == BooleanOperator.LOGICAL_OR) { state.booleanOperation(op); } @@ -189,8 +188,8 @@ public class CognitiveComplexityVisitor extends ApexParserVisitorAdapter { public Object visit(ASTPrefixExpression node, Object data) { State state = (State) data; - PrefixOp op = node.getOperator(); - if (op == PrefixOp.NOT) { + PrefixOperator op = node.getOp(); + if (op == PrefixOperator.LOGICAL_NOT) { state.booleanOperation(null); } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldTest.java index b7cda1793c..1e8c2e1e44 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldTest.java @@ -7,13 +7,11 @@ package net.sourceforge.pmd.lang.apex.ast; import org.junit.Assert; import org.junit.Test; -import apex.jorje.semantic.ast.compilation.Compilation; - public class ASTFieldTest extends ApexParserTestBase { @Test public void testGetType() { - ApexNode node = parse("public class Foo { private String myField = 'a'; }"); + ApexNode node = parse("public class Foo { private String myField = 'a'; }"); ASTField field = node.getFirstDescendantOfType(ASTField.class); Assert.assertEquals("myField", field.getImage()); @@ -23,7 +21,7 @@ public class ASTFieldTest extends ApexParserTestBase { @Test public void testGetValue() { - ApexNode node = parse("public class Foo { private String myField = 'a'; }"); + ApexNode node = parse("public class Foo { private String myField = 'a'; }"); ASTField field = node.getFirstDescendantOfType(ASTField.class); Assert.assertEquals("a", field.getValue()); @@ -31,7 +29,7 @@ public class ASTFieldTest extends ApexParserTestBase { @Test public void testGetNoValue() { - ApexNode node = parse("public class Foo { private String myField; }"); + ApexNode node = parse("public class Foo { private String myField; }"); ASTField field = node.getFirstDescendantOfType(ASTField.class); Assert.assertNull(field.getValue()); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodTest.java index 832ab9e976..060b40a368 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodTest.java @@ -9,13 +9,11 @@ import java.util.List; import org.junit.Assert; import org.junit.Test; -import apex.jorje.semantic.ast.compilation.Compilation; - public class ASTMethodTest extends ApexParserTestBase { @Test public void testConstructorName() { - ApexNode node = parse("public class Foo { public Foo() {} public void bar() {} }"); + ApexNode node = parse("public class Foo { public Foo() {} public void bar() {} }"); Assert.assertSame(ASTUserClass.class, node.getClass()); List methods = node.findChildrenOfType(ASTMethod.class); Assert.assertEquals("Foo", methods.get(0).getImage()); // constructor diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpressionTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpressionTest.java index 82fd256867..927c559790 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpressionTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpressionTest.java @@ -9,13 +9,11 @@ import java.util.List; import org.junit.Assert; import org.junit.Test; -import apex.jorje.semantic.ast.compilation.Compilation; - public class ASTNewKeyValueObjectExpressionTest extends ApexParserTestBase { @Test public void testParameterName() { - ApexNode node = parse("public class Foo { \n" + ApexNode node = parse("public class Foo { \n" + " public void foo(String newName, String tempID) { \n" + " if (Contact.sObjectType.getDescribe().isCreateable() && Contact.sObjectType.getDescribe().isUpdateable()) {\n" + " upsert new Contact(FirstName = 'First', LastName = 'Last', Phone = '414-414-4414');\n" diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpressionTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpressionTest.java index 4bf940aaa2..31a933ea2d 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpressionTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpressionTest.java @@ -7,13 +7,11 @@ package net.sourceforge.pmd.lang.apex.ast; import org.junit.Assert; import org.junit.Test; -import apex.jorje.semantic.ast.compilation.Compilation; - public class ASTSoqlExpressionTest extends ApexParserTestBase { @Test public void testQuery() { - ApexNode node = parse("class Foo { void test1() { Account acc = [SELECT col FROM Account]; } }"); + ApexNode node = parse("class Foo { void test1() { Account acc = [SELECT col FROM Account]; } }"); ASTSoqlExpression soqlExpression = node.getFirstDescendantOfType(ASTSoqlExpression.class); Assert.assertEquals("SELECT col FROM Account", soqlExpression.getQuery()); } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSwitchStatementTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSwitchStatementTest.java index 72623c8ecc..f5dddb17c0 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSwitchStatementTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSwitchStatementTest.java @@ -9,13 +9,11 @@ import java.util.List; import org.junit.Assert; import org.junit.Test; -import apex.jorje.semantic.ast.compilation.Compilation; - public class ASTSwitchStatementTest extends ApexParserTestBase { @Test public void testExamples() { - ApexNode node = parseResource("SwitchStatements.cls"); + ApexNode node = parseResource("SwitchStatements.cls"); List switchStatements = node.findDescendantsOfType(ASTSwitchStatement.class); Assert.assertEquals(4, switchStatements.size()); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatementTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatementTest.java index a45ac3dfb8..a6cd4df9b9 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatementTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatementTest.java @@ -7,13 +7,11 @@ package net.sourceforge.pmd.lang.apex.ast; import org.junit.Assert; import org.junit.Test; -import apex.jorje.semantic.ast.compilation.Compilation; - public class ASTTryCatchFinallyBlockStatementTest extends ApexParserTestBase { @Test public void testTryFinally() { - ApexNode node = parse("class Foo { void bar() { try { methodCall(); } finally { methodCall(); } } }"); + ApexNode node = parse("class Foo { void bar() { try { methodCall(); } finally { methodCall(); } } }"); ASTTryCatchFinallyBlockStatement statement = node.getFirstDescendantOfType(ASTTryCatchFinallyBlockStatement.class); Assert.assertNotNull(statement.getTryBlock()); Assert.assertEquals(0, statement.getTryBlock().getIndexInParent()); @@ -24,7 +22,7 @@ public class ASTTryCatchFinallyBlockStatementTest extends ApexParserTestBase { @Test public void testTryCatch() { - ApexNode node = parse("class Foo { void bar() { try { methodCall(); } catch (Exception e) { methodCall(); } } }"); + ApexNode node = parse("class Foo { void bar() { try { methodCall(); } catch (Exception e) { methodCall(); } } }"); ASTTryCatchFinallyBlockStatement statement = node.getFirstDescendantOfType(ASTTryCatchFinallyBlockStatement.class); Assert.assertNotNull(statement.getTryBlock()); Assert.assertEquals(0, statement.getTryBlock().getIndexInParent()); @@ -36,7 +34,7 @@ public class ASTTryCatchFinallyBlockStatementTest extends ApexParserTestBase { @Test public void testTryCatchFinally() { - ApexNode node = parse("class Foo { void bar() { try { methodCall(); } catch (Exception e) { methodCall(); } finally { } } }"); + ApexNode node = parse("class Foo { void bar() { try { methodCall(); } catch (Exception e) { methodCall(); } finally { } } }"); ASTTryCatchFinallyBlockStatement statement = node.getFirstDescendantOfType(ASTTryCatchFinallyBlockStatement.class); Assert.assertNotNull(statement.getTryBlock()); Assert.assertEquals(0, statement.getTryBlock().getIndexInParent()); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassTest.java index 4fa039f9ce..9a2cda1265 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassTest.java @@ -9,20 +9,18 @@ import java.util.Arrays; import org.junit.Assert; import org.junit.Test; -import apex.jorje.semantic.ast.compilation.Compilation; - public class ASTUserClassTest extends ApexParserTestBase { @Test public void testClassName() { - ApexNode node = parse("class Foo { }"); + ApexNode node = parse("class Foo { }"); Assert.assertSame(ASTUserClass.class, node.getClass()); Assert.assertEquals("Foo", node.getImage()); } @Test public void testInnerClassName() { - ApexNode node = parse("class Foo { class Bar { } }"); + ApexNode node = parse("class Foo { class Bar { } }"); Assert.assertSame(ASTUserClass.class, node.getClass()); ASTUserClass innerNode = node.getFirstDescendantOfType(ASTUserClass.class); Assert.assertNotNull(innerNode); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnumTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnumTest.java index cf67095019..c03125ecb5 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnumTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnumTest.java @@ -7,13 +7,11 @@ package net.sourceforge.pmd.lang.apex.ast; import org.junit.Assert; import org.junit.Test; -import apex.jorje.semantic.ast.compilation.Compilation; - public class ASTUserEnumTest extends ApexParserTestBase { @Test public void testEnumName() { - ApexNode node = parse("class Foo { enum Bar { } }"); + ApexNode node = parse("class Foo { enum Bar { } }"); Assert.assertSame(ASTUserClass.class, node.getClass()); ASTUserEnum enumNode = node.getFirstDescendantOfType(ASTUserEnum.class); Assert.assertNotNull(enumNode); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterfaceTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterfaceTest.java index a53124139b..6b56d677b9 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterfaceTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterfaceTest.java @@ -7,20 +7,18 @@ package net.sourceforge.pmd.lang.apex.ast; import org.junit.Assert; import org.junit.Test; -import apex.jorje.semantic.ast.compilation.Compilation; - public class ASTUserInterfaceTest extends ApexParserTestBase { @Test public void testInterfaceName() { - ApexNode node = parse("interface Foo { }"); + ApexNode node = parse("interface Foo { }"); Assert.assertSame(ASTUserInterface.class, node.getClass()); Assert.assertEquals("Foo", node.getImage()); } @Test public void testInnerInterfaceName() { - ApexNode node = parse("class Foo { interface Bar { } }"); + ApexNode node = parse("class Foo { interface Bar { } }"); Assert.assertSame(ASTUserClass.class, node.getClass()); ASTUserInterface innerNode = node.getFirstDescendantOfType(ASTUserInterface.class); Assert.assertNotNull(innerNode); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java index be3f11d57e..10c7875243 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java @@ -21,8 +21,6 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.xpath.internal.FileNameXPathFunction; import net.sourceforge.pmd.util.IOUtil; -import apex.jorje.semantic.ast.compilation.Compilation; - public class ApexParserTest extends ApexParserTestBase { @Test @@ -33,7 +31,7 @@ public class ApexParserTest extends ApexParserTestBase { + " \n" + " }\n" + "}"; // Exercise - ApexNode rootNode = parse(code); + ApexNode rootNode = parse(code); // Verify List methods = rootNode.findDescendantsOfType(ASTMethod.class); @@ -59,18 +57,18 @@ public class ApexParserTest extends ApexParserTestBase { @Test public void verifyLineColumnNumbers() { - ApexNode rootNode = parse(testCodeForLineNumbers); + ApexNode rootNode = parse(testCodeForLineNumbers); assertLineNumbersForTestCode(rootNode); } @Test public void verifyLineColumnNumbersWithWindowsLineEndings() { String windowsLineEndings = testCodeForLineNumbers.replaceAll(" \n", "\r\n"); - ApexNode rootNode = parse(windowsLineEndings); + ApexNode rootNode = parse(windowsLineEndings); assertLineNumbersForTestCode(rootNode); } - private void assertLineNumbersForTestCode(ApexNode rootNode) { + private void assertLineNumbersForTestCode(ApexNode rootNode) { // whole source code, well from the beginning of the class // name Modifier of the class - doesn't work. This node just // sees the identifier ("SimpleClass") @@ -107,7 +105,7 @@ public class ApexParserTest extends ApexParserTestBase { + " }\n" // line 5 + "}\n"; // line 6 - ApexNode rootNode = parse(code); + ApexNode rootNode = parse(code); Node method1 = rootNode.getChild(1); assertEquals("Wrong begin line", 2, method1.getBeginLine()); @@ -129,7 +127,7 @@ public class ApexParserTest extends ApexParserTestBase { + " }\n" // line 5 + "}\n"; // line 6 - ApexNode root = parse(code); + ApexNode root = parse(code); assertThat(root, instanceOf(ASTUserClass.class)); ApexNode comment = root.getChild(0); @@ -154,7 +152,7 @@ public class ApexParserTest extends ApexParserTestBase { for (File file : fList) { if (file.isFile() && file.getName().endsWith(".cls")) { String sourceCode = IOUtil.readFileToString(file, StandardCharsets.UTF_8); - ApexNode rootNode = parse(sourceCode); + ApexNode rootNode = parse(sourceCode); Assert.assertNotNull(rootNode); } } @@ -168,7 +166,7 @@ public class ApexParserTest extends ApexParserTestBase { public void parseInheritedSharingClass() throws IOException { String source = IOUtil.readToString(ApexParserTest.class.getResourceAsStream("InheritedSharing.cls"), StandardCharsets.UTF_8); - ApexNode rootNode = parse(source); + ApexNode rootNode = parse(source); Assert.assertNotNull(rootNode); } @@ -181,7 +179,7 @@ public class ApexParserTest extends ApexParserTestBase { public void stackOverflowDuringClassParsing() throws Exception { String source = IOUtil.readToString(ApexParserTest.class.getResourceAsStream("StackOverflowClass.cls"), StandardCharsets.UTF_8); - ApexNode rootNode = parse(source); + ApexNode rootNode = parse(source); Assert.assertNotNull(rootNode); int count = visitPosition(rootNode, 0); @@ -193,7 +191,7 @@ public class ApexParserTest extends ApexParserTestBase { String source = IOUtil.readToString(ApexParserTest.class.getResourceAsStream("InnerClassLocations.cls"), StandardCharsets.UTF_8); source = source.replaceAll("\r\n", "\n"); - ApexNode rootNode = parse(source); + ApexNode rootNode = parse(source); Assert.assertNotNull(rootNode); visitPosition(rootNode, 0); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTestBase.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTestBase.java index 728e57b3a9..ab27f77abb 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTestBase.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTestBase.java @@ -11,15 +11,15 @@ public class ApexParserTestBase { protected final ApexParsingHelper apex = ApexParsingHelper.DEFAULT.withResourceContext(getClass()); - protected ApexNode parse(String code) { + protected ApexRootNode parse(String code) { return apex.parse(code); } - protected ApexNode parse(String code, String fileName) { + protected ApexRootNode parse(String code, String fileName) { return apex.parse(code, null, fileName); } - protected ApexNode parseResource(String code) { + protected ApexRootNode parseResource(String code) { return apex.parseResource(code); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java index 515b830457..cf55cb8cc5 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java @@ -13,9 +13,6 @@ import java.util.List; import org.junit.Test; -import apex.jorje.semantic.ast.compilation.Compilation; - - /** * @author ClΓ©ment Fournier */ @@ -23,9 +20,9 @@ public class ApexQualifiedNameTest extends ApexParserTestBase { @Test public void testClass() { - ApexNode root = parse("public class Foo {}"); + ApexNode root = parse("public class Foo {}"); - ApexQualifiedName qname = ASTUserClass.class.cast(root).getQualifiedName(); + ApexQualifiedName qname = ((ASTUserClass) root).getQualifiedName(); assertEquals("c__Foo", qname.toString()); assertEquals(1, qname.getClasses().length); assertNotNull(qname.getNameSpace()); @@ -35,7 +32,7 @@ public class ApexQualifiedNameTest extends ApexParserTestBase { @Test public void testNestedClass() { - ApexNode root = parse("public class Foo { class Bar {}}"); + ApexNode root = parse("public class Foo { class Bar {}}"); ApexQualifiedName qname = root.getFirstDescendantOfType(ASTUserClass.class).getQualifiedName(); assertEquals("c__Foo.Bar", qname.toString()); @@ -47,7 +44,7 @@ public class ApexQualifiedNameTest extends ApexParserTestBase { @Test public void testSimpleMethod() { - ApexNode root = parse("public class Foo { String foo() {}}"); + ApexNode root = parse("public class Foo { String foo() {}}"); ApexQualifiedName qname = root.getFirstDescendantOfType(ASTMethod.class).getQualifiedName(); assertEquals("c__Foo#foo()", qname.toString()); assertEquals(1, qname.getClasses().length); @@ -58,7 +55,7 @@ public class ApexQualifiedNameTest extends ApexParserTestBase { @Test public void testMethodWithArguments() { - ApexNode root = parse("public class Foo { String foo(String h, Foo g) {}}"); + ApexNode root = parse("public class Foo { String foo(String h, Foo g) {}}"); ApexQualifiedName qname = root.getFirstDescendantOfType(ASTMethod.class).getQualifiedName(); assertEquals("c__Foo#foo(String, Foo)", qname.toString()); assertEquals(1, qname.getClasses().length); @@ -69,7 +66,7 @@ public class ApexQualifiedNameTest extends ApexParserTestBase { @Test public void testOverLoads() { - ApexNode root = parse("public class Foo { " + ApexNode root = parse("public class Foo { " + "String foo(String h) {} " + "String foo(int c) {}" + "String foo(Foo c) {}}"); @@ -88,7 +85,7 @@ public class ApexQualifiedNameTest extends ApexParserTestBase { @Test public void testTrigger() { - ApexNode root = parse("trigger myAccountTrigger on Account (before insert, before update) {}"); + ApexNode root = parse("trigger myAccountTrigger on Account (before insert, before update) {}"); List methods = root.findDescendantsOfType(ASTMethod.class); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/ApexProjectMirrorTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/ApexProjectMirrorTest.java index 204bc20b7c..0c6cabf7b1 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/ApexProjectMirrorTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/ApexProjectMirrorTest.java @@ -27,14 +27,12 @@ import net.sourceforge.pmd.lang.metrics.MetricKeyUtil; import net.sourceforge.pmd.lang.metrics.MetricOptions; import net.sourceforge.pmd.lang.metrics.MetricsUtil; -import apex.jorje.semantic.ast.compilation.Compilation; - /** * @author ClΓ©ment Fournier */ public class ApexProjectMirrorTest extends ApexParserTestBase { - private static ApexNode acu; + private static ApexNode acu; private MetricKey> classMetricKey = MetricKeyUtil.of(null, new RandomClassMetric()); private MetricKey opMetricKey = MetricKeyUtil.of(null, new RandomOperationMetric()); @@ -70,7 +68,7 @@ public class ApexProjectMirrorTest extends ApexParserTestBase { } - private List visitWith(ApexNode acu, final boolean force) { + private List visitWith(ApexNode acu, final boolean force) { final List result = new ArrayList<>(); acu.jjtAccept(new ApexParserVisitorAdapter() { diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileVisitorTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileVisitorTest.java index 625a7d40eb..ce5829028b 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileVisitorTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileVisitorTest.java @@ -18,8 +18,6 @@ import net.sourceforge.pmd.lang.apex.ast.ApexParserVisitorAdapter; import net.sourceforge.pmd.lang.apex.metrics.ApexSignatureMatcher; import net.sourceforge.pmd.lang.apex.metrics.signature.ApexOperationSigMask; -import apex.jorje.semantic.ast.compilation.Compilation; - /** * @author ClΓ©ment Fournier */ @@ -33,7 +31,7 @@ public class ApexMultifileVisitorTest extends ApexParserTestBase { @Test public void testOperationsAreThere() throws IOException { - ApexNode acu = parseResource("MetadataDeployController.cls"); + ApexNode acu = parseResource("MetadataDeployController.cls"); final ApexSignatureMatcher toplevel = ApexProjectMirror.INSTANCE; diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java index e0d0bc2737..6d7f80ce3e 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java @@ -19,8 +19,6 @@ import net.sourceforge.pmd.lang.apex.ast.ASTUserTrigger; import net.sourceforge.pmd.lang.apex.ast.ApexNode; import net.sourceforge.pmd.lang.apex.ast.ApexParserTestBase; -import apex.jorje.semantic.ast.compilation.Compilation; - public class AbstractApexRuleTest extends ApexParserTestBase { @Test @@ -44,7 +42,7 @@ public class AbstractApexRuleTest extends ApexParserTestBase { } private void run(String code) { - ApexNode node = parse(code); + ApexNode node = parse(code); TopLevelRule rule = new TopLevelRule(); RuleContext ctx = new RuleContext(); ctx.setLanguageVersion(apex.getDefaultVersion()); From fbeb071d081f3ef848d8de34a7dcf32c7975b458 Mon Sep 17 00:00:00 2001 From: Aaron Hurst Date: Fri, 12 Aug 2022 19:10:54 +0000 Subject: [PATCH 09/45] Implement ApexQualifiableNode for ASTUserEnum. Include enum in qualified name. Properly handle case where enum is root node. Fixes null deref in ApexQualifiedName.toString() for built-in ASTMethods in enum types. Reference: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_enum.htm Add tests of qualified and unqualified enums. Change-Id: I691795d40a66f3d3335ab72ad43de7055a6aee31 --- .../pmd/lang/apex/ast/ASTUserEnum.java | 20 ++++++++- .../pmd/lang/apex/ast/ApexQualifiedName.java | 44 ++++++++++++++----- .../lang/apex/ast/ApexQualifiedNameTest.java | 29 ++++++++++++ 3 files changed, 82 insertions(+), 11 deletions(-) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnum.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnum.java index 4aef1641cc..b4db014ea9 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnum.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnum.java @@ -8,7 +8,9 @@ import net.sourceforge.pmd.annotation.InternalApi; import apex.jorje.semantic.ast.compilation.UserEnum; -public class ASTUserEnum extends ApexRootNode { +public class ASTUserEnum extends ApexRootNode implements ApexQualifiableNode { + + private ApexQualifiedName qname; @Deprecated @InternalApi @@ -30,4 +32,20 @@ public class ASTUserEnum extends ApexRootNode { public ASTModifierNode getModifiers() { return getFirstChildOfType(ASTModifierNode.class); } + + @Override + public ApexQualifiedName getQualifiedName() { + if (qname == null) { + + ASTUserClass parent = this.getFirstParentOfType(ASTUserClass.class); + + if (parent != null) { + qname = ApexQualifiedName.ofNestedEnum(parent.getQualifiedName(), this); + } else { + qname = ApexQualifiedName.ofOuterEnum(this); + } + } + + return qname; + } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedName.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedName.java index d3898a29fb..b5ce290e4a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedName.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedName.java @@ -148,6 +148,20 @@ public final class ApexQualifiedName implements QualifiedName { } + static ApexQualifiedName ofOuterEnum(ASTUserEnum astUserEnum) { + String ns = astUserEnum.getNamespace(); + String[] classes = {astUserEnum.getImage()}; + return new ApexQualifiedName(StringUtils.isEmpty(ns) ? "c" : ns, classes, null); + } + + + static ApexQualifiedName ofNestedEnum(ApexQualifiedName parent, ASTUserEnum astUserEnum) { + String[] classes = Arrays.copyOf(parent.classes, parent.classes.length + 1); + classes[classes.length - 1] = astUserEnum.getImage(); + return new ApexQualifiedName(parent.nameSpace, classes, null); + } + + private static String getOperationString(ASTMethod node) { StringBuilder sb = new StringBuilder(); sb.append(node.getImage()).append('('); @@ -171,18 +185,28 @@ public final class ApexQualifiedName implements QualifiedName { static ApexQualifiedName ofMethod(ASTMethod node) { - ASTUserClassOrInterface parent = node.getFirstParentOfType(ASTUserClassOrInterface.class); - if (parent == null) { - ASTUserTrigger trigger = node.getFirstParentOfType(ASTUserTrigger.class); - String ns = trigger.getNamespace(); - String targetObj = trigger.getTargetName(); - - return new ApexQualifiedName(StringUtils.isEmpty(ns) ? "c" : ns, new String[]{"trigger", targetObj}, trigger.getImage()); // uses a reserved word as a class name to prevent clashes - - } else { - ApexQualifiedName baseName = parent.getQualifiedName(); + // Check first, as enum must be innermost potential parent + ASTUserEnum enumParent = node.getFirstParentOfType(ASTUserEnum.class); + if (enumParent != null) { + ApexQualifiedName baseName = enumParent.getQualifiedName(); return new ApexQualifiedName(baseName.nameSpace, baseName.classes, getOperationString(node)); } + + ASTUserClassOrInterface classParent = node.getFirstParentOfType(ASTUserClassOrInterface.class); + if (classParent != null) { + ApexQualifiedName baseName = classParent.getQualifiedName(); + + return new ApexQualifiedName(baseName.nameSpace, baseName.classes, getOperationString(node)); + } + + ASTUserTrigger triggerParent = node.getFirstParentOfType(ASTUserTrigger.class); + if (triggerParent != null) { + String ns = triggerParent.getNamespace(); + String targetObj = triggerParent.getTargetName(); + + return new ApexQualifiedName(StringUtils.isEmpty(ns) ? "c" : ns, new String[]{"trigger", targetObj}, triggerParent.getImage()); // uses a reserved word as a class name to prevent clashes + } + throw new UnsupportedOperationException(); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java index 515b830457..d290a4044a 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java @@ -8,6 +8,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.util.List; @@ -97,4 +98,32 @@ public class ApexQualifiedNameTest extends ApexParserTestBase { assertEquals("c__trigger.Account#myAccountTrigger", m.getQualifiedName().toString()); } } + + + @Test + public void testUnqualifiedEnum() { + ApexNode root = parse("public enum primaryColor { RED, YELLOW, BLUE }"); + + ApexQualifiedName enumQName = ASTUserEnum.class.cast(root).getQualifiedName(); + List methods = root.findDescendantsOfType(ASTMethod.class); + + assertEquals("c__primaryColor", enumQName.toString()); + for (ASTMethod m : methods) { + assertTrue(m.getQualifiedName().toString().startsWith("c__primaryColor#")); + } + } + + @Test + public void testQualifiedEnum() { + ApexNode root = parse("public class Outer { public enum Inner { OK } }"); + + ASTUserEnum enumNode = root.getFirstDescendantOfType(ASTUserEnum.class); + ApexQualifiedName enumQName = enumNode.getQualifiedName(); + List methods = enumNode.findDescendantsOfType(ASTMethod.class); + + assertEquals("c__Outer.Inner", enumQName.toString()); + for (ASTMethod m : methods) { + assertTrue(m.getQualifiedName().toString().startsWith("c__Outer.Inner#")); + } + } } From 91fbcc804abf5cef726bb44eab1bd92703a5eb64 Mon Sep 17 00:00:00 2001 From: zon <> Date: Wed, 17 Aug 2022 12:40:39 +0200 Subject: [PATCH 10/45] Added begin and end token attributes to XML output of CPD --- .../pmd/userdocs/cpd/cpd_report_formats.md | 10 +++--- .../java/net/sourceforge/pmd/cpd/Mark.java | 8 +++++ .../net/sourceforge/pmd/cpd/XMLRenderer.java | 6 ++++ .../sourceforge/pmd/cpd/XMLRendererTest.java | 32 +++++++++++++++++++ 4 files changed, 51 insertions(+), 5 deletions(-) diff --git a/docs/pages/pmd/userdocs/cpd/cpd_report_formats.md b/docs/pages/pmd/userdocs/cpd/cpd_report_formats.md index 4e1a23a0d0..f21bd5b448 100644 --- a/docs/pages/pmd/userdocs/cpd/cpd_report_formats.md +++ b/docs/pages/pmd/userdocs/cpd/cpd_report_formats.md @@ -104,9 +104,9 @@ Example: - - - - - ruleChainVisits = query.getRuleChainVisits(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Mark.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Mark.java index c741a337ad..30e13c4b04 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Mark.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Mark.java @@ -35,6 +35,10 @@ public class Mark implements Comparable { return this.token.getBeginColumn(); // TODO Java 1.8 make optional } + public int getBeginTokenIndex() { + return this.token.getIndex(); + } + public int getEndLine() { return getBeginLine() + getLineCount() - 1; } @@ -48,6 +52,10 @@ public class Mark implements Comparable { return this.endToken == null ? -1 : this.endToken.getEndColumn(); // TODO Java 1.8 make optional } + public int getEndTokenIndex() { + return this.endToken == null ? -1 : this.endToken.getIndex(); + } + public int getLineCount() { return this.lineCount; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java index d7d69382e5..6b5d51a2cf 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java @@ -152,6 +152,12 @@ public final class XMLRenderer implements Renderer, CPDRenderer, CPDReportRender if (endCol != -1) { file.setAttribute("endcolumn", String.valueOf(endCol)); } + final int beginIndex = mark.getBeginTokenIndex(); + final int endIndex = mark.getEndTokenIndex(); + file.setAttribute("begintoken", String.valueOf(beginIndex)); + if (endIndex != -1) { + file.setAttribute("endtoken", String.valueOf(endIndex)); + } duplication.appendChild(file); } return duplication; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLRendererTest.java index 1e29e7961b..366733b088 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLRendererTest.java @@ -216,6 +216,38 @@ public class XMLRendererTest { assertEquals("888", attributes.getNamedItem("totalNumberOfTokens").getNodeValue()); } + @Test + public void testGetDuplicationStartEnd() throws IOException, ParserConfigurationException, SAXException { + TokenEntry.clearImages(); + final CPDReportRenderer renderer = new XMLRenderer(); + final List matches = new ArrayList<>(); + final String filename = "/var/Foo.java"; + final int lineCount = 6; + final String codeFragment = "code\nfragment"; + final Mark mark1 = createMark("public", filename, 1, lineCount, codeFragment, 2, 3); + final Mark mark2 = createMark("stuff", filename, 73, lineCount, codeFragment, 4, 5); + final Match match = new Match(75, mark1, mark2); + matches.add(match); + final Map numberOfTokensPerFile = new HashMap<>(); + numberOfTokensPerFile.put(filename, 888); + final CPDReport report = new CPDReport(matches, numberOfTokensPerFile); + final StringWriter writer = new StringWriter(); + renderer.render(report, writer); + final String xmlOutput = writer.toString(); + final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder() + .parse(new ByteArrayInputStream(xmlOutput.getBytes(ENCODING))); + final NodeList files = doc.getElementsByTagName("file"); + final Node dup_1 = files.item(1); + final NamedNodeMap attrs_1 = dup_1.getAttributes(); + assertEquals("0", attrs_1.getNamedItem("begintoken").getNodeValue()); + assertEquals("1", attrs_1.getNamedItem("endtoken").getNodeValue()); + + final Node dup_2 = files.item(2); + final NamedNodeMap attrs_2 = dup_2.getAttributes(); + assertEquals("2", attrs_2.getNamedItem("begintoken").getNodeValue()); + assertEquals("3", attrs_2.getNamedItem("endtoken").getNodeValue()); + } + @Test public void testRendererEncodedPath() throws IOException { CPDRenderer renderer = new XMLRenderer(); From 237b1066760b992c449a23fdcbf28677dd4f0c68 Mon Sep 17 00:00:00 2001 From: Thomas Prouvot Date: Wed, 17 Aug 2022 15:09:54 +0200 Subject: [PATCH 11/45] Add new assert methods for api 56 --- ...ApexUnitTestClassShouldHaveAssertsRule.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java index 084a25daf6..083ea31356 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java @@ -37,6 +37,24 @@ public class ApexUnitTestClassShouldHaveAssertsRule extends AbstractApexUnitTest ASSERT_METHODS.add("system.assert"); ASSERT_METHODS.add("system.assertequals"); ASSERT_METHODS.add("system.assertnotequals"); + ASSERT_METHODS.add("system.assert.areequal"); + ASSERT_METHODS.add("system.assert.arenotequal"); + ASSERT_METHODS.add("system.assert.fail"); + ASSERT_METHODS.add("system.assert.isfalse"); + ASSERT_METHODS.add("system.assert.isinstanceoftype"); + ASSERT_METHODS.add("system.assert.isnotinstanceoftype"); + ASSERT_METHODS.add("system.assert.isnnull"); + ASSERT_METHODS.add("system.assert.isnotnull"); + ASSERT_METHODS.add("system.assert.istrue"); + ASSERT_METHODS.add("assert.areequal"); + ASSERT_METHODS.add("assert.arenotequal"); + ASSERT_METHODS.add("assert.fail"); + ASSERT_METHODS.add("assert.isfalse"); + ASSERT_METHODS.add("assert.isinstanceoftype"); + ASSERT_METHODS.add("assert.isnotinstanceoftype"); + ASSERT_METHODS.add("assert.isnnull"); + ASSERT_METHODS.add("assert.isnotnull"); + ASSERT_METHODS.add("assert.istrue"); // Fully-qualified variants...rare but still valid/possible ASSERT_METHODS.add("system.system.assert"); ASSERT_METHODS.add("system.system.assertequals"); From 2e1d913058be17c0407203abd6f8bf5d4e47e427 Mon Sep 17 00:00:00 2001 From: Thomas Prouvot Date: Thu, 18 Aug 2022 10:27:06 +0200 Subject: [PATCH 12/45] Update @tprouvot as a contributor --- .all-contributorsrc | 3 ++- docs/pages/pmd/projectdocs/credits.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 99708783e8..4b24a733c3 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -5917,7 +5917,8 @@ "avatar_url": "https://avatars.githubusercontent.com/u/35368290?v=4", "profile": "https://github.com/tprouvot", "contributions": [ - "bug" + "bug", + "code" ] }, { diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index 37788cf5f7..eb60d9190c 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -932,7 +932,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
tobwoerk

πŸ› -
tprouvot

πŸ› +
tprouvot

πŸ› πŸ’»
trentchilders

πŸ›
triandicAnt

πŸ›
trishul14

πŸ› From 2edcfe25cdbab7c56ec0df1ed89fac7a3110d6ac Mon Sep 17 00:00:00 2001 From: Thomas Prouvot Date: Thu, 18 Aug 2022 10:28:19 +0200 Subject: [PATCH 13/45] Update @tprouvot as a contributor --- .all-contributorsrc | 1 - docs/pages/pmd/projectdocs/credits.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 4b24a733c3..5fba86143b 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -5917,7 +5917,6 @@ "avatar_url": "https://avatars.githubusercontent.com/u/35368290?v=4", "profile": "https://github.com/tprouvot", "contributions": [ - "bug", "code" ] }, diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index eb60d9190c..00199aea11 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -932,7 +932,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
tobwoerk

πŸ› -
tprouvot

πŸ› πŸ’» +
tprouvot

πŸ’»
trentchilders

πŸ›
triandicAnt

πŸ›
trishul14

πŸ› From 539838c9064b377df16e2b7dced257790bc6e3c4 Mon Sep 17 00:00:00 2001 From: Thomas Prouvot Date: Thu, 18 Aug 2022 14:40:50 +0200 Subject: [PATCH 14/45] Update previous negative test which is ok now and add new positive test. --- .../xml/ApexUnitTestClassShouldHaveAsserts.xml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml index 8e9520f15d..69d0cba08f 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml @@ -103,7 +103,7 @@ public class Foo { @isTest public class Foo { public static testMethod void testAssertIsTrue() { - Assert.isTrue(someCondition); + Assert.assertEquals(someCondition); } public static testMethod void testLocalVerify() { @@ -115,4 +115,18 @@ public class Foo { } ]]>
+ + + #4096 [apex] api 56.0 ApexAssertionsShouldIncludeMessage and new apex class : Assert + 0 + + From ad21a24b74f96c1e5df0fb7c5075c7f8079c18de Mon Sep 17 00:00:00 2001 From: Thomas Prouvot Date: Thu, 18 Aug 2022 14:48:25 +0200 Subject: [PATCH 15/45] Fix contributors --- .all-contributorsrc | 4 ++-- docs/pages/pmd/projectdocs/credits.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 5fba86143b..16274b1839 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -5917,7 +5917,7 @@ "avatar_url": "https://avatars.githubusercontent.com/u/35368290?v=4", "profile": "https://github.com/tprouvot", "contributions": [ - "code" + "bug" ] }, { @@ -6773,4 +6773,4 @@ "contributorsPerLine": 7, "contributorsSortAlphabetically": true, "skipCi": true -} +} \ No newline at end of file diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index 00199aea11..8a7c21410f 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -932,7 +932,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
tobwoerk

πŸ› -
tprouvot

πŸ’» +
tprouvot

πŸ›
trentchilders

πŸ›
triandicAnt

πŸ›
trishul14

πŸ› From a2058c454b551535b243e53553ee7e4370563d3d Mon Sep 17 00:00:00 2001 From: Thomas Prouvot Date: Thu, 18 Aug 2022 16:34:14 +0200 Subject: [PATCH 16/45] move fully qualified variant under comment (PR Comment) --- ...ApexUnitTestClassShouldHaveAssertsRule.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java index 083ea31356..2e0d717b60 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java @@ -37,15 +37,6 @@ public class ApexUnitTestClassShouldHaveAssertsRule extends AbstractApexUnitTest ASSERT_METHODS.add("system.assert"); ASSERT_METHODS.add("system.assertequals"); ASSERT_METHODS.add("system.assertnotequals"); - ASSERT_METHODS.add("system.assert.areequal"); - ASSERT_METHODS.add("system.assert.arenotequal"); - ASSERT_METHODS.add("system.assert.fail"); - ASSERT_METHODS.add("system.assert.isfalse"); - ASSERT_METHODS.add("system.assert.isinstanceoftype"); - ASSERT_METHODS.add("system.assert.isnotinstanceoftype"); - ASSERT_METHODS.add("system.assert.isnnull"); - ASSERT_METHODS.add("system.assert.isnotnull"); - ASSERT_METHODS.add("system.assert.istrue"); ASSERT_METHODS.add("assert.areequal"); ASSERT_METHODS.add("assert.arenotequal"); ASSERT_METHODS.add("assert.fail"); @@ -59,6 +50,15 @@ public class ApexUnitTestClassShouldHaveAssertsRule extends AbstractApexUnitTest ASSERT_METHODS.add("system.system.assert"); ASSERT_METHODS.add("system.system.assertequals"); ASSERT_METHODS.add("system.system.assertnotequals"); + ASSERT_METHODS.add("system.assert.areequal"); + ASSERT_METHODS.add("system.assert.arenotequal"); + ASSERT_METHODS.add("system.assert.fail"); + ASSERT_METHODS.add("system.assert.isfalse"); + ASSERT_METHODS.add("system.assert.isinstanceoftype"); + ASSERT_METHODS.add("system.assert.isnotinstanceoftype"); + ASSERT_METHODS.add("system.assert.isnnull"); + ASSERT_METHODS.add("system.assert.isnotnull"); + ASSERT_METHODS.add("system.assert.istrue"); } // Using a string property instead of a regex property to ensure that the compiled pattern can be case-insensitive From dc03e52be3c951a0430135fa5c29dca1a57d1a29 Mon Sep 17 00:00:00 2001 From: Thomas Prouvot Date: Thu, 18 Aug 2022 16:34:46 +0200 Subject: [PATCH 17/45] Update method name and number of parameters (PR Comment) --- .../bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml index 69d0cba08f..b78a6c86f7 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml @@ -102,8 +102,8 @@ public class Foo { Date: Thu, 18 Aug 2022 17:11:22 +0200 Subject: [PATCH 18/45] fix contributors --- .all-contributorsrc | 2 +- docs/pages/pmd/projectdocs/credits.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 16274b1839..99708783e8 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -6773,4 +6773,4 @@ "contributorsPerLine": 7, "contributorsSortAlphabetically": true, "skipCi": true -} \ No newline at end of file +} diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index 8a7c21410f..37788cf5f7 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -932,7 +932,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
tobwoerk

πŸ› -
tprouvot

πŸ› +
tprouvot

πŸ›
trentchilders

πŸ›
triandicAnt

πŸ›
trishul14

πŸ› From 8fcbcb434e9e2862989e0fbd0ecd4e3c0250dac2 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Wed, 24 Aug 2022 17:27:34 +0200 Subject: [PATCH 19/45] [doc] Update release notes (#4082, #4083) --- docs/pages/release_notes.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index b8f8783555..f14ef9960d 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -16,9 +16,14 @@ This is a {{ site.pmd.release_type }} release. ### Fixed Issues +* java-codestyle + * [#4082](https://github.com/pmd/pmd/issues/4082): \[java] UnnecessaryImport false positive for on-demand imports of nested classes + ### API Changes ### External Contributions +* [#4083](https://github.com/pmd/pmd/pull/4083): \[java] UnnecessaryImport false positive for on-demand imports of nested classes (fix for #4082) - [@abyss638](https://github.com/abyss638) + {% endtocmaker %} From 075507cb0183aa09256508c1a7d3dc311c79071b Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Wed, 24 Aug 2022 17:28:13 +0200 Subject: [PATCH 20/45] Add @abyss638 as a contributor --- .all-contributorsrc | 9 ++++ docs/pages/pmd/projectdocs/credits.md | 75 ++++++++++++++------------- 2 files changed, 47 insertions(+), 37 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 99708783e8..9ef6610038 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -6768,6 +6768,15 @@ "code", "financial" ] + }, + { + "login": "abyss638", + "name": "Simon Abykov", + "avatar_url": "https://avatars.githubusercontent.com/u/90252673?v=4", + "profile": "https://github.com/abyss638", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index 37788cf5f7..73955ce6f7 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -632,333 +632,334 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Sergey Yanzin

πŸ’» πŸ›
Seth Wilcox

πŸ’»
Shubham

πŸ’» πŸ› -
Simon Xiao

πŸ› +
Simon Abykov

πŸ’» +
Simon Xiao

πŸ›
Srinivasan Venkatachalam

πŸ›
Stanislav Gromov

πŸ›
Stanislav Myachenkov

πŸ’»
Stefan Birkner

πŸ›
Stefan Bohn

πŸ›
Stefan Endrullis

πŸ› -
Stefan KlΓΆss-Schuster

πŸ› +
Stefan KlΓΆss-Schuster

πŸ›
Stefan Wolf

πŸ›
Stephan H. Wissel

πŸ›
Stephen

πŸ›
Stephen Friedrich

πŸ›
Steve Babula

πŸ’»
Stexxe

πŸ› -
Stian LΓ₯gstad

πŸ› +
Stian LΓ₯gstad

πŸ›
StuartClayton5

πŸ›
Supun Arunoda

πŸ›
Suren Abrahamyan

πŸ›
SwatiBGupta1110

πŸ›
SyedThoufich

πŸ›
Szymon Sasin

πŸ› -
T-chuangxin

πŸ› +
T-chuangxin

πŸ›
TERAI Atsuhiro

πŸ›
TIOBE Software

πŸ’» πŸ›
Taylor Smock

πŸ›
Techeira DamiΓ‘n

πŸ’» πŸ›
Ted Husted

πŸ›
TehBakker

πŸ› -
The Gitter Badger

πŸ› +
The Gitter Badger

πŸ›
Theodoor

πŸ›
Thiago Henrique HΓΌpner

πŸ›
Thibault Meyer

πŸ›
Thomas GΓΌttler

πŸ›
Thomas Jones-Low

πŸ›
Thomas Smith

πŸ’» πŸ› -
ThrawnCA

πŸ› +
ThrawnCA

πŸ›
Thunderforge

πŸ’» πŸ›
Tim van der Lippe

πŸ›
Tobias Weimer

πŸ’» πŸ›
Tom Daly

πŸ›
Tomer Figenblat

πŸ›
Tomi De Lucca

πŸ’» πŸ› -
Torsten Kleiber

πŸ› +
Torsten Kleiber

πŸ›
TrackerSB

πŸ›
Ullrich Hafner

πŸ›
Utku Cuhadaroglu

πŸ’» πŸ›
Valentin Brandl

πŸ›
Valeria

πŸ›
Vasily Anisimov

πŸ› -
Vibhor Goyal

πŸ› +
Vibhor Goyal

πŸ›
Vickenty Fesunov

πŸ›
Victor NoΓ«l

πŸ›
Vincent Galloy

πŸ’»
Vincent HUYNH

πŸ›
Vincent Maurin

πŸ›
Vincent Privat

πŸ› -
Vishhwas

πŸ› +
Vishhwas

πŸ›
Vitaly

πŸ›
Vitaly Polonetsky

πŸ›
Vojtech Polivka

πŸ›
Vsevolod Zholobov

πŸ›
Vyom Yadav

πŸ’»
Wang Shidong

πŸ› -
Waqas Ahmed

πŸ› +
Waqas Ahmed

πŸ›
Wayne J. Earl

πŸ›
Wchenghui

πŸ›
Will Winder

πŸ›
William Brockhus

πŸ’» πŸ›
Wilson Kurniawan

πŸ›
Wim Deblauwe

πŸ› -
Woongsik Choi

πŸ› +
Woongsik Choi

πŸ›
XenoAmess

πŸ’» πŸ›
Yang

πŸ’»
YaroslavTER

πŸ›
Young Chan

πŸ’» πŸ›
YuJin Kim

πŸ›
Yuri Dolzhenko

πŸ› -
Yurii Dubinka

πŸ› +
Yurii Dubinka

πŸ›
Zoltan Farkas

πŸ›
Zustin

πŸ›
aaronhurst-google

πŸ›
alexmodis

πŸ›
andreoss

πŸ›
andrey81inmd

πŸ’» πŸ› -
anicoara

πŸ› +
anicoara

πŸ›
arunprasathav

πŸ›
asiercamara

πŸ›
astillich-igniti

πŸ’»
avesolovksyy

πŸ›
avishvat

πŸ›
avivmu

πŸ› -
axelbarfod1

πŸ› +
axelbarfod1

πŸ›
b-3-n

πŸ›
balbhadra9

πŸ›
base23de

πŸ›
bergander

πŸ›
berkam

πŸ’» πŸ›
breizh31

πŸ› -
caesarkim

πŸ› +
caesarkim

πŸ›
carolyujing

πŸ›
cesares-basilico

πŸ›
chrite

πŸ›
cobratbq

πŸ›
coladict

πŸ›
cosmoJFH

πŸ› -
cristalp

πŸ› +
cristalp

πŸ›
crunsk

πŸ›
cwholmes

πŸ›
cyberjj999

πŸ›
cyw3

πŸ›
d1ss0nanz

πŸ›
dalizi007

πŸ’» -
danbrycefairsailcom

πŸ› +
danbrycefairsailcom

πŸ›
dariansanity

πŸ›
darrenmiliband

πŸ›
davidburstrom

πŸ›
dbirkman-paloalto

πŸ›
deepak-patra

πŸ›
dependabot[bot]

πŸ’» πŸ› -
dinesh150

πŸ› +
dinesh150

πŸ›
diziaq

πŸ›
dreaminpast123

πŸ›
duanyanan

πŸ›
dutt-sanjay

πŸ›
dylanleung

πŸ›
dzeigler

πŸ› -
ekkirala

πŸ› +
ekkirala

πŸ›
emersonmoura

πŸ›
fairy

πŸ›
filiprafalowicz

πŸ’»
foxmason

πŸ›
frankegabor

πŸ›
frankl

πŸ› -
freafrea

πŸ› +
freafrea

πŸ›
fsapatin

πŸ›
gracia19

πŸ›
guo fei

πŸ›
gurmsc5

πŸ›
gwilymatgearset

πŸ’» πŸ›
haigsn

πŸ› -
hemanshu070

πŸ› +
hemanshu070

πŸ›
henrik242

πŸ›
hongpuwu

πŸ›
hvbtup

πŸ’» πŸ›
igniti GmbH

πŸ›
ilovezfs

πŸ›
itaigilo

πŸ› -
jakivey32

πŸ› +
jakivey32

πŸ›
jbennett2091

πŸ›
jcamerin

πŸ›
jkeener1

πŸ›
jmetertea

πŸ›
johnra2

πŸ’»
josemanuelrolon

πŸ’» πŸ› -
kabroxiko

πŸ’» πŸ› +
kabroxiko

πŸ’» πŸ›
karwer

πŸ›
kaulonline

πŸ›
kdaemonv

πŸ›
kenji21

πŸ’» πŸ›
kfranic

πŸ›
khalidkh

πŸ› -
krzyk

πŸ› +
krzyk

πŸ›
lasselindqvist

πŸ›
lgemeinhardt

πŸ›
lihuaib

πŸ›
lonelyma1021

πŸ›
lpeddy

πŸ›
lujiefsi

πŸ’» -
lukelukes

πŸ’» +
lukelukes

πŸ’»
lyriccoder

πŸ›
marcelmore

πŸ›
matchbox

πŸ›
matthiaskraaz

πŸ›
meandonlyme

πŸ›
mikesive

πŸ› -
milossesic

πŸ› +
milossesic

πŸ›
mriddell95

πŸ›
mrlzh

πŸ›
msloan

πŸ›
mucharlaravalika

πŸ›
mvenneman

πŸ›
nareshl119

πŸ› -
nicolas-harraudeau-sonarsource

πŸ› +
nicolas-harraudeau-sonarsource

πŸ›
noerremark

πŸ›
novsirion

πŸ›
oggboy

πŸ›
oinume

πŸ›
orimarko

πŸ’» πŸ›
pallavi agarwal

πŸ› -
parksungrin

πŸ› +
parksungrin

πŸ›
patpatpat123

πŸ›
patriksevallius

πŸ›
pbrajesh1

πŸ›
phoenix384

πŸ›
piotrszymanski-sc

πŸ’»
plan3d

πŸ› -
poojasix

πŸ› +
poojasix

πŸ›
prabhushrikant

πŸ›
pujitha8783

πŸ›
r-r-a-j

πŸ›
raghujayjunk

πŸ›
rajeshveera

πŸ›
rajeswarreddy88

πŸ› -
recdevs

πŸ› +
recdevs

πŸ›
reudismam

πŸ’» πŸ›
rijkt

πŸ›
rillig-tk

πŸ›
rmohan20

πŸ’» πŸ›
rxmicro

πŸ›
ryan-gustafson

πŸ’» πŸ› -
sabi0

πŸ› +
sabi0

πŸ›
scais

πŸ›
sebbASF

πŸ›
sergeygorbaty

πŸ’»
shilko2013

πŸ›
shiomiyan

πŸ“–
simeonKondr

πŸ› -
snajberk

πŸ› +
snajberk

πŸ›
sniperrifle2004

πŸ›
snuyanzin

πŸ› πŸ’»
sratz

πŸ›
stonio

πŸ›
sturton

πŸ’» πŸ›
sudharmohan

πŸ› -
suruchidawar

πŸ› +
suruchidawar

πŸ›
svenfinitiv

πŸ›
tashiscool

πŸ›
test-git-hook

πŸ›
testation21

πŸ’» πŸ›
thanosa

πŸ›
tiandiyixian

πŸ› -
tobwoerk

πŸ› +
tobwoerk

πŸ›
tprouvot

πŸ›
trentchilders

πŸ›
triandicAnt

πŸ›
trishul14

πŸ›
tsui

πŸ›
winhkey

πŸ› -
witherspore

πŸ› +
witherspore

πŸ›
wjljack

πŸ›
wuchiuwong

πŸ›
xingsong

πŸ›
xioayuge

πŸ›
xnYi9wRezm

πŸ’» πŸ›
xuanuy

πŸ› -
xyf0921

πŸ› +
xyf0921

πŸ›
yalechen-cyw3

πŸ›
yasuharu-sato

πŸ›
zenglian

πŸ›
zgrzyt93

πŸ’» πŸ›
zh3ng

πŸ›
zt_soft

πŸ› -
ztt79

πŸ› +
ztt79

πŸ›
zzzzfeng

πŸ›
ÁrpÑd MagosÑnyi

πŸ›
任贡杰

πŸ› From f83a1a092cef9f09dbb7a5b3389a326ea89c21e7 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Wed, 24 Aug 2022 17:55:04 +0200 Subject: [PATCH 21/45] [doc] Add deprecation infos --- docs/pages/release_notes.md | 15 +++++++++++++++ .../lang/apex/ast/ASTAssignmentExpression.java | 3 +++ .../pmd/lang/apex/ast/ASTBinaryExpression.java | 3 +++ .../pmd/lang/apex/ast/ASTBooleanExpression.java | 3 +++ .../pmd/lang/apex/ast/ASTPostfixExpression.java | 3 +++ .../pmd/lang/apex/ast/ASTPrefixExpression.java | 3 +++ 6 files changed, 30 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index f14ef9960d..53e43a3dad 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -21,6 +21,21 @@ This is a {{ site.pmd.release_type }} release. ### API Changes +#### Deprecated API + +* In order to reduce the dependency on Apex Jorje classes, the following methods have been deprecated. + These methods all leaked internal Jorje enums. These enums have been replaced now by enums the + PMD's AST package. + * {% jdoc !!apex::lang.apex.ast.ASTAssignmentExpression#getOperator() %} + * {% jdoc !!apex::lang.apex.ast.ASTBinaryExpression#getOperator() %} + * {% jdoc !!apex::lang.apex.ast.ASTBooleanExpression#getOperator() %} + * {% jdoc !!apex::lang.apex.ast.ASTPostfixExpression#getOperator() %} + * {% jdoc !!apex::lang.apex.ast.ASTPrefixExpression#getOperator() %} + + All these classes have now a new `getOp()` method. Existing code should be refactored to use this method instead. + It returns the new enums, like {% jdoc apex::lang.apex.ast.AssignmentOperator %}, and avoids + the dependency to Jorje. + ### External Contributions * [#4083](https://github.com/pmd/pmd/pull/4083): \[java] UnnecessaryImport false positive for on-demand imports of nested classes (fix for #4082) - [@abyss638](https://github.com/abyss638) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAssignmentExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAssignmentExpression.java index 73b3b10740..b9e5c03027 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAssignmentExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAssignmentExpression.java @@ -22,6 +22,9 @@ public class ASTAssignmentExpression extends AbstractApexNode { return visitor.visit(this, data); } + /** + * @deprecated Use {@link #getOp()} instead. + */ @Deprecated public BinaryOp getOperator() { return node.getOp(); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBooleanExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBooleanExpression.java index f258a389c8..04950e8907 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBooleanExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBooleanExpression.java @@ -24,6 +24,9 @@ public class ASTBooleanExpression extends AbstractApexNode { return visitor.visit(this, data); } + /** + * @deprecated Use {@link #getOp()} instead. + */ @Deprecated public BooleanOp getOperator() { return this.node.getOp(); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPostfixExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPostfixExpression.java index 8ef0b8770b..f3c9f858f7 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPostfixExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPostfixExpression.java @@ -24,6 +24,9 @@ public class ASTPostfixExpression extends AbstractApexNode { return visitor.visit(this, data); } + /** + * @deprecated Use {@link #getOp()} instead. + */ @Deprecated public PostfixOp getOperator() { return node.getOp(); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPrefixExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPrefixExpression.java index bc8c4fdf29..049ac6b2b6 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPrefixExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPrefixExpression.java @@ -22,6 +22,9 @@ public class ASTPrefixExpression extends AbstractApexNode { return visitor.visit(this, data); } + /** + * @deprecated Use {@link #getOp()} instead. + */ @Deprecated public PrefixOp getOperator() { return node.getOp(); From d2bd69437a761641bcb5459d741211d3c82f31eb Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Wed, 24 Aug 2022 17:56:57 +0200 Subject: [PATCH 22/45] [doc] Update release notes (#4081) --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 53e43a3dad..5e50bcf8c9 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -38,6 +38,7 @@ This is a {{ site.pmd.release_type }} release. ### External Contributions +* [#4081](https://github.com/pmd/pmd/pull/4081): \[apex] Remove Jorje leaks outside `ast` package - [@eklimo](https://github.com/eklimo) * [#4083](https://github.com/pmd/pmd/pull/4083): \[java] UnnecessaryImport false positive for on-demand imports of nested classes (fix for #4082) - [@abyss638](https://github.com/abyss638) {% endtocmaker %} From f71d68067c9da7f2edf73efd34c41be5e8820ece Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Wed, 24 Aug 2022 17:57:23 +0200 Subject: [PATCH 23/45] Add @eklimo as a contributor --- .all-contributorsrc | 10 ++ docs/pages/pmd/projectdocs/credits.md | 163 +++++++++++++------------- 2 files changed, 92 insertions(+), 81 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 9ef6610038..78311a6858 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -6777,6 +6777,16 @@ "contributions": [ "code" ] + }, + { + "login": "eklimo", + "name": "Edward Klimoshenko", + "avatar_url": "https://avatars.githubusercontent.com/u/39220927?v=4", + "profile": "https://github.com/eklimo", + "contributions": [ + "bug", + "code" + ] } ], "contributorsPerLine": 7, diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index 73955ce6f7..967675f0d1 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -231,734 +231,735 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Eden Hao

πŸ› +
Edward Klimoshenko

πŸ› πŸ’»
Egor Bredikhin

πŸ›
Elan P. Kugelmass

πŸ›
Elder S.

πŸ›
Emile

πŸ›
Eric

πŸ› -
Eric Kintzer

πŸ› +
Eric Kintzer

πŸ›
Eric Perret

πŸ›
Eric Squires

πŸ›
Erich L Foster

πŸ›
Erik Bleske

πŸ›
Ernst Reissner

πŸ›
F.W. Dekker

πŸ› -
FSchliephacke

πŸ› +
FSchliephacke

πŸ›
Facundo

πŸ›
Federico Giust

πŸ›
Fedor Sherstobitov

πŸ›
Felix Lampe

πŸ›
Filip Golonka

πŸ›
Filipe Esperandio

πŸ’» πŸ› -
Filippo Nova

πŸ› +
Filippo Nova

πŸ›
Francesco la Torre

πŸ›
Francisco Duarte

πŸ›
Frieder Bluemle

πŸ›
Frits Jalvingh

πŸ’» πŸ›
G. Bazior

πŸ›
Gabe Henkes

πŸ› -
Genoud Magloire

πŸ› +
Genoud Magloire

πŸ›
Geoffrey555

πŸ›
Georg Romstorfer

πŸ›
Gio

πŸ›
Gol

πŸ›
Gonzalo Exequiel Ibars Ingman

πŸ’» πŸ›
GooDer

πŸ› -
Gregor Riegler

πŸ› +
Gregor Riegler

πŸ›
Grzegorz Olszewski

πŸ›
Gunther Schrijvers

πŸ’» πŸ›
Gustavo Krieger

πŸ›
Guy Elsmore-Paddock

πŸ›
GΓΆrkem MΓΌlayim

πŸ›
Hanzel Godinez

πŸ› -
Haoliang Chen

πŸ› +
Haoliang Chen

πŸ›
Harsh Kukreja

πŸ›
Heber

πŸ›
Henning Schmiedehausen

πŸ’» πŸ›
Henning von Bargen

πŸ’»
HervΓ© Boutemy

πŸ›
Himanshu Pandey

πŸ› -
Hokwang Lee

πŸ› +
Hokwang Lee

πŸ›
Hooperbloob

πŸ’»
Hung PHAN

πŸ›
IDoCodingStuffs

πŸ’» πŸ›
Iccen Gan

πŸ›
Ignacio Mariano Tirabasso

πŸ›
Igor Melnichenko

πŸ› -
Igor Moreno

πŸ› +
Igor Moreno

πŸ›
Intelesis-MS

πŸ›
Iroha_

πŸ›
Ishan Srivastava

πŸ›
Ivano Guerini

πŸ›
Ivar Andreas Bonsaksen

πŸ›
Ivo Ε mΓ­d

πŸ› -
JJengility

πŸ› +
JJengility

πŸ›
Jake Hemmerle

πŸ›
James Harrison

πŸ› πŸ’»
Jan

πŸ›
Jan Aertgeerts

πŸ’» πŸ›
Jan BrΓΌmmer

πŸ›
Jan TΕ™Γ­ska

πŸ› -
Jan-Lukas Else

πŸ› +
Jan-Lukas Else

πŸ›
Jason Qiu

πŸ’» πŸ“–
Jason Williams

πŸ›
Jean-Paul Mayer

πŸ›
Jean-Simon Larochelle

πŸ›
Jeff Bartolotta

πŸ’» πŸ›
Jeff Hube

πŸ’» πŸ› -
Jeff Jensen

πŸ› +
Jeff Jensen

πŸ›
Jeff May

πŸ›
Jens Gerdes

πŸ›
Jeroen Borgers

πŸ› πŸ’»
Jerome Russ

πŸ›
JerritEic

πŸ’» πŸ“–
Jiri Pejchal

πŸ› -
Jithin Sunny

πŸ› +
Jithin Sunny

πŸ›
JiΕ™Γ­ Ε korpil

πŸ›
Joao Machado

πŸ›
Jochen Krauss

πŸ›
Johan Hammar

πŸ›
John Karp

πŸ›
John Zhang

πŸ› -
John-Teng

πŸ’» πŸ› +
John-Teng

πŸ’» πŸ›
Jon Moroney

πŸ’» πŸ›
Jonas Geiregat

πŸ›
Jonathan Wiesel

πŸ’» πŸ›
Jordan

πŸ›
Jordi Llach

πŸ›
Jorge SolΓ³rzano

πŸ› -
JorneVL

πŸ› +
JorneVL

πŸ›
Jose Palafox

πŸ›
Jose Stovall

πŸ›
Joseph

πŸ’»
Joseph Heenan

πŸ›
Josh Feingold

πŸ’» πŸ›
Josh Holthaus

πŸ› -
Joshua S Arquilevich

πŸ› +
Joshua S Arquilevich

πŸ›
JoΓ£o Ferreira

πŸ’» πŸ›
JoΓ£o Pedro Schmitt

πŸ›
Juan MartΓ­n Sotuyo Dodero

πŸ’» πŸ“– πŸ› 🚧
Juan Pablo Civile

πŸ›
Julian Voronetsky

πŸ›
Julien

πŸ› -
Julius

πŸ› +
Julius

πŸ›
JustPRV

πŸ›
JΓΆrn Huxhorn

πŸ›
KThompso

πŸ›
Kai Amundsen

πŸ›
Karel Vervaeke

πŸ›
Karl-Andero Mere

πŸ› -
Karl-Philipp Richter

πŸ› +
Karl-Philipp Richter

πŸ›
Karsten Silz

πŸ›
Kazuma Watanabe

πŸ›
Kev

πŸ›
Keve MΓΌller

πŸ›
Kevin Guerra

πŸ’»
Kevin Jones

πŸ› -
Kevin Wayne

πŸ› +
Kevin Wayne

πŸ›
Kieran Black

πŸ›
Kirill Zubov

πŸ›
Kirk Clemens

πŸ’» πŸ›
Klaus Hartl

πŸ›
Koen Van Looveren

πŸ›
Kris Scheibe

πŸ’» πŸ› -
Kunal Thanki

πŸ› +
Kunal Thanki

πŸ›
LaLucid

πŸ’»
Larry Diamond

πŸ’» πŸ›
Lars Knickrehm

πŸ›
Leo Gutierrez

πŸ›
LiGaOg

πŸ’»
Lintsi

πŸ› -
Linus Fernandes

πŸ› +
Linus Fernandes

πŸ›
Lixon Lookose

πŸ›
Logesh

πŸ›
Lorenzo Gabriele

πŸ›
LoΓ―c Ledoyen

πŸ›
Lucas Silva

πŸ›
Lucas Soncini

πŸ’» πŸ› -
Lukasz Slonina

πŸ› +
Lukasz Slonina

πŸ›
Lukebray

πŸ›
Lyor Goldstein

πŸ›
MCMicS

πŸ›
Macarse

πŸ›
Machine account for PMD

πŸ’»
Maciek Siemczyk

πŸ› -
Maikel Steneker

πŸ’» πŸ› +
Maikel Steneker

πŸ’» πŸ›
Maksim Moiseikin

πŸ›
Manfred Koch

πŸ›
Manuel Moya Ferrer

πŸ’» πŸ›
Manuel Ryan

πŸ›
Marat Vyshegorodtsev

πŸ›
Marcel HΓ€rle

πŸ› -
Marcello Fialho

πŸ› +
Marcello Fialho

πŸ›
Marcin Rataj

πŸ›
Mark Adamcin

πŸ›
Mark Hall

πŸ’» πŸ›
Mark Kolich

πŸ›
Mark Pritchard

πŸ›
Markus Rathgeb

πŸ› -
Marquis Wang

πŸ› +
Marquis Wang

πŸ›
Martin Feldsztejn

πŸ›
Martin Lehmann

πŸ›
Martin Spamer

πŸ›
Martin TarjΓ‘nyi

πŸ›
MatFl

πŸ›
Mateusz Stefanski

πŸ› -
Mathieu Gouin

πŸ› +
Mathieu Gouin

πŸ›
MatiasComercio

πŸ’» πŸ›
Matt Benson

πŸ›
Matt De Poorter

πŸ›
Matt Hargett

πŸ’» πŸ’΅
Matt Harrah

πŸ›
Matt Nelson

πŸ› -
Matthew Amos

πŸ› +
Matthew Amos

πŸ›
Matthew Duggan

πŸ›
Matthew Hall

πŸ›
MatΓ­as Fraga

πŸ’» πŸ›
Maxime Robert

πŸ’» πŸ›
MetaBF

πŸ›
Michael

πŸ› -
Michael Bell

πŸ› +
Michael Bell

πŸ›
Michael Bernstein

πŸ›
Michael Clay

πŸ›
Michael Dombrowski

πŸ›
Michael Hausegger

πŸ›
Michael Hoefer

πŸ›
Michael MΓΆbius

πŸ› -
Michael N. Lipp

πŸ› +
Michael N. Lipp

πŸ›
Michael Pellegrini

πŸ›
Michal Kordas

πŸ›
MichaΕ‚ Borek

πŸ›
MichaΕ‚ KuliΕ„ski

πŸ›
Miguel NΓΊΓ±ez DΓ­az-Montes

πŸ›
Mihai Ionut

πŸ› -
Mirek Hankus

πŸ› +
Mirek Hankus

πŸ›
Mladjan Gadzic

πŸ›
MrAngry52

πŸ›
Muminur Choudhury

πŸ›
Mykhailo Palahuta

πŸ’» πŸ›
Nagendra Kumar Singh

πŸ›
Nahuel Barrios

πŸ› -
Nathan Braun

πŸ› +
Nathan Braun

πŸ›
Nathan Reynolds

πŸ›
Nathan Reynolds

πŸ›
NathanaΓ«l

πŸ›
Naveen

πŸ’»
Nazdravi

πŸ›
Neha-Dhonde

πŸ› -
Nicholas Doyle

πŸ› +
Nicholas Doyle

πŸ›
Nick Butcher

πŸ›
Nico Gallinal

πŸ›
Nicola Dal Maso

πŸ›
Nicolas Filotto

πŸ’»
Nikita Chursin

πŸ›
Niklas Baudy

πŸ› -
Nikolas Havrikov

πŸ› +
Nikolas Havrikov

πŸ›
Nilesh Virkar

πŸ›
Nimit Patel

πŸ›
Niranjan Harpale

πŸ›
Noah Sussman

πŸ›
Noah0120

πŸ›
Noam Tamim

πŸ› -
Noel Grandin

πŸ› +
Noel Grandin

πŸ›
Olaf Haalstra

πŸ›
Oleg Pavlenko

πŸ›
Oleksii Dykov

πŸ’»
Oliver Eikemeier

πŸ›
Olivier Parent

πŸ’» πŸ›
Ollie Abbey

πŸ’» πŸ› -
OverDrone

πŸ› +
OverDrone

πŸ›
Ozan Gulle

πŸ’» πŸ›
PUNEET JAIN

πŸ›
Parbati Bose

πŸ›
Paul Berg

πŸ›
Pavel Bludov

πŸ›
Pavel Mička

πŸ› -
Pedro Nuno Santos

πŸ› +
Pedro Nuno Santos

πŸ›
Pedro Rijo

πŸ›
Pelisse Romain

πŸ’» πŸ“– πŸ›
Per Abich

πŸ’»
Pete Davids

πŸ›
Peter Bruin

πŸ›
Peter Chittum

πŸ’» πŸ› -
Peter Cudmore

πŸ› +
Peter Cudmore

πŸ›
Peter Kasson

πŸ›
Peter Kofler

πŸ›
Peter Paul Bakker

πŸ’»
Pham Hai Trung

πŸ›
Philip Graf

πŸ’» πŸ›
Philip Hachey

πŸ› -
Philippe Ozil

πŸ› +
Philippe Ozil

πŸ›
Phinehas Artemix

πŸ›
Phokham Nonava

πŸ›
Piotr SzymaΕ„ski

πŸ›
Piotrek Ε»ygieΕ‚o

πŸ’» πŸ›
Pranay Jaiswal

πŸ›
Prasad Kamath

πŸ› -
Prasanna

πŸ› +
Prasanna

πŸ›
Presh-AR

πŸ›
Puneet1726

πŸ›
Rafael CortΓͺs

πŸ›
RaheemShaik999

πŸ›
RajeshR

πŸ’» πŸ›
Ramachandra Mohan

πŸ› -
Ramel0921

πŸ› +
Ramel0921

πŸ›
Raquel Pau

πŸ›
Ravikiran Janardhana

πŸ›
Reda Benhemmouche

πŸ›
Renato Oliveira

πŸ’» πŸ›
Rich DiCroce

πŸ›
Riot R1cket

πŸ› -
Rishabh Jain

πŸ› +
Rishabh Jain

πŸ›
RishabhDeep Singh

πŸ›
Robbie Martinus

πŸ’» πŸ›
Robert Henry

πŸ›
Robert Painsi

πŸ›
Robert Russell

πŸ›
Robert SΓΆsemann

πŸ’» πŸ“– πŸ“’ πŸ› -
Robert Whitebit

πŸ› +
Robert Whitebit

πŸ›
Robin Richtsfeld

πŸ›
Robin Stocker

πŸ’» πŸ›
Robin Wils

πŸ›
RochusOest

πŸ›
Rodolfo Noviski

πŸ›
Rodrigo Casara

πŸ› -
Rodrigo Fernandes

πŸ› +
Rodrigo Fernandes

πŸ›
Roman Salvador

πŸ’» πŸ›
Ronald Blaschke

πŸ›
RΓ³bert Papp

πŸ›
Saikat Sengupta

πŸ›
Saksham Handu

πŸ›
Saladoc

πŸ› -
Salesforce Bob Lightning

πŸ› +
Salesforce Bob Lightning

πŸ›
Sam Carlberg

πŸ›
Satoshi Kubo

πŸ›
Scott Kennedy

πŸ›
Scott Wells

πŸ› πŸ’»
Scrsloota

πŸ’»
Sebastian BΓΆgl

πŸ› -
Sebastian Schuberth

πŸ› +
Sebastian Schuberth

πŸ›
Sebastian Schwarz

πŸ›
Sergey Gorbaty

πŸ›
Sergey Kozlov

πŸ›
Sergey Yanzin

πŸ’» πŸ›
Seth Wilcox

πŸ’»
Shubham

πŸ’» πŸ› -
Simon Abykov

πŸ’» +
Simon Abykov

πŸ’»
Simon Xiao

πŸ›
Srinivasan Venkatachalam

πŸ›
Stanislav Gromov

πŸ›
Stanislav Myachenkov

πŸ’»
Stefan Birkner

πŸ›
Stefan Bohn

πŸ› -
Stefan Endrullis

πŸ› +
Stefan Endrullis

πŸ›
Stefan KlΓΆss-Schuster

πŸ›
Stefan Wolf

πŸ›
Stephan H. Wissel

πŸ›
Stephen

πŸ›
Stephen Friedrich

πŸ›
Steve Babula

πŸ’» -
Stexxe

πŸ› +
Stexxe

πŸ›
Stian LΓ₯gstad

πŸ›
StuartClayton5

πŸ›
Supun Arunoda

πŸ›
Suren Abrahamyan

πŸ›
SwatiBGupta1110

πŸ›
SyedThoufich

πŸ› -
Szymon Sasin

πŸ› +
Szymon Sasin

πŸ›
T-chuangxin

πŸ›
TERAI Atsuhiro

πŸ›
TIOBE Software

πŸ’» πŸ›
Taylor Smock

πŸ›
Techeira DamiΓ‘n

πŸ’» πŸ›
Ted Husted

πŸ› -
TehBakker

πŸ› +
TehBakker

πŸ›
The Gitter Badger

πŸ›
Theodoor

πŸ›
Thiago Henrique HΓΌpner

πŸ›
Thibault Meyer

πŸ›
Thomas GΓΌttler

πŸ›
Thomas Jones-Low

πŸ› -
Thomas Smith

πŸ’» πŸ› +
Thomas Smith

πŸ’» πŸ›
ThrawnCA

πŸ›
Thunderforge

πŸ’» πŸ›
Tim van der Lippe

πŸ›
Tobias Weimer

πŸ’» πŸ›
Tom Daly

πŸ›
Tomer Figenblat

πŸ› -
Tomi De Lucca

πŸ’» πŸ› +
Tomi De Lucca

πŸ’» πŸ›
Torsten Kleiber

πŸ›
TrackerSB

πŸ›
Ullrich Hafner

πŸ›
Utku Cuhadaroglu

πŸ’» πŸ›
Valentin Brandl

πŸ›
Valeria

πŸ› -
Vasily Anisimov

πŸ› +
Vasily Anisimov

πŸ›
Vibhor Goyal

πŸ›
Vickenty Fesunov

πŸ›
Victor NoΓ«l

πŸ›
Vincent Galloy

πŸ’»
Vincent HUYNH

πŸ›
Vincent Maurin

πŸ› -
Vincent Privat

πŸ› +
Vincent Privat

πŸ›
Vishhwas

πŸ›
Vitaly

πŸ›
Vitaly Polonetsky

πŸ›
Vojtech Polivka

πŸ›
Vsevolod Zholobov

πŸ›
Vyom Yadav

πŸ’» -
Wang Shidong

πŸ› +
Wang Shidong

πŸ›
Waqas Ahmed

πŸ›
Wayne J. Earl

πŸ›
Wchenghui

πŸ›
Will Winder

πŸ›
William Brockhus

πŸ’» πŸ›
Wilson Kurniawan

πŸ› -
Wim Deblauwe

πŸ› +
Wim Deblauwe

πŸ›
Woongsik Choi

πŸ›
XenoAmess

πŸ’» πŸ›
Yang

πŸ’»
YaroslavTER

πŸ›
Young Chan

πŸ’» πŸ›
YuJin Kim

πŸ› -
Yuri Dolzhenko

πŸ› +
Yuri Dolzhenko

πŸ›
Yurii Dubinka

πŸ›
Zoltan Farkas

πŸ›
Zustin

πŸ›
aaronhurst-google

πŸ›
alexmodis

πŸ›
andreoss

πŸ› -
andrey81inmd

πŸ’» πŸ› +
andrey81inmd

πŸ’» πŸ›
anicoara

πŸ›
arunprasathav

πŸ›
asiercamara

πŸ›
astillich-igniti

πŸ’»
avesolovksyy

πŸ›
avishvat

πŸ› -
avivmu

πŸ› +
avivmu

πŸ›
axelbarfod1

πŸ›
b-3-n

πŸ›
balbhadra9

πŸ›
base23de

πŸ›
bergander

πŸ›
berkam

πŸ’» πŸ› -
breizh31

πŸ› +
breizh31

πŸ›
caesarkim

πŸ›
carolyujing

πŸ›
cesares-basilico

πŸ›
chrite

πŸ›
cobratbq

πŸ›
coladict

πŸ› -
cosmoJFH

πŸ› +
cosmoJFH

πŸ›
cristalp

πŸ›
crunsk

πŸ›
cwholmes

πŸ›
cyberjj999

πŸ›
cyw3

πŸ›
d1ss0nanz

πŸ› -
dalizi007

πŸ’» +
dalizi007

πŸ’»
danbrycefairsailcom

πŸ›
dariansanity

πŸ›
darrenmiliband

πŸ›
davidburstrom

πŸ›
dbirkman-paloalto

πŸ›
deepak-patra

πŸ› -
dependabot[bot]

πŸ’» πŸ› +
dependabot[bot]

πŸ’» πŸ›
dinesh150

πŸ›
diziaq

πŸ›
dreaminpast123

πŸ›
duanyanan

πŸ›
dutt-sanjay

πŸ›
dylanleung

πŸ› -
dzeigler

πŸ› +
dzeigler

πŸ›
ekkirala

πŸ›
emersonmoura

πŸ›
fairy

πŸ›
filiprafalowicz

πŸ’»
foxmason

πŸ›
frankegabor

πŸ› -
frankl

πŸ› +
frankl

πŸ›
freafrea

πŸ›
fsapatin

πŸ›
gracia19

πŸ›
guo fei

πŸ›
gurmsc5

πŸ›
gwilymatgearset

πŸ’» πŸ› -
haigsn

πŸ› +
haigsn

πŸ›
hemanshu070

πŸ›
henrik242

πŸ›
hongpuwu

πŸ›
hvbtup

πŸ’» πŸ›
igniti GmbH

πŸ›
ilovezfs

πŸ› -
itaigilo

πŸ› +
itaigilo

πŸ›
jakivey32

πŸ›
jbennett2091

πŸ›
jcamerin

πŸ›
jkeener1

πŸ›
jmetertea

πŸ›
johnra2

πŸ’» -
josemanuelrolon

πŸ’» πŸ› +
josemanuelrolon

πŸ’» πŸ›
kabroxiko

πŸ’» πŸ›
karwer

πŸ›
kaulonline

πŸ›
kdaemonv

πŸ›
kenji21

πŸ’» πŸ›
kfranic

πŸ› -
khalidkh

πŸ› +
khalidkh

πŸ›
krzyk

πŸ›
lasselindqvist

πŸ›
lgemeinhardt

πŸ›
lihuaib

πŸ›
lonelyma1021

πŸ›
lpeddy

πŸ› -
lujiefsi

πŸ’» +
lujiefsi

πŸ’»
lukelukes

πŸ’»
lyriccoder

πŸ›
marcelmore

πŸ›
matchbox

πŸ›
matthiaskraaz

πŸ›
meandonlyme

πŸ› -
mikesive

πŸ› +
mikesive

πŸ›
milossesic

πŸ›
mriddell95

πŸ›
mrlzh

πŸ›
msloan

πŸ›
mucharlaravalika

πŸ›
mvenneman

πŸ› -
nareshl119

πŸ› +
nareshl119

πŸ›
nicolas-harraudeau-sonarsource

πŸ›
noerremark

πŸ›
novsirion

πŸ›
oggboy

πŸ›
oinume

πŸ›
orimarko

πŸ’» πŸ› -
pallavi agarwal

πŸ› +
pallavi agarwal

πŸ›
parksungrin

πŸ›
patpatpat123

πŸ›
patriksevallius

πŸ›
pbrajesh1

πŸ›
phoenix384

πŸ›
piotrszymanski-sc

πŸ’» -
plan3d

πŸ› +
plan3d

πŸ›
poojasix

πŸ›
prabhushrikant

πŸ›
pujitha8783

πŸ›
r-r-a-j

πŸ›
raghujayjunk

πŸ›
rajeshveera

πŸ› -
rajeswarreddy88

πŸ› +
rajeswarreddy88

πŸ›
recdevs

πŸ›
reudismam

πŸ’» πŸ›
rijkt

πŸ›
rillig-tk

πŸ›
rmohan20

πŸ’» πŸ›
rxmicro

πŸ› -
ryan-gustafson

πŸ’» πŸ› +
ryan-gustafson

πŸ’» πŸ›
sabi0

πŸ›
scais

πŸ›
sebbASF

πŸ›
sergeygorbaty

πŸ’»
shilko2013

πŸ›
shiomiyan

πŸ“– -
simeonKondr

πŸ› +
simeonKondr

πŸ›
snajberk

πŸ›
sniperrifle2004

πŸ›
snuyanzin

πŸ› πŸ’»
sratz

πŸ›
stonio

πŸ›
sturton

πŸ’» πŸ› -
sudharmohan

πŸ› +
sudharmohan

πŸ›
suruchidawar

πŸ›
svenfinitiv

πŸ›
tashiscool

πŸ›
test-git-hook

πŸ›
testation21

πŸ’» πŸ›
thanosa

πŸ› -
tiandiyixian

πŸ› +
tiandiyixian

πŸ›
tobwoerk

πŸ›
tprouvot

πŸ›
trentchilders

πŸ›
triandicAnt

πŸ›
trishul14

πŸ›
tsui

πŸ› -
winhkey

πŸ› +
winhkey

πŸ›
witherspore

πŸ›
wjljack

πŸ›
wuchiuwong

πŸ›
xingsong

πŸ›
xioayuge

πŸ›
xnYi9wRezm

πŸ’» πŸ› -
xuanuy

πŸ› +
xuanuy

πŸ›
xyf0921

πŸ›
yalechen-cyw3

πŸ›
yasuharu-sato

πŸ›
zenglian

πŸ›
zgrzyt93

πŸ’» πŸ›
zh3ng

πŸ› -
zt_soft

πŸ› +
zt_soft

πŸ›
ztt79

πŸ›
zzzzfeng

πŸ›
ÁrpÑd MagosÑnyi

πŸ› From 67bab1609179fbc4168a6202b3e86b3032234430 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Wed, 24 Aug 2022 17:59:57 +0200 Subject: [PATCH 24/45] [doc] Update release notes (#4092) --- docs/pages/release_notes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index b8f8783555..3cfcae03f1 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -20,5 +20,7 @@ This is a {{ site.pmd.release_type }} release. ### External Contributions +* [#4092](https://github.com/pmd/pmd/pull/4092): \[apex] Implement ApexQualifiableNode for ASTUserEnum - [@aaronhurst-google](https://github.com/aaronhurst-google) + {% endtocmaker %} From 4847470db0d898b6dcf622398b1710d8fd9343f7 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Wed, 24 Aug 2022 18:00:17 +0200 Subject: [PATCH 25/45] Update @aaronhurst-google as a contributor --- .all-contributorsrc | 3 ++- docs/pages/pmd/projectdocs/credits.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 99708783e8..0c84c82931 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1053,7 +1053,8 @@ "avatar_url": "https://avatars.githubusercontent.com/u/86377278?v=4", "profile": "https://github.com/aaronhurst-google", "contributions": [ - "bug" + "bug", + "code" ] }, { diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index 37788cf5f7..d8b9a5408b 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -736,7 +736,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Zoltan Farkas

πŸ›
Zustin

πŸ› -
aaronhurst-google

πŸ› +
aaronhurst-google

πŸ› πŸ’»
alexmodis

πŸ›
andreoss

πŸ›
andrey81inmd

πŸ’» πŸ› From 5d5fbd5b21ce3e016b7952676c2b7d79bda51a6b Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Wed, 24 Aug 2022 19:15:56 +0200 Subject: [PATCH 26/45] Bump maven-pmd-plugin from 3.17.0 to 3.18.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1f7aa9e9b7..5b215e903e 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ 3.0.0-M5 9.3 3.1.2 - 3.17.0 + 3.18.0 1.10.12 3.2.0 4.7.2 From 804e4d188afcffb2b430ea3d079ee0e12f555cca Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Wed, 24 Aug 2022 19:41:08 +0200 Subject: [PATCH 27/45] [ci] Allow building of branch "experimental-apex-parser" It should build like a pull request --- .ci/build.sh | 9 +++++++++ .github/workflows/build.yml | 1 + 2 files changed, 10 insertions(+) diff --git a/.ci/build.sh b/.ci/build.sh index 92f7f6472a..6c6b657654 100755 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -27,6 +27,15 @@ function build() { pmd_ci_utils_determine_build_env pmd/pmd echo + if ! pmd_ci_utils_is_fork_or_pull_request; then + if [ "${PMD_CI_BRANCH}" = "experimental-apex-parser" ]; then + pmd_ci_log_group_start "Build with mvnw" + ./mvnw clean install --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}" + pmd_ci_log_group_end + exit 0 + fi + fi + if pmd_ci_utils_is_fork_or_pull_request; then pmd_ci_log_group_start "Build with mvnw" ./mvnw clean install --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1f64ba25cb..f94319eb05 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,7 @@ on: branches: - main - master + - experimental-apex-parser tags: - '**' pull_request: From e0b9965c27f8663135d4be915b850184c58927e7 Mon Sep 17 00:00:00 2001 From: tprouvot <35368290+tprouvot@users.noreply.github.com> Date: Thu, 25 Aug 2022 10:46:47 +0200 Subject: [PATCH 28/45] Update pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java Co-authored-by: Andreas Dangel --- .../bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java index 2e0d717b60..71f2ea9b99 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java @@ -43,7 +43,7 @@ public class ApexUnitTestClassShouldHaveAssertsRule extends AbstractApexUnitTest ASSERT_METHODS.add("assert.isfalse"); ASSERT_METHODS.add("assert.isinstanceoftype"); ASSERT_METHODS.add("assert.isnotinstanceoftype"); - ASSERT_METHODS.add("assert.isnnull"); + ASSERT_METHODS.add("assert.isnull"); ASSERT_METHODS.add("assert.isnotnull"); ASSERT_METHODS.add("assert.istrue"); // Fully-qualified variants...rare but still valid/possible From d5098ca115de49e450be43415d238c37f0d13987 Mon Sep 17 00:00:00 2001 From: tprouvot <35368290+tprouvot@users.noreply.github.com> Date: Thu, 25 Aug 2022 12:15:30 +0200 Subject: [PATCH 29/45] Update pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml Co-authored-by: Andreas Dangel --- .../bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml index b78a6c86f7..471822ad5a 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml @@ -117,7 +117,7 @@ public class Foo {
- #4096 [apex] api 56.0 ApexAssertionsShouldIncludeMessage and new apex class : Assert + [apex] ApexUnitTestClassShouldHaveAssertsRule: Support new Assert class (Apex v56.0) #4097 0 Date: Thu, 25 Aug 2022 12:17:32 +0200 Subject: [PATCH 30/45] Fix typo --- ...pexUnitTestClassShouldHaveAssertsRule.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java index 2e0d717b60..d45f93c397 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java @@ -56,17 +56,20 @@ public class ApexUnitTestClassShouldHaveAssertsRule extends AbstractApexUnitTest ASSERT_METHODS.add("system.assert.isfalse"); ASSERT_METHODS.add("system.assert.isinstanceoftype"); ASSERT_METHODS.add("system.assert.isnotinstanceoftype"); - ASSERT_METHODS.add("system.assert.isnnull"); + ASSERT_METHODS.add("system.assert.isnull"); ASSERT_METHODS.add("system.assert.isnotnull"); ASSERT_METHODS.add("system.assert.istrue"); } - // Using a string property instead of a regex property to ensure that the compiled pattern can be case-insensitive - private static final PropertyDescriptor ADDITIONAL_ASSERT_METHOD_PATTERN_DESCRIPTOR = - stringProperty("additionalAssertMethodPattern") - .desc("A regular expression for one or more custom test assertion method patterns.").defaultValue("").build(); + // Using a string property instead of a regex property to ensure that the + // compiled pattern can be case-insensitive + private static final PropertyDescriptor ADDITIONAL_ASSERT_METHOD_PATTERN_DESCRIPTOR = stringProperty( + "additionalAssertMethodPattern") + .desc("A regular expression for one or more custom test assertion method patterns.").defaultValue("") + .build(); - // A simple compiled pattern cache to ensure that we only ever try to compile the configured pattern once for a given run + // A simple compiled pattern cache to ensure that we only ever try to compile + // the configured pattern once for a given run private Optional compiledAdditionalAssertMethodPattern = null; public ApexUnitTestClassShouldHaveAssertsRule() { @@ -99,7 +102,8 @@ public class ApexUnitTestClassShouldHaveAssertsRule extends AbstractApexUnitTest } } - // If we didn't find assert method invocations the simple way and we have a configured pattern, try it + // If we didn't find assert method invocations the simple way and we have a + // configured pattern, try it if (!isAssertFound) { final String additionalAssertMethodPattern = getProperty(ADDITIONAL_ASSERT_METHOD_PATTERN_DESCRIPTOR); final Pattern compiledPattern = getCompiledAdditionalAssertMethodPattern(additionalAssertMethodPattern); @@ -123,12 +127,15 @@ public class ApexUnitTestClassShouldHaveAssertsRule extends AbstractApexUnitTest private Pattern getCompiledAdditionalAssertMethodPattern(String additionalAssertMethodPattern) { if (StringUtils.isNotBlank(additionalAssertMethodPattern)) { - // Check for presence first since we will cache a null value for patterns that don't compile + // Check for presence first since we will cache a null value for patterns that + // don't compile if (compiledAdditionalAssertMethodPattern == null) { try { - compiledAdditionalAssertMethodPattern = Optional.of(Pattern.compile(additionalAssertMethodPattern, Pattern.CASE_INSENSITIVE)); + compiledAdditionalAssertMethodPattern = Optional + .of(Pattern.compile(additionalAssertMethodPattern, Pattern.CASE_INSENSITIVE)); } catch (IllegalArgumentException e) { - // Cache a null compiled pattern so that we won't try to compile this one again during the run + // Cache a null compiled pattern so that we won't try to compile this one again + // during the run compiledAdditionalAssertMethodPattern = Optional.ofNullable(null); throw e; } From 2e9f25c8ba8ca963660dd604e81fe54fa625e508 Mon Sep 17 00:00:00 2001 From: Thomas Prouvot Date: Thu, 25 Aug 2022 12:17:51 +0200 Subject: [PATCH 31/45] PR review comment --- .../bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml index b78a6c86f7..f08128a6f7 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml @@ -102,8 +102,8 @@ public class Foo { Date: Thu, 25 Aug 2022 12:18:15 +0200 Subject: [PATCH 32/45] Add new Assert methods to ApexAssertionsShouldIncludeMessageRule --- ...pexAssertionsShouldIncludeMessageRule.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageRule.java index 679935d617..fa50f75334 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageRule.java @@ -12,17 +12,39 @@ public class ApexAssertionsShouldIncludeMessageRule extends AbstractApexUnitTest private static final String ASSERT = "System.assert"; private static final String ASSERT_EQUALS = "System.assertEquals"; private static final String ASSERT_NOT_EQUALS = "System.assertNotEquals"; + private static final String ARE_EQUAL = "Assert.areEqual"; + private static final String ARE_NOT_EQUAL = "Assert.areNotEqual"; + private static final String IS_FALSE = "Assert.isFalse"; + private static final String FAIL = "Assert.fail"; + private static final String IS_INSTANCE_OF_TYPE = "Assert.isInstanceOfType"; + private static final String IS_NOT_INSTANCE_OF_TYPE = "Assert.isNotInstanceOfType"; + private static final String IS_NOT_NULL = "Assert.isNotNull"; + private static final String IS_NULL = "Assert.isNull"; + private static final String IS_TRUE = "Assert.isTrue"; @Override public Object visit(ASTMethodCallExpression node, Object data) { String methodName = node.getFullMethodName(); - if (ASSERT.equalsIgnoreCase(methodName) && node.getNumChildren() == 2) { + if (FAIL.equalsIgnoreCase(methodName) && node.getNumChildren() == 1) { + addViolationWithMessage(data, node, + "''{0}'' should have 1 parameters.", + new Object[] { FAIL }); + } else if ((ASSERT.equalsIgnoreCase(methodName) + || IS_FALSE.equalsIgnoreCase(methodName) + || IS_NOT_NULL.equalsIgnoreCase(methodName) + || IS_NULL.equalsIgnoreCase(methodName) + || IS_TRUE.equalsIgnoreCase(methodName)) + && node.getNumChildren() == 2) { addViolationWithMessage(data, node, "''{0}'' should have 2 parameters.", new Object[] { ASSERT }); } else if ((ASSERT_EQUALS.equalsIgnoreCase(methodName) - || ASSERT_NOT_EQUALS.equalsIgnoreCase(methodName)) + || ASSERT_NOT_EQUALS.equalsIgnoreCase(methodName) + || ARE_EQUAL.equalsIgnoreCase(methodName) + || ARE_NOT_EQUAL.equalsIgnoreCase(methodName) + || IS_INSTANCE_OF_TYPE.equalsIgnoreCase(methodName) + || IS_NOT_INSTANCE_OF_TYPE.equalsIgnoreCase(methodName)) && node.getNumChildren() == 3) { addViolationWithMessage(data, node, "''{0}'' should have 3 parameters.", From d6194be47b39cb7f41b665ceb08e5b4e25d82e95 Mon Sep 17 00:00:00 2001 From: Thomas Prouvot Date: Thu, 25 Aug 2022 15:31:13 +0200 Subject: [PATCH 33/45] Add tests for new methods --- .../ApexUnitTestClassShouldHaveAsserts.xml | 50 +++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml index 048170d3ad..0ce6d81f0f 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml @@ -122,9 +122,53 @@ public class Foo { From ac94df9e17f6778967cb3e63516e9c0cf7260e80 Mon Sep 17 00:00:00 2001 From: Thomas Prouvot Date: Thu, 25 Aug 2022 15:34:54 +0200 Subject: [PATCH 34/45] Update add violation parameters to macth with new tests --- .../bestpractices/ApexAssertionsShouldIncludeMessageRule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageRule.java index fa50f75334..2919206121 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageRule.java @@ -38,7 +38,7 @@ public class ApexAssertionsShouldIncludeMessageRule extends AbstractApexUnitTest && node.getNumChildren() == 2) { addViolationWithMessage(data, node, "''{0}'' should have 2 parameters.", - new Object[] { ASSERT }); + new Object[] { methodName }); } else if ((ASSERT_EQUALS.equalsIgnoreCase(methodName) || ASSERT_NOT_EQUALS.equalsIgnoreCase(methodName) || ARE_EQUAL.equalsIgnoreCase(methodName) From 065b4b80835c9d27d96516cabbbd3d761709a6ac Mon Sep 17 00:00:00 2001 From: Thomas Prouvot Date: Thu, 25 Aug 2022 15:44:18 +0200 Subject: [PATCH 35/45] Remove param message not mandatory in this test --- .../xml/ApexUnitTestClassShouldHaveAsserts.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml index 0ce6d81f0f..1e16256b0a 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml @@ -124,18 +124,18 @@ public class Foo { public class Foo { public static testAreEqual void testSomething() { String sub = 'abcde'.substring(2); - Assert.areEqual('cde', sub, 'Expected characters after first two'); + Assert.areEqual('cde', sub); } public static testAreNotEqual void testSomething() { String sub = 'abcde'.substring(2); - Assert.areNotEqual('xyz', sub, 'Characters not expected after first two'); + Assert.areNotEqual('xyz', sub); } public static testFail void testSomething() { try { SomeClass.methodUnderTest(); - Assert.fail('DmlException Expected'); + Assert.fail(); } catch (DmlException ex) { // Add assertions here about the expected exception } @@ -143,7 +143,7 @@ public class Foo { public static testIsFalse void testSomething() { Boolean containsCode = 'Salesforce'.contains('code'); - Assert.isFalse(containsCode, 'No code'); + Assert.isFalse(containsCode); } public static testIsInstanceOf void testSomething() { @@ -153,22 +153,22 @@ public class Foo { public static testIsNotInstanceOf void testSomething() { Contact con = new Contact(); - Assert.isNotInstanceOfType(con, Account.class, 'Not expected type'); + Assert.isNotInstanceOfType(con, Account.class); } public static testIsNotNull void testSomething() { String myString = 'value'; - Assert.isNotNull(myString, 'myString should not be null'); + Assert.isNotNull(myString); } public static testIsNull void testSomething() { String myString = null; - Assert.isNull(myString, 'String should be null'); + Assert.isNull(myString); } public static testIsTrue void testSomething() { Boolean containsForce = 'Salesforce'.contains('force'); - Assert.isTrue(containsForce, 'Contains force'); + Assert.isTrue(containsForce); } } ]]> From d73cdcc193689fa31f524dabd0378ac0e55b324d Mon Sep 17 00:00:00 2001 From: Thomas Prouvot Date: Thu, 25 Aug 2022 15:44:37 +0200 Subject: [PATCH 36/45] Ad new tests for Assert method class --- .../ApexAssertionsShouldIncludeMessage.xml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexAssertionsShouldIncludeMessage.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexAssertionsShouldIncludeMessage.xml index 71790b39db..ac608c7529 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexAssertionsShouldIncludeMessage.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexAssertionsShouldIncludeMessage.xml @@ -49,4 +49,62 @@ public class Foo { } ]]> + + + [apex] Support new Assert class (Apex v56.0) #4097 + 0 + + From 29c4e996fb0be080dea93df56bb4f9a438ad3e4e Mon Sep 17 00:00:00 2001 From: Thomas Prouvot Date: Thu, 25 Aug 2022 16:54:11 +0200 Subject: [PATCH 37/45] Increase test coverage --- .../ApexAssertionsShouldIncludeMessage.xml | 77 +++++++++++-------- .../ApexUnitTestClassShouldHaveAsserts.xml | 31 +++++--- 2 files changed, 63 insertions(+), 45 deletions(-) diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexAssertionsShouldIncludeMessage.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexAssertionsShouldIncludeMessage.xml index ac608c7529..f05e9124da 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexAssertionsShouldIncludeMessage.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexAssertionsShouldIncludeMessage.xml @@ -50,61 +50,70 @@ public class Foo { ]]> - + [apex] Support new Assert class (Apex v56.0) #4097 0 - + ]]> diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml index 1e16256b0a..28ba29690b 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml @@ -122,51 +122,60 @@ public class Foo { Date: Sun, 28 Aug 2022 15:00:55 +0200 Subject: [PATCH 38/45] Add MegaLinter in the list of integrations --- docs/pages/pmd/userdocs/tools/ci.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/pages/pmd/userdocs/tools/ci.md b/docs/pages/pmd/userdocs/tools/ci.md index f12b366935..513374f26e 100644 --- a/docs/pages/pmd/userdocs/tools/ci.md +++ b/docs/pages/pmd/userdocs/tools/ci.md @@ -28,4 +28,10 @@ result of the PMD maven plugin. See [Other Tools / Integrations](pmd_userdocs_tools.html#github-actions) +## MegaLinter + +[πŸ¦™ Mega-Linter](https://oxsecurity.github.io/megalinter/latest/) analyzes 50 languages, 22 formats, 21 tooling formats, excessive copy-pastes, spelling mistakes and security issues in your repository sources with a GitHub Action, other CI tools or locally. + +It [natively embeds PMD](https://oxsecurity.github.io/megalinter/latest/descriptors/java_pmd/). + From b83ca316e1863f5d3321dffa47afe07278a0f621 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 29 Aug 2022 18:33:17 +0200 Subject: [PATCH 39/45] [doc] Update release notes (#4104) --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 7fcbc0c973..8127c2c6a0 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -41,6 +41,7 @@ This is a {{ site.pmd.release_type }} release. * [#4081](https://github.com/pmd/pmd/pull/4081): \[apex] Remove Jorje leaks outside `ast` package - [@eklimo](https://github.com/eklimo) * [#4083](https://github.com/pmd/pmd/pull/4083): \[java] UnnecessaryImport false positive for on-demand imports of nested classes (fix for #4082) - [@abyss638](https://github.com/abyss638) * [#4092](https://github.com/pmd/pmd/pull/4092): \[apex] Implement ApexQualifiableNode for ASTUserEnum - [@aaronhurst-google](https://github.com/aaronhurst-google) +* [#4104](https://github.com/pmd/pmd/pull/4104): \[doc] Add MegaLinter in the list of integrations - [@nvuillam](https://github.com/nvuillam) {% endtocmaker %} From bb81bd785710a94546f63b6bba3075bfb0c0bbe6 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 29 Aug 2022 18:34:52 +0200 Subject: [PATCH 40/45] Add @nvuillam as a contributor --- .all-contributorsrc | 9 +++ docs/pages/pmd/projectdocs/credits.md | 101 +++++++++++++------------- 2 files changed, 60 insertions(+), 50 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 87892e6d84..e87abaa8ae 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -6788,6 +6788,15 @@ "bug", "code" ] + }, + { + "login": "nvuillam", + "name": "Nicolas Vuillamy", + "avatar_url": "https://avatars.githubusercontent.com/u/17500430?v=4", + "profile": "https://github.com/nvuillam", + "contributions": [ + "doc" + ] } ], "contributorsPerLine": 7, diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index db79a432d7..ffb67b7978 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -514,451 +514,452 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Nico Gallinal

πŸ›
Nicola Dal Maso

πŸ›
Nicolas Filotto

πŸ’» +
Nicolas Vuillamy

πŸ“–
Nikita Chursin

πŸ› -
Niklas Baudy

πŸ› +
Niklas Baudy

πŸ›
Nikolas Havrikov

πŸ›
Nilesh Virkar

πŸ›
Nimit Patel

πŸ›
Niranjan Harpale

πŸ›
Noah Sussman

πŸ›
Noah0120

πŸ› -
Noam Tamim

πŸ› +
Noam Tamim

πŸ›
Noel Grandin

πŸ›
Olaf Haalstra

πŸ›
Oleg Pavlenko

πŸ›
Oleksii Dykov

πŸ’»
Oliver Eikemeier

πŸ›
Olivier Parent

πŸ’» πŸ› -
Ollie Abbey

πŸ’» πŸ› +
Ollie Abbey

πŸ’» πŸ›
OverDrone

πŸ›
Ozan Gulle

πŸ’» πŸ›
PUNEET JAIN

πŸ›
Parbati Bose

πŸ›
Paul Berg

πŸ›
Pavel Bludov

πŸ› -
Pavel Mička

πŸ› +
Pavel Mička

πŸ›
Pedro Nuno Santos

πŸ›
Pedro Rijo

πŸ›
Pelisse Romain

πŸ’» πŸ“– πŸ›
Per Abich

πŸ’»
Pete Davids

πŸ›
Peter Bruin

πŸ› -
Peter Chittum

πŸ’» πŸ› +
Peter Chittum

πŸ’» πŸ›
Peter Cudmore

πŸ›
Peter Kasson

πŸ›
Peter Kofler

πŸ›
Peter Paul Bakker

πŸ’»
Pham Hai Trung

πŸ›
Philip Graf

πŸ’» πŸ› -
Philip Hachey

πŸ› +
Philip Hachey

πŸ›
Philippe Ozil

πŸ›
Phinehas Artemix

πŸ›
Phokham Nonava

πŸ›
Piotr SzymaΕ„ski

πŸ›
Piotrek Ε»ygieΕ‚o

πŸ’» πŸ›
Pranay Jaiswal

πŸ› -
Prasad Kamath

πŸ› +
Prasad Kamath

πŸ›
Prasanna

πŸ›
Presh-AR

πŸ›
Puneet1726

πŸ›
Rafael CortΓͺs

πŸ›
RaheemShaik999

πŸ›
RajeshR

πŸ’» πŸ› -
Ramachandra Mohan

πŸ› +
Ramachandra Mohan

πŸ›
Ramel0921

πŸ›
Raquel Pau

πŸ›
Ravikiran Janardhana

πŸ›
Reda Benhemmouche

πŸ›
Renato Oliveira

πŸ’» πŸ›
Rich DiCroce

πŸ› -
Riot R1cket

πŸ› +
Riot R1cket

πŸ›
Rishabh Jain

πŸ›
RishabhDeep Singh

πŸ›
Robbie Martinus

πŸ’» πŸ›
Robert Henry

πŸ›
Robert Painsi

πŸ›
Robert Russell

πŸ› -
Robert SΓΆsemann

πŸ’» πŸ“– πŸ“’ πŸ› +
Robert SΓΆsemann

πŸ’» πŸ“– πŸ“’ πŸ›
Robert Whitebit

πŸ›
Robin Richtsfeld

πŸ›
Robin Stocker

πŸ’» πŸ›
Robin Wils

πŸ›
RochusOest

πŸ›
Rodolfo Noviski

πŸ› -
Rodrigo Casara

πŸ› +
Rodrigo Casara

πŸ›
Rodrigo Fernandes

πŸ›
Roman Salvador

πŸ’» πŸ›
Ronald Blaschke

πŸ›
RΓ³bert Papp

πŸ›
Saikat Sengupta

πŸ›
Saksham Handu

πŸ› -
Saladoc

πŸ› +
Saladoc

πŸ›
Salesforce Bob Lightning

πŸ›
Sam Carlberg

πŸ›
Satoshi Kubo

πŸ›
Scott Kennedy

πŸ›
Scott Wells

πŸ› πŸ’»
Scrsloota

πŸ’» -
Sebastian BΓΆgl

πŸ› +
Sebastian BΓΆgl

πŸ›
Sebastian Schuberth

πŸ›
Sebastian Schwarz

πŸ›
Sergey Gorbaty

πŸ›
Sergey Kozlov

πŸ›
Sergey Yanzin

πŸ’» πŸ›
Seth Wilcox

πŸ’» -
Shubham

πŸ’» πŸ› +
Shubham

πŸ’» πŸ›
Simon Abykov

πŸ’»
Simon Xiao

πŸ›
Srinivasan Venkatachalam

πŸ›
Stanislav Gromov

πŸ›
Stanislav Myachenkov

πŸ’»
Stefan Birkner

πŸ› -
Stefan Bohn

πŸ› +
Stefan Bohn

πŸ›
Stefan Endrullis

πŸ›
Stefan KlΓΆss-Schuster

πŸ›
Stefan Wolf

πŸ›
Stephan H. Wissel

πŸ›
Stephen

πŸ›
Stephen Friedrich

πŸ› -
Steve Babula

πŸ’» +
Steve Babula

πŸ’»
Stexxe

πŸ›
Stian LΓ₯gstad

πŸ›
StuartClayton5

πŸ›
Supun Arunoda

πŸ›
Suren Abrahamyan

πŸ›
SwatiBGupta1110

πŸ› -
SyedThoufich

πŸ› +
SyedThoufich

πŸ›
Szymon Sasin

πŸ›
T-chuangxin

πŸ›
TERAI Atsuhiro

πŸ›
TIOBE Software

πŸ’» πŸ›
Taylor Smock

πŸ›
Techeira DamiΓ‘n

πŸ’» πŸ› -
Ted Husted

πŸ› +
Ted Husted

πŸ›
TehBakker

πŸ›
The Gitter Badger

πŸ›
Theodoor

πŸ›
Thiago Henrique HΓΌpner

πŸ›
Thibault Meyer

πŸ›
Thomas GΓΌttler

πŸ› -
Thomas Jones-Low

πŸ› +
Thomas Jones-Low

πŸ›
Thomas Smith

πŸ’» πŸ›
ThrawnCA

πŸ›
Thunderforge

πŸ’» πŸ›
Tim van der Lippe

πŸ›
Tobias Weimer

πŸ’» πŸ›
Tom Daly

πŸ› -
Tomer Figenblat

πŸ› +
Tomer Figenblat

πŸ›
Tomi De Lucca

πŸ’» πŸ›
Torsten Kleiber

πŸ›
TrackerSB

πŸ›
Ullrich Hafner

πŸ›
Utku Cuhadaroglu

πŸ’» πŸ›
Valentin Brandl

πŸ› -
Valeria

πŸ› +
Valeria

πŸ›
Vasily Anisimov

πŸ›
Vibhor Goyal

πŸ›
Vickenty Fesunov

πŸ›
Victor NoΓ«l

πŸ›
Vincent Galloy

πŸ’»
Vincent HUYNH

πŸ› -
Vincent Maurin

πŸ› +
Vincent Maurin

πŸ›
Vincent Privat

πŸ›
Vishhwas

πŸ›
Vitaly

πŸ›
Vitaly Polonetsky

πŸ›
Vojtech Polivka

πŸ›
Vsevolod Zholobov

πŸ› -
Vyom Yadav

πŸ’» +
Vyom Yadav

πŸ’»
Wang Shidong

πŸ›
Waqas Ahmed

πŸ›
Wayne J. Earl

πŸ›
Wchenghui

πŸ›
Will Winder

πŸ›
William Brockhus

πŸ’» πŸ› -
Wilson Kurniawan

πŸ› +
Wilson Kurniawan

πŸ›
Wim Deblauwe

πŸ›
Woongsik Choi

πŸ›
XenoAmess

πŸ’» πŸ›
Yang

πŸ’»
YaroslavTER

πŸ›
Young Chan

πŸ’» πŸ› -
YuJin Kim

πŸ› +
YuJin Kim

πŸ›
Yuri Dolzhenko

πŸ›
Yurii Dubinka

πŸ›
Zoltan Farkas

πŸ›
Zustin

πŸ›
aaronhurst-google

πŸ› πŸ’»
alexmodis

πŸ› -
andreoss

πŸ› +
andreoss

πŸ›
andrey81inmd

πŸ’» πŸ›
anicoara

πŸ›
arunprasathav

πŸ›
asiercamara

πŸ›
astillich-igniti

πŸ’»
avesolovksyy

πŸ› -
avishvat

πŸ› +
avishvat

πŸ›
avivmu

πŸ›
axelbarfod1

πŸ›
b-3-n

πŸ›
balbhadra9

πŸ›
base23de

πŸ›
bergander

πŸ› -
berkam

πŸ’» πŸ› +
berkam

πŸ’» πŸ›
breizh31

πŸ›
caesarkim

πŸ›
carolyujing

πŸ›
cesares-basilico

πŸ›
chrite

πŸ›
cobratbq

πŸ› -
coladict

πŸ› +
coladict

πŸ›
cosmoJFH

πŸ›
cristalp

πŸ›
crunsk

πŸ›
cwholmes

πŸ›
cyberjj999

πŸ›
cyw3

πŸ› -
d1ss0nanz

πŸ› +
d1ss0nanz

πŸ›
dalizi007

πŸ’»
danbrycefairsailcom

πŸ›
dariansanity

πŸ›
darrenmiliband

πŸ›
davidburstrom

πŸ›
dbirkman-paloalto

πŸ› -
deepak-patra

πŸ› +
deepak-patra

πŸ›
dependabot[bot]

πŸ’» πŸ›
dinesh150

πŸ›
diziaq

πŸ›
dreaminpast123

πŸ›
duanyanan

πŸ›
dutt-sanjay

πŸ› -
dylanleung

πŸ› +
dylanleung

πŸ›
dzeigler

πŸ›
ekkirala

πŸ›
emersonmoura

πŸ›
fairy

πŸ›
filiprafalowicz

πŸ’»
foxmason

πŸ› -
frankegabor

πŸ› +
frankegabor

πŸ›
frankl

πŸ›
freafrea

πŸ›
fsapatin

πŸ›
gracia19

πŸ›
guo fei

πŸ›
gurmsc5

πŸ› -
gwilymatgearset

πŸ’» πŸ› +
gwilymatgearset

πŸ’» πŸ›
haigsn

πŸ›
hemanshu070

πŸ›
henrik242

πŸ›
hongpuwu

πŸ›
hvbtup

πŸ’» πŸ›
igniti GmbH

πŸ› -
ilovezfs

πŸ› +
ilovezfs

πŸ›
itaigilo

πŸ›
jakivey32

πŸ›
jbennett2091

πŸ›
jcamerin

πŸ›
jkeener1

πŸ›
jmetertea

πŸ› -
johnra2

πŸ’» +
johnra2

πŸ’»
josemanuelrolon

πŸ’» πŸ›
kabroxiko

πŸ’» πŸ›
karwer

πŸ›
kaulonline

πŸ›
kdaemonv

πŸ›
kenji21

πŸ’» πŸ› -
kfranic

πŸ› +
kfranic

πŸ›
khalidkh

πŸ›
krzyk

πŸ›
lasselindqvist

πŸ›
lgemeinhardt

πŸ›
lihuaib

πŸ›
lonelyma1021

πŸ› -
lpeddy

πŸ› +
lpeddy

πŸ›
lujiefsi

πŸ’»
lukelukes

πŸ’»
lyriccoder

πŸ›
marcelmore

πŸ›
matchbox

πŸ›
matthiaskraaz

πŸ› -
meandonlyme

πŸ› +
meandonlyme

πŸ›
mikesive

πŸ›
milossesic

πŸ›
mriddell95

πŸ›
mrlzh

πŸ›
msloan

πŸ›
mucharlaravalika

πŸ› -
mvenneman

πŸ› +
mvenneman

πŸ›
nareshl119

πŸ›
nicolas-harraudeau-sonarsource

πŸ›
noerremark

πŸ›
novsirion

πŸ›
oggboy

πŸ›
oinume

πŸ› -
orimarko

πŸ’» πŸ› +
orimarko

πŸ’» πŸ›
pallavi agarwal

πŸ›
parksungrin

πŸ›
patpatpat123

πŸ›
patriksevallius

πŸ›
pbrajesh1

πŸ›
phoenix384

πŸ› -
piotrszymanski-sc

πŸ’» +
piotrszymanski-sc

πŸ’»
plan3d

πŸ›
poojasix

πŸ›
prabhushrikant

πŸ›
pujitha8783

πŸ›
r-r-a-j

πŸ›
raghujayjunk

πŸ› -
rajeshveera

πŸ› +
rajeshveera

πŸ›
rajeswarreddy88

πŸ›
recdevs

πŸ›
reudismam

πŸ’» πŸ›
rijkt

πŸ›
rillig-tk

πŸ›
rmohan20

πŸ’» πŸ› -
rxmicro

πŸ› +
rxmicro

πŸ›
ryan-gustafson

πŸ’» πŸ›
sabi0

πŸ›
scais

πŸ›
sebbASF

πŸ›
sergeygorbaty

πŸ’»
shilko2013

πŸ› -
shiomiyan

πŸ“– +
shiomiyan

πŸ“–
simeonKondr

πŸ›
snajberk

πŸ›
sniperrifle2004

πŸ›
snuyanzin

πŸ› πŸ’»
sratz

πŸ›
stonio

πŸ› -
sturton

πŸ’» πŸ› +
sturton

πŸ’» πŸ›
sudharmohan

πŸ›
suruchidawar

πŸ›
svenfinitiv

πŸ›
tashiscool

πŸ›
test-git-hook

πŸ›
testation21

πŸ’» πŸ› -
thanosa

πŸ› +
thanosa

πŸ›
tiandiyixian

πŸ›
tobwoerk

πŸ›
tprouvot

πŸ›
trentchilders

πŸ›
triandicAnt

πŸ›
trishul14

πŸ› -
tsui

πŸ› +
tsui

πŸ›
winhkey

πŸ›
witherspore

πŸ›
wjljack

πŸ›
wuchiuwong

πŸ›
xingsong

πŸ›
xioayuge

πŸ› -
xnYi9wRezm

πŸ’» πŸ› +
xnYi9wRezm

πŸ’» πŸ›
xuanuy

πŸ›
xyf0921

πŸ›
yalechen-cyw3

πŸ›
yasuharu-sato

πŸ›
zenglian

πŸ›
zgrzyt93

πŸ’» πŸ› -
zh3ng

πŸ› +
zh3ng

πŸ›
zt_soft

πŸ›
ztt79

πŸ›
zzzzfeng

πŸ› From 7c6277c8b8d3f19636be43e280d7ba9548c11c2f Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 29 Aug 2022 19:05:40 +0200 Subject: [PATCH 41/45] [apex] Update tests (ApexUnitTestClassShouldHaveAsserts, ApexAssertionsShouldIncludeMessage) #4097 --- .../ApexAssertionsShouldIncludeMessage.xml | 68 +++++++++++++++++++ .../ApexUnitTestClassShouldHaveAsserts.xml | 4 +- 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexAssertionsShouldIncludeMessage.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexAssertionsShouldIncludeMessage.xml index f05e9124da..7a499d556a 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexAssertionsShouldIncludeMessage.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexAssertionsShouldIncludeMessage.xml @@ -116,4 +116,72 @@ public class Foo { } ]]>
+ + + [apex] Support new Assert class (Apex v56.0) - negative test case #4097 + 9 + 6,12,19,28,34,40,46,52,58 + + diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml index 28ba29690b..686ffd3cb6 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/bestpractices/xml/ApexUnitTestClassShouldHaveAsserts.xml @@ -76,13 +76,13 @@ private class C2_Assignment_Report_Job_Test { #1089 [apex] ApexUnitTestClassShouldHaveAsserts: Verify use of additionalAssertMethodPattern, positive test - (Assert\.\w+|verify\w+) + (MyAssert\.\w+|verify\w+) 0 Date: Mon, 29 Aug 2022 19:06:03 +0200 Subject: [PATCH 42/45] [doc] Update release notes (#4097, #4096) --- docs/pages/release_notes.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 7fcbc0c973..12f1e105b7 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -16,6 +16,8 @@ This is a {{ site.pmd.release_type }} release. ### Fixed Issues +* apex + * [#4096](https://github.com/pmd/pmd/issues/4096): \[apex] ApexAssertionsShouldIncludeMessage and ApexUnitTestClassShouldHaveAsserts: support new Assert class (introduced with Apex v56.0) * java-codestyle * [#4082](https://github.com/pmd/pmd/issues/4082): \[java] UnnecessaryImport false positive for on-demand imports of nested classes @@ -41,6 +43,7 @@ This is a {{ site.pmd.release_type }} release. * [#4081](https://github.com/pmd/pmd/pull/4081): \[apex] Remove Jorje leaks outside `ast` package - [@eklimo](https://github.com/eklimo) * [#4083](https://github.com/pmd/pmd/pull/4083): \[java] UnnecessaryImport false positive for on-demand imports of nested classes (fix for #4082) - [@abyss638](https://github.com/abyss638) * [#4092](https://github.com/pmd/pmd/pull/4092): \[apex] Implement ApexQualifiableNode for ASTUserEnum - [@aaronhurst-google](https://github.com/aaronhurst-google) +* [#4097](https://github.com/pmd/pmd/pull/4097): \[apex] ApexUnitTestClassShouldHaveAssertsRule: Support new Assert class (Apex v56.0) - [@tprouvot](https://github.com/tprouvot) {% endtocmaker %} From 04b38c3c55a8ddbfd894657194245f791395a23a Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 29 Aug 2022 19:07:55 +0200 Subject: [PATCH 43/45] Update @tprouvot as a contributor --- .all-contributorsrc | 3 ++- docs/pages/pmd/projectdocs/credits.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 87892e6d84..e2edf1e7e1 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -5918,7 +5918,8 @@ "avatar_url": "https://avatars.githubusercontent.com/u/35368290?v=4", "profile": "https://github.com/tprouvot", "contributions": [ - "bug" + "bug", + "code" ] }, { diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index db79a432d7..444b350f40 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -934,7 +934,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
tiandiyixian

πŸ›
tobwoerk

πŸ› -
tprouvot

πŸ› +
tprouvot

πŸ› πŸ’»
trentchilders

πŸ›
triandicAnt

πŸ›
trishul14

πŸ› From aafd95eb3c2e3e4a45876cefc10030c7fbbbe2f9 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 30 Aug 2022 19:02:42 +0200 Subject: [PATCH 44/45] Add @pacvz as a contributor --- .all-contributorsrc | 9 +++++++++ docs/pages/pmd/projectdocs/credits.md | 21 +++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 99708783e8..0f9478e0c3 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -6768,6 +6768,15 @@ "code", "financial" ] + }, + { + "login": "pacvz", + "name": "pacvz", + "avatar_url": "https://avatars.githubusercontent.com/u/35453365?v=4", + "profile": "https://github.com/pacvz", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index 37788cf5f7..34eb9d91cd 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -874,91 +874,92 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
oggboy

πŸ›
oinume

πŸ›
orimarko

πŸ’» πŸ› +
pacvz

πŸ’»
pallavi agarwal

πŸ› -
parksungrin

πŸ› +
parksungrin

πŸ›
patpatpat123

πŸ›
patriksevallius

πŸ›
pbrajesh1

πŸ›
phoenix384

πŸ›
piotrszymanski-sc

πŸ’»
plan3d

πŸ› -
poojasix

πŸ› +
poojasix

πŸ›
prabhushrikant

πŸ›
pujitha8783

πŸ›
r-r-a-j

πŸ›
raghujayjunk

πŸ›
rajeshveera

πŸ›
rajeswarreddy88

πŸ› -
recdevs

πŸ› +
recdevs

πŸ›
reudismam

πŸ’» πŸ›
rijkt

πŸ›
rillig-tk

πŸ›
rmohan20

πŸ’» πŸ›
rxmicro

πŸ›
ryan-gustafson

πŸ’» πŸ› -
sabi0

πŸ› +
sabi0

πŸ›
scais

πŸ›
sebbASF

πŸ›
sergeygorbaty

πŸ’»
shilko2013

πŸ›
shiomiyan

πŸ“–
simeonKondr

πŸ› -
snajberk

πŸ› +
snajberk

πŸ›
sniperrifle2004

πŸ›
snuyanzin

πŸ› πŸ’»
sratz

πŸ›
stonio

πŸ›
sturton

πŸ’» πŸ›
sudharmohan

πŸ› -
suruchidawar

πŸ› +
suruchidawar

πŸ›
svenfinitiv

πŸ›
tashiscool

πŸ›
test-git-hook

πŸ›
testation21

πŸ’» πŸ›
thanosa

πŸ›
tiandiyixian

πŸ› -
tobwoerk

πŸ› +
tobwoerk

πŸ›
tprouvot

πŸ›
trentchilders

πŸ›
triandicAnt

πŸ›
trishul14

πŸ›
tsui

πŸ›
winhkey

πŸ› -
witherspore

πŸ› +
witherspore

πŸ›
wjljack

πŸ›
wuchiuwong

πŸ›
xingsong

πŸ›
xioayuge

πŸ›
xnYi9wRezm

πŸ’» πŸ›
xuanuy

πŸ› -
xyf0921

πŸ› +
xyf0921

πŸ›
yalechen-cyw3

πŸ›
yasuharu-sato

πŸ›
zenglian

πŸ›
zgrzyt93

πŸ’» πŸ›
zh3ng

πŸ›
zt_soft

πŸ› -
ztt79

πŸ› +
ztt79

πŸ›
zzzzfeng

πŸ›
ÁrpÑd MagosÑnyi

πŸ›
任贡杰

πŸ› From 504d2ad5f9c4d9a89d9ef4c03e18709bec1b46af Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 30 Aug 2022 19:04:08 +0200 Subject: [PATCH 45/45] [doc] Update release notes (#4095) --- docs/pages/release_notes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index b8f8783555..b90bc890c5 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -20,5 +20,7 @@ This is a {{ site.pmd.release_type }} release. ### External Contributions +* [#4095](https://github.com/pmd/pmd/pull/4095): \[core] CPD: Added begin and end token to XML reports - [@pacvz](https://github.com/pacvz) + {% endtocmaker %}