From 5a55af46d35e74ba80a3e2015ad9f3c9d2026def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Thu, 8 Jun 2023 00:28:58 -0300 Subject: [PATCH 01/58] Change completion generation to runtime - We no longer ship a pre-built completion script - A hidden subcommand is available to generate it dynamically based on actually available languages. - We update docs everywhere accordingly. --- docs/pages/pmd/userdocs/installation.md | 2 +- docs/pages/release_notes_pmd7.md | 3 +- pmd-cli/pom.xml | 49 ------------------- .../java/net/sourceforge/pmd/cli/PmdCli.java | 12 +++-- .../cli/commands/internal/PmdRootCommand.java | 4 +- .../src/main/resources/assemblies/pmd-bin.xml | 13 ----- .../pmd/it/BinaryDistributionIT.java | 1 - .../java/rule/design/xml/LawOfDemeter.xml | 36 ++++++++++++++ 8 files changed, 49 insertions(+), 71 deletions(-) diff --git a/docs/pages/pmd/userdocs/installation.md b/docs/pages/pmd/userdocs/installation.md index eaa4115bce..da419f375d 100644 --- a/docs/pages/pmd/userdocs/installation.md +++ b/docs/pages/pmd/userdocs/installation.md @@ -47,7 +47,7 @@ On Windows this is achieved by: PMD ships with built-in completion support for Bash / Zsh. -To enable it, simply add `source *path_to_pmd*/shell/pmd-completion.sh` to your `~/.bashrc` / `~/.zshrc` file. +To enable it, simply add `source <(*path_to_pmd*/bin/pmd generate-completion)` to your `~/.bashrc` / `~/.zshrc` file. ## Running PMD via command line diff --git a/docs/pages/release_notes_pmd7.md b/docs/pages/release_notes_pmd7.md index 3a57818bf4..db850ce333 100644 --- a/docs/pages/release_notes_pmd7.md +++ b/docs/pages/release_notes_pmd7.md @@ -416,11 +416,10 @@ current progress of the analysis. This can be disabled with the `--no-progress` flag. Finally, we now provide a completion script for Bash/Zsh to further help daily usage. -This script can be found under `shell/pmd-completion.sh` in the binary distribution. To use it, edit your `~/.bashrc` / `~/.zshrc` file and add the following line: ``` -source *path_to_pmd*/shell/pmd-completion.sh +source <(*path_to_pmd*/bin/pmd generate-completion) ``` Contributors: [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) diff --git a/pmd-cli/pom.xml b/pmd-cli/pom.xml index 2df635e272..a217e76abd 100644 --- a/pmd-cli/pom.xml +++ b/pmd-cli/pom.xml @@ -20,55 +20,6 @@ pmd-cli-checkstyle-suppressions.xml - - - org.codehaus.mojo - exec-maven-plugin - - - generate-autocompletion-script - package - - exec - - - - - java - - -Dpicocli.autocomplete.systemExitOnError - -cp - - picocli.AutoComplete - --force - --completionScript - ${project.build.directory}/pmd_completion.sh - net.sourceforge.pmd.cli.commands.internal.PmdRootCommand - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-completion-artifact - - attach-artifact - - - - - ${project.build.directory}/pmd_completion.sh - sh - completion - - - - - - diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/PmdCli.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/PmdCli.java index 1de2edc64a..1b246b86f1 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/PmdCli.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/PmdCli.java @@ -13,9 +13,13 @@ public final class PmdCli { private PmdCli() { } public static void main(String[] args) { - final int exitCode = new CommandLine(new PmdRootCommand()) - .setCaseInsensitiveEnumValuesAllowed(true) - .execute(args); - System.exit(exitCode); + final CommandLine cli = new CommandLine(new PmdRootCommand()) + .setCaseInsensitiveEnumValuesAllowed(true); + + // Don't show autocomplete subcommand in help by default + cli.getSubcommands().get("generate-completion") + .getCommandSpec().usageMessage().hidden(true); + + System.exit(cli.execute(args)); } } diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdRootCommand.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdRootCommand.java index ef15d504fd..d596745bfc 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdRootCommand.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdRootCommand.java @@ -6,6 +6,7 @@ package net.sourceforge.pmd.cli.commands.internal; import net.sourceforge.pmd.PMDVersion; +import picocli.AutoComplete.GenerateCompletion; import picocli.CommandLine.Command; import picocli.CommandLine.IVersionProvider; @@ -14,7 +15,8 @@ import picocli.CommandLine.IVersionProvider; exitCodeListHeading = "Exit Codes:%n", exitCodeList = { "0:Successful analysis, no violations found", "1:An unexpected error occurred during execution", "2:Usage error, please refer to the command help", "4:Successful analysis, at least 1 violation found" }, - subcommands = { PmdCommand.class, CpdCommand.class, DesignerCommand.class, CpdGuiCommand.class, TreeExportCommand.class }) + subcommands = { PmdCommand.class, CpdCommand.class, DesignerCommand.class, + CpdGuiCommand.class, TreeExportCommand.class, GenerateCompletion.class }) public class PmdRootCommand { } diff --git a/pmd-dist/src/main/resources/assemblies/pmd-bin.xml b/pmd-dist/src/main/resources/assemblies/pmd-bin.xml index a69cde3c66..f33bf93348 100644 --- a/pmd-dist/src/main/resources/assemblies/pmd-bin.xml +++ b/pmd-dist/src/main/resources/assemblies/pmd-bin.xml @@ -67,19 +67,6 @@ - - - runtime - - net.sourceforge.pmd:pmd-cli:sh:completion:* - - pmd-completion.sh - shell - 0755 - 0644 - false - - runtime diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java b/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java index 04f87ac700..bd863c44a3 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java @@ -85,7 +85,6 @@ class BinaryDistributionIT extends AbstractBinaryDistributionTest { result.add(basedir + "bin/pmd"); result.add(basedir + "bin/pmd.bat"); result.add(basedir + "conf/simplelogger.properties"); - result.add(basedir + "shell/pmd-completion.sh"); result.add(basedir + "lib/pmd-core-" + PMDVersion.VERSION + ".jar"); result.add(basedir + "lib/pmd-java-" + PMDVersion.VERSION + ".jar"); result.add(basedir + "sbom/pmd-" + PMDVersion.VERSION + "-cyclonedx.xml"); diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/LawOfDemeter.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/LawOfDemeter.xml index c977a3e509..6c6eceac33 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/LawOfDemeter.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/LawOfDemeter.xml @@ -1222,6 +1222,42 @@ class LawOfDemeterFields { return null; } } +]]> + + + + sadasd conditional self assignment of fields + 2 + 12,18 + { + TreeNode root = (TreeNode) tree.getModel().getRoot(); // NOT report + visitAll(tree, new TreePath(root), true); + })); + box.add(new JButton(new AbstractAction("collapse") { + @Override + public void actionPerformed(ActionEvent e) { + TreeNode root = (TreeNode) tree.getModel().getRoot(); // report LawOfDemeter(method chain calls) + visitAll(tree, new TreePath(root), false); + } + })); + box.add(Box.createVerticalGlue()); + JPanel p = new JPanel(new BorderLayout()); + p.add(box, BorderLayout.EAST); + p.add(new JScrollPane(tree)); + return p; + } +} ]]> From 7062d795777b10ff77130cb389425d848e4bf277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Thu, 8 Jun 2023 10:13:46 -0300 Subject: [PATCH 02/58] Fix indentation --- .../sourceforge/pmd/cli/commands/internal/PmdRootCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdRootCommand.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdRootCommand.java index d596745bfc..169690f98a 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdRootCommand.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdRootCommand.java @@ -16,7 +16,7 @@ import picocli.CommandLine.IVersionProvider; exitCodeList = { "0:Successful analysis, no violations found", "1:An unexpected error occurred during execution", "2:Usage error, please refer to the command help", "4:Successful analysis, at least 1 violation found" }, subcommands = { PmdCommand.class, CpdCommand.class, DesignerCommand.class, - CpdGuiCommand.class, TreeExportCommand.class, GenerateCompletion.class }) + CpdGuiCommand.class, TreeExportCommand.class, GenerateCompletion.class }) public class PmdRootCommand { } From 2fc4cb9929a396305bccaa466705ec56528bba4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Fri, 9 Jun 2023 11:42:54 -0300 Subject: [PATCH 03/58] Remove completion dependency from dist --- pmd-dist/pom.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pmd-dist/pom.xml b/pmd-dist/pom.xml index 9e824be8a3..44c745feff 100644 --- a/pmd-dist/pom.xml +++ b/pmd-dist/pom.xml @@ -132,14 +132,6 @@ pmd-cli ${project.version} - - - net.sourceforge.pmd - pmd-cli - ${project.version} - sh - completion - net.sourceforge.pmd pmd-ant From 6fc45493e7a1abe1b007395c02dfa83ba7c32f26 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 29 Jun 2023 18:47:22 +0200 Subject: [PATCH 04/58] [core] Deal with errors from threads in multithreading mode If an error occurs in multithreading mode, PMD now rethrows this. Such errors indicate a serious problem like incomplete runtime classpath of PMD or other VM error (out of memory) that shouldn't be swallowed. --- .../pmd/lang/impl/MultiThreadProcessor.java | 24 +++- .../lang/impl/AbstractPMDProcessorTest.java | 130 ++++++++++++++++-- .../lang/impl/MonoThreadProcessorTest.java | 43 ++++++ .../lang/impl/MultiThreadProcessorTest.java | 85 +++++------- 4 files changed, 223 insertions(+), 59 deletions(-) create mode 100644 pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessor.java index 035accf05f..cd0e26dc37 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessor.java @@ -4,8 +4,12 @@ package net.sourceforge.pmd.lang.impl; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import net.sourceforge.pmd.RuleSets; @@ -18,13 +22,15 @@ import net.sourceforge.pmd.util.log.MessageReporter; * @author Romain Pelisse <belaran@gmail.com> */ final class MultiThreadProcessor extends AbstractPMDProcessor { - private final ExecutorService executor; + private final List> futureList; + MultiThreadProcessor(final AnalysisTask task) { super(task); executor = Executors.newFixedThreadPool(task.getThreadCount(), new PmdThreadFactory()); + futureList = new LinkedList<>(); } @Override @@ -42,18 +48,30 @@ final class MultiThreadProcessor extends AbstractPMDProcessor { }); for (final TextFile textFile : task.getFiles()) { - executor.submit(new PmdRunnable(textFile, task) { + futureList.add(executor.submit(new PmdRunnable(textFile, task) { @Override protected RuleSets getRulesets() { return ruleSetCopy.get(); } - }); + })); } } @Override public void close() { try { + try { + for (Future task : futureList) { + task.get(); + } + } catch (ExecutionException e) { + task.getMessageReporter().error("Unknown error occurred while executing a PmdRunnable: {0}", + e.getCause().toString(), e.getCause()); + if (e.getCause() instanceof Error) { + throw (Error) e.getCause(); + } + } + executor.shutdown(); while (!executor.awaitTermination(10, TimeUnit.HOURS)) { // still waiting diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessorTest.java index a95f36e3da..ca52a03e65 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessorTest.java @@ -4,24 +4,136 @@ package net.sourceforge.pmd.lang.impl; +import static net.sourceforge.pmd.util.CollectionUtil.listOf; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertSame; +import java.util.concurrent.atomic.AtomicInteger; + import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import net.sourceforge.pmd.PMDConfiguration; +import net.sourceforge.pmd.PmdAnalysis; +import net.sourceforge.pmd.Report; +import net.sourceforge.pmd.RuleContext; +import net.sourceforge.pmd.RuleSet; +import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageProcessor; +import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.document.FileId; +import net.sourceforge.pmd.lang.document.TextFile; +import net.sourceforge.pmd.lang.rule.AbstractRule; +import net.sourceforge.pmd.reporting.FileAnalysisListener; +import net.sourceforge.pmd.reporting.GlobalAnalysisListener; +import net.sourceforge.pmd.util.log.MessageReporter; + +abstract class AbstractPMDProcessorTest { + protected SimpleReportListener reportListener; + + protected MessageReporter reporter; + + protected abstract int getThreads(); + + protected abstract Class getExpectedImplementation(); -class AbstractPMDProcessorTest { @Test - void shouldUseMonoThreadProcessorForZeroOnly() { - AbstractPMDProcessor processor = AbstractPMDProcessor.newFileProcessor(createTask(0)); - assertSame(MonoThreadProcessor.class, processor.getClass()); - - processor = AbstractPMDProcessor.newFileProcessor(createTask(1)); - assertSame(MultiThreadProcessor.class, processor.getClass()); + void shouldUseCorrectProcessorImpl() { + try (AbstractPMDProcessor processor = AbstractPMDProcessor.newFileProcessor(createTask(getThreads()))) { + assertSame(getExpectedImplementation(), processor.getClass()); + } } private LanguageProcessor.AnalysisTask createTask(int threads) { - LanguageProcessor.AnalysisTask task = new LanguageProcessor.AnalysisTask(null, null, null, threads, null, null, null); - return task; + return new LanguageProcessor.AnalysisTask(null, null, null, threads, null, null, null); + } + + @Test + void exceptionsShouldBeLogged() { + try (PmdAnalysis pmd = createPmdAnalysis()) { + pmd.addRuleSet(RuleSet.forSingleRule(new RuleThatThrowsException())); + pmd.performAnalysis(); + } + + assertEquals(2, reportListener.files.get()); + assertEquals(2, reportListener.errors.get()); + // exceptions are reported as processing errors + Mockito.verifyNoInteractions(reporter); + } + + protected PmdAnalysis createPmdAnalysis() { + PMDConfiguration configuration = new PMDConfiguration(); + configuration.setThreads(getThreads()); + configuration.setIgnoreIncrementalAnalysis(true); + reporter = Mockito.spy(configuration.getReporter()); + configuration.setReporter(reporter); + + PmdAnalysis pmd = PmdAnalysis.create(configuration); + LanguageVersion lv = DummyLanguageModule.getInstance().getDefaultVersion(); + pmd.files().addFile(TextFile.forCharSeq("abc", FileId.fromPathLikeString("file1-violation.dummy"), lv)); + pmd.files().addFile(TextFile.forCharSeq("DEF", FileId.fromPathLikeString("file2-foo.dummy"), lv)); + + reportListener = new SimpleReportListener(); + GlobalAnalysisListener listener = GlobalAnalysisListener.tee(listOf( + new Report.GlobalReportBuilderListener(), + reportListener + )); + + + pmd.addListener(listener); + return pmd; + } + + protected static class RuleThatThrowsException extends AbstractRule { + RuleThatThrowsException() { + setLanguage(DummyLanguageModule.getInstance().getDefaultVersion().getLanguage()); + } + + @Override + public void apply(Node target, RuleContext ctx) { + throw new RuntimeException("test exception"); + } + } + + protected static class RuleThatThrowsError extends AbstractRule { + RuleThatThrowsError() { + setLanguage(DummyLanguageModule.getInstance().getDefaultVersion().getLanguage()); + } + + @Override + public void apply(Node target, RuleContext ctx) { + throw new Error("test error"); + } + } + + protected static class SimpleReportListener implements GlobalAnalysisListener { + + public AtomicInteger violations = new AtomicInteger(0); + public AtomicInteger files = new AtomicInteger(0); + public AtomicInteger errors = new AtomicInteger(0); + + @Override + public FileAnalysisListener startFileAnalysis(TextFile file) { + files.incrementAndGet(); + + return new FileAnalysisListener() { + @Override + public void onRuleViolation(RuleViolation violation) { + violations.incrementAndGet(); + } + + @Override + public void onError(Report.ProcessingError error) { + errors.incrementAndGet(); + } + }; + } + + @Override + public void close() throws Exception { + + } } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java new file mode 100644 index 0000000000..755003142b --- /dev/null +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java @@ -0,0 +1,43 @@ +/* + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.impl; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +import net.sourceforge.pmd.PmdAnalysis; +import net.sourceforge.pmd.RuleSet; + +class MonoThreadProcessorTest extends AbstractPMDProcessorTest { + + @Override + protected int getThreads() { + return 0; + } + + @Override + protected Class getExpectedImplementation() { + return MonoThreadProcessor.class; + } + + @Test + void errorsShouldBeThrown() { + try (PmdAnalysis pmd = createPmdAnalysis()) { + pmd.addRuleSet(RuleSet.forSingleRule(new RuleThatThrowsError())); + Error exception = assertThrows(Error.class, pmd::performAnalysis); + assertEquals("test error", exception.getMessage()); + } + + // in mono thread, files are processed one after another. + // in case of error, we abort at the first error, so in this test case + // we abort at the first file, so only 1 file is processed. + assertEquals(1, reportListener.files.get()); + // in mono thread, the error just falls through, we don't additionally catch and log it. + Mockito.verifyNoInteractions(reporter); + } +} diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java index f32b330b0a..12e381fac1 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java @@ -4,51 +4,61 @@ package net.sourceforge.pmd.lang.impl; -import static net.sourceforge.pmd.util.CollectionUtil.listOf; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.concurrent.atomic.AtomicInteger; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; -import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; -import net.sourceforge.pmd.Report.GlobalReportBuilderListener; import net.sourceforge.pmd.RuleContext; -import net.sourceforge.pmd.RuleViolation; -import net.sourceforge.pmd.lang.DummyLanguageModule; -import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.lang.ast.Node; -import net.sourceforge.pmd.lang.document.FileId; -import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.rule.AbstractRule; -import net.sourceforge.pmd.reporting.FileAnalysisListener; -import net.sourceforge.pmd.reporting.GlobalAnalysisListener; -class MultiThreadProcessorTest { +class MultiThreadProcessorTest extends AbstractPMDProcessorTest { - private SimpleReportListener reportListener; + @Override + protected int getThreads() { + return 2; + } - PmdAnalysis setupForTest(final String ruleset) { - PMDConfiguration configuration = new PMDConfiguration(); - configuration.setThreads(2); - configuration.setIgnoreIncrementalAnalysis(true); - PmdAnalysis pmd = PmdAnalysis.create(configuration); - LanguageVersion lv = DummyLanguageModule.getInstance().getDefaultVersion(); - pmd.files().addFile(TextFile.forCharSeq("abc", FileId.fromPathLikeString("file1-violation.dummy"), lv)); - pmd.files().addFile(TextFile.forCharSeq("DEF", FileId.fromPathLikeString("file2-foo.dummy"), lv)); + @Override + protected Class getExpectedImplementation() { + return MultiThreadProcessor.class; + } - reportListener = new SimpleReportListener(); - GlobalAnalysisListener listener = GlobalAnalysisListener.tee(listOf( - new GlobalReportBuilderListener(), - reportListener - )); - - pmd.addListener(listener); + private PmdAnalysis createPmdAnalysis(final String ruleset) { + PmdAnalysis pmd = createPmdAnalysis(); pmd.addRuleSet(pmd.newRuleSetLoader().loadFromResource(ruleset)); return pmd; } + @Test + void errorsShouldBeThrown() { + // in multithreading mode, the errors are detected when closing PmdAnalysis + Error error = assertThrows(Error.class, () -> { + try (PmdAnalysis pmd = createPmdAnalysis()) { + pmd.addRuleSet(RuleSet.forSingleRule(new RuleThatThrowsError())); + pmd.performAnalysis(); + } + }); + assertEquals("test error", error.getMessage()); + + // in multithreading mode, all files are started but eventually fail + // depending on how many tasks have been started before getting the first results + // we might have started only one file analysis or more. But we rethrow + // the error on the first. + assertTrue(reportListener.files.get() >= 1); + // we report the first error + Mockito.verify(reporter).error(Mockito.eq("Unknown error occurred while executing a PmdRunnable: {0}"), + Mockito.eq("java.lang.Error: test error"), + Mockito.any(Error.class)); + } + // TODO: Dysfunctional rules are pruned upstream of the processor. // // @Test @@ -71,7 +81,7 @@ class MultiThreadProcessorTest { @Test void testRulesThreadSafety() throws Exception { - try (PmdAnalysis pmd = setupForTest("rulesets/MultiThreadProcessorTest/basic.xml")) { + try (PmdAnalysis pmd = createPmdAnalysis("rulesets/MultiThreadProcessorTest/basic.xml")) { pmd.performAnalysis(); } @@ -130,23 +140,4 @@ class MultiThreadProcessorTest { } } - private static class SimpleReportListener implements GlobalAnalysisListener { - - public AtomicInteger violations = new AtomicInteger(0); - - @Override - public FileAnalysisListener startFileAnalysis(TextFile file) { - return new FileAnalysisListener() { - @Override - public void onRuleViolation(RuleViolation violation) { - violations.incrementAndGet(); - } - }; - } - - @Override - public void close() throws Exception { - - } - } } From 295ee304a49539597e351a88b25adb7328e3bbd3 Mon Sep 17 00:00:00 2001 From: Shai Bennathan Date: Mon, 7 Aug 2023 12:51:09 +0300 Subject: [PATCH 05/58] Issue: Launch failure via bin/bash Currently if run.sh is launched via 'bin/bash run.sh', when run.sh is not in the local directory (i.e., accessed via path env var) it thinks it runs in the local directory. This change makes sure that all cases are covered. Tested on local Ubuntu 22.04. --- pmd-dist/src/main/resources/scripts/pmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-dist/src/main/resources/scripts/pmd b/pmd-dist/src/main/resources/scripts/pmd index 926238f9da..5da1418e00 100755 --- a/pmd-dist/src/main/resources/scripts/pmd +++ b/pmd-dist/src/main/resources/scripts/pmd @@ -52,7 +52,7 @@ set_lib_dir() { if [ -L "$0" ]; then local script_real_loc=$(readlink "$0") else - local script_real_loc=$0 + local script_real_loc=${BASH_SOURCE[0]} fi local script_dir=$(dirname "${script_real_loc}") From 56ae02ad3547e80dc082624a9f38c42e4c45aa7f Mon Sep 17 00:00:00 2001 From: Shai Bennathan Date: Mon, 7 Aug 2023 15:32:11 +0300 Subject: [PATCH 06/58] Update pmd-dist/src/main/resources/scripts/pmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Juan Martín Sotuyo Dodero --- pmd-dist/src/main/resources/scripts/pmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-dist/src/main/resources/scripts/pmd b/pmd-dist/src/main/resources/scripts/pmd index 5da1418e00..50010b4310 100755 --- a/pmd-dist/src/main/resources/scripts/pmd +++ b/pmd-dist/src/main/resources/scripts/pmd @@ -52,7 +52,7 @@ set_lib_dir() { if [ -L "$0" ]; then local script_real_loc=$(readlink "$0") else - local script_real_loc=${BASH_SOURCE[0]} + local script_real_loc=${BASH_SOURCE[0]:-${(%):-%x}} fi local script_dir=$(dirname "${script_real_loc}") From 6e61b9f2a8824221a49fb1367e9008fc962c2b9f Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 31 Aug 2023 14:42:53 +0200 Subject: [PATCH 07/58] [ant] Improve documentation Refs #4658 --- docs/pages/pmd/userdocs/cpd/cpd.md | 8 ++++- docs/pages/pmd/userdocs/tools/ant.md | 2 -- .../java/net/sourceforge/pmd/ant/CPDTask.java | 34 +++++++++++-------- .../java/net/sourceforge/pmd/ant/PMDTask.java | 25 ++++++++++++++ 4 files changed, 52 insertions(+), 17 deletions(-) diff --git a/docs/pages/pmd/userdocs/cpd/cpd.md b/docs/pages/pmd/userdocs/cpd/cpd.md index 73b7368f1c..ab65964e5e 100644 --- a/docs/pages/pmd/userdocs/cpd/cpd.md +++ b/docs/pages/pmd/userdocs/cpd/cpd.md @@ -333,8 +333,14 @@ For details, see [CPD Report Formats](pmd_userdocs_cpd_report_formats.html). Andy Glover wrote an Ant task for CPD; here's how to use it: ```xml + + + + + + + - diff --git a/docs/pages/pmd/userdocs/tools/ant.md b/docs/pages/pmd/userdocs/tools/ant.md index ae3abbcbab..8306bae2ff 100644 --- a/docs/pages/pmd/userdocs/tools/ant.md +++ b/docs/pages/pmd/userdocs/tools/ant.md @@ -181,7 +181,6 @@ automatically and the latest language version is used. `ruleset` nested element - another way to specify rulesets. You can specify multiple elements. Here's an example: - rulesets/java/quickstart.xml config/my-ruleset.xml @@ -373,7 +372,6 @@ You can run pmd then with `ant pmd`. An HTML report with the "linkPrefix" and "linePrefix" properties: - diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/CPDTask.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/CPDTask.java index 177f1311de..85abfdc0ad 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/CPDTask.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/CPDTask.java @@ -40,20 +40,26 @@ import net.sourceforge.pmd.lang.LanguageRegistry; * *

Runs the CPD utility via ant. The ant task looks like this:

* - *
- * <project name="CPDProj" default="main" basedir=".">
- *   <taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask" />
- *   <target name="main">
- *     <cpd encoding="UTF-16LE" language="java" ignoreIdentifiers="true"
- *          ignoreLiterals="true" ignoreAnnotations="true" minimumTokenCount="100"
- *          outputFile="c:\cpdrun.txt">
- *       <fileset dir="/path/to/my/src">
- *         <include name="*.java"/>
- *       </fileset>
- *     </cpd>
- *   </target>
- * </project>
- * 
+ *
{@code
+ *   
+ *     
+ *         
+ *             
+ *         
+ *     
+ *     
+ *
+ *     
+ *       
+ *         
+ *           
+ *         
+ *       
+ *     
+ *   
+ * }
* *

Required: minimumTokenCount, outputFile, and at least one file

*/ diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java index 578db83ca5..db10833ff7 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java @@ -24,6 +24,31 @@ import net.sourceforge.pmd.ant.internal.PMDTaskImpl; /** * PMD Ant task. Setters of this class are interpreted by Ant as properties * settable in the XML. This is therefore published API. + * + *

Runs PMD analysis via ant. The ant task looks like this:

+ * + *
{@code
+ *   
+ *     
+ *         
+ *             
+ *         
+ *     
+ *     
+ *
+ *     
+ *       
+ *         rulesets/java/quickstart.xml
+ *         config/my-ruleset.xml
+ *         
+ *             
+ *         
+ *       
+ *     
+ *   
+ * }
+ * + *

Required: rulesetfiles/ruleset, fileset

*/ public class PMDTask extends Task { From 291a5aa956401fc195e0f818a1dc1f06e673e612 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 31 Aug 2023 17:12:21 +0200 Subject: [PATCH 08/58] [doc] Update language module docs (apex, java, visualforce) --- .../adding_a_new_antlr_based_language.md | 4 ++- .../adding_a_new_javacc_based_language.md | 4 ++- docs/pages/pmd/languages/apex.md | 33 +++++++++++++++++-- docs/pages/pmd/languages/java.md | 12 +++++++ docs/pages/pmd/languages/visualforce.md | 24 +++++++++++--- .../pmd/lang/vf/VfLanguageProperties.java | 4 +-- 6 files changed, 70 insertions(+), 11 deletions(-) diff --git a/docs/pages/pmd/devdocs/major_contributions/adding_a_new_antlr_based_language.md b/docs/pages/pmd/devdocs/major_contributions/adding_a_new_antlr_based_language.md index e5890d1078..1433a5fe73 100644 --- a/docs/pages/pmd/devdocs/major_contributions/adding_a_new_antlr_based_language.md +++ b/docs/pages/pmd/devdocs/major_contributions/adding_a_new_antlr_based_language.md @@ -142,7 +142,9 @@ definitely don't come for free. It is much effort and requires perseverance to i * For a minimal implementation, it just needs to return a parser *(see step #6)*. * It can be used to provide other features for your language like * violation suppression logic - * violation decorators, to add additional language specific information to the created violations + * {% jdoc core::reporting::ViolationDecorator %}s, to add additional language specific information to the + created violations. The [Java language module](pmd_languages_java.html#violation-decorators) uses this to + provide the method name or class name, where the violation occurred. * metrics * custom XPath functions diff --git a/docs/pages/pmd/devdocs/major_contributions/adding_a_new_javacc_based_language.md b/docs/pages/pmd/devdocs/major_contributions/adding_a_new_javacc_based_language.md index 1f3ede48a4..bb0ffb6f8a 100644 --- a/docs/pages/pmd/devdocs/major_contributions/adding_a_new_javacc_based_language.md +++ b/docs/pages/pmd/devdocs/major_contributions/adding_a_new_javacc_based_language.md @@ -81,7 +81,9 @@ definitely don't come for free. It is much effort and requires perseverance to i * For a minimal implementation, it just needs to return a parser *(see step #5)*. * It can be used to provide other features for your language like * violation suppression logic - * violation decorators, to add additional language specific information to the created violations + * {% jdoc core::reporting::ViolationDecorator %}s, to add additional language specific information to the + created violations. The [Java language module](pmd_languages_java.html#violation-decorators) uses this to + provide the method name or class name, where the violation occurred. * metrics (see below "Optional features") * custom XPath functions * See `VmHandler` class as an example diff --git a/docs/pages/pmd/languages/apex.md b/docs/pages/pmd/languages/apex.md index 18d0d749cc..6ba6bf4ed3 100644 --- a/docs/pages/pmd/languages/apex.md +++ b/docs/pages/pmd/languages/apex.md @@ -2,14 +2,41 @@ title: Apex support permalink: pmd_languages_apex.html author: Clément Fournier -last_updated: March 2021 (7.0.0) +last_updated: September 2023 (7.0.0) tags: [languages] summary: "Apex-specific features and guidance" --- +Implementation: {% jdoc apex::lang.apex.ApexLanguageModule %} +Name: Apex +id: apex +PMD: yes +CPD: yes + + {% include warning.html content="Todo for pmd 7" %} -### Metrics framework +## Metrics framework -In order to use code metrics in Java, use the metrics constants in {% jdoc apex::lang.apex.metrics.ApexMetrics %}, +In order to use code metrics in Apex, use the metrics constants in {% jdoc apex::lang.apex.metrics.ApexMetrics %}, together with {% jdoc core::lang.metrics.MetricsUtil %}. + +## Multifile Analysis + +See {% jdoc apex::lang.apex.multifile.ApexMultifileAnalysis %} +Uses [ApexLink](https://github.com/nawforce/apex-link), see also [Apexlink POC #2830](https://github.com/pmd/pmd/pull/2830). + +Note: ApexLink new home: https://github.com/apex-dev-tools + +Used for rule {% rule apex/design/UnusedMethod %} + +## Language Properties + +See [Apex language properties](pmd_languages_configuration.html#apex-language-properties) + +## Parser + +We use Jorje... + +## Limitations + diff --git a/docs/pages/pmd/languages/java.md b/docs/pages/pmd/languages/java.md index 43463f0c74..aca60936f1 100644 --- a/docs/pages/pmd/languages/java.md +++ b/docs/pages/pmd/languages/java.md @@ -82,3 +82,15 @@ public Object visit(ASTMethodDeclaration node, Object data) { ``` The Javadocs are the reference documentation. + +## Violation Decorators + +Violations reported are the same for all languages, but languages can opt in to provide more details. +Java does this by adding the following additional information for each reported violation: + +* {% jdoc core::RuleViolation#VARIABLE_NAME %} +* {% jdoc core::RuleViolation#METHOD_NAME %} +* {% jdoc core::RuleViolation#CLASS_NAME %} +* {% jdoc core::RuleViolation#PACKAGE_NAME %} + +You can access these via {% jdoc core::RuleViolation#getAdditionalInfo() %} diff --git a/docs/pages/pmd/languages/visualforce.md b/docs/pages/pmd/languages/visualforce.md index 8699883564..84c070d10f 100644 --- a/docs/pages/pmd/languages/visualforce.md +++ b/docs/pages/pmd/languages/visualforce.md @@ -2,9 +2,19 @@ title: Visualforce Support permalink: pmd_languages_visualforce.html author: Andreas Dangel -last_updated: October 2021 +last_updated: September 2023 --- +Implementation: {% jdoc visualforce::lang.vf.VfLanguageModule %} +Name: Salesforce VisualForce +id: vf +PMD: yes +CPD: yes + +## Language Properties + +See [VisualForce language properties](pmd_languages_configuration.html#visualforce-language-properties) + ## Type resolution Since PMD 6.30.0 support for type resolution has been added. @@ -13,16 +23,22 @@ The Visualforce AST now can resolve the data type of Visualforce expressions tha Apex Controller properties and Custom Object fields. This feature improves the precision of existing rules, like {% rule vf/security/VfUnescapeEl %}. -This can be configured using two environment variables: +This can be configured using two language properties, which can be set as environment variables: -* `PMD_VF_APEXDIRECTORIES`: Comma separated list of directories for Apex classes. Absolute or relative +* `PMD_VF_APEX_DIRECTORIES`: Comma separated list of directories for Apex classes. Absolute or relative to the Visualforce directory. Default is `../classes`. Specifying an empty string will disable data type resolution for Apex Controller properties. -* `PMD_VF_OBJECTSDIRECTORIES`: Comma separated list of directories for Custom Objects. Absolute or relative +* `PMD_VF_OBJECTS_DIRECTORIES`: Comma separated list of directories for Custom Objects. Absolute or relative to the Visualforce directory. Default is `../objects`. Specifying an empty string will disable data type resolution for Custom Object fields. +{% include warning.html content=" +These env vars have changed from PMD 6 to PMD 7: +* `PMD_VF_APEXDIRECTORIES` ➡️ `PMD_VF_APEX_DIRECTORIES` +* `PMD_VF_OBJECTSDIRECTORIES` ➡️ `PMD_VF_OBJECTS_DIRECTORIES` +"%} + This feature is experimental, in particular, expect changes to the way the configuration is specified. We'll probably extend the CLI instead of relying on environment variables in a future version. diff --git a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/VfLanguageProperties.java b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/VfLanguageProperties.java index 3ec4d2d21b..445e6d3f1f 100644 --- a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/VfLanguageProperties.java +++ b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/VfLanguageProperties.java @@ -19,7 +19,7 @@ public class VfLanguageProperties extends LanguagePropertyBundle { /** * Directory that contains Apex classes that may be referenced from a Visualforce page. * - *

Env variable is {@code PMD_VF_APEXDIRECTORIES}. + *

Env variable is {@code PMD_VF_APEX_DIRECTORIES}. */ public static final PropertyDescriptor> APEX_DIRECTORIES_DESCRIPTOR = PropertyFactory.stringListProperty("apexDirectories") @@ -30,7 +30,7 @@ public class VfLanguageProperties extends LanguagePropertyBundle { /** * Directory that contains Object definitions that may be referenced from a Visualforce page. * - *

Env variable is {@code PMD_VF_OBJECTSDIRECTORIES}. + *

Env variable is {@code PMD_VF_OBJECTS_DIRECTORIES}. */ public static final PropertyDescriptor> OBJECTS_DIRECTORIES_DESCRIPTOR = PropertyFactory.stringListProperty("objectsDirectories") From ca40dc41b0c4a2213eb5d22d83e0a8e422d4604b Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 1 Sep 2023 09:41:46 +0200 Subject: [PATCH 09/58] [doc] Add language info summary --- docs/_includes/language_info.html | 11 +++++++++++ docs/_plugins/javadoc_tag.rb | 20 +++++++++++++------- docs/pages/pmd/languages/apex.md | 9 +-------- docs/pages/pmd/languages/java.md | 2 ++ 4 files changed, 27 insertions(+), 15 deletions(-) create mode 100644 docs/_includes/language_info.html diff --git a/docs/_includes/language_info.html b/docs/_includes/language_info.html new file mode 100644 index 0000000000..b36db72904 --- /dev/null +++ b/docs/_includes/language_info.html @@ -0,0 +1,11 @@ +

+ Name: {{include.name}} +
+
    +
  • Implementation: {% jdoc include.implementation %}
  • +
  • id: {{include.id}}
  • +
  • PMD: {% if include.supports_pmd %}✔️{% else %}❌{% endif %}
  • +
  • CPD: {% if include.supports_cpd %}✔️{% else %}❌{% endif %}
  • +
+
+
diff --git a/docs/_plugins/javadoc_tag.rb b/docs/_plugins/javadoc_tag.rb index b3e79329f9..2016c442f7 100644 --- a/docs/_plugins/javadoc_tag.rb +++ b/docs/_plugins/javadoc_tag.rb @@ -106,16 +106,25 @@ class JavadocTag < Liquid::Tag def initialize(tag_name, doc_ref, tokens) super - # sanitize a little - doc_ref.delete! " \"'" + @doc_ref = doc_ref + end - arr = doc_ref.split("#") # split into fqcn + member suffix + def render(var_ctx) + # maybe the parameter is actually a variable - try to resolve it first + if var_ctx.key?(@doc_ref) + @doc_ref = var_ctx[@doc_ref] + end + + # sanitize a little + @doc_ref.delete! " \"'" + + arr = @doc_ref.split("#") # split into fqcn + member suffix @type_fqcn = arr[0] @member_suffix = arr[1] || "" # default to empty string unless Regexp.new('(!\w*!)?' + Regexp.union(JDocNamespaceDeclaration::NAMESPACED_FQCN_REGEX, JDocNamespaceDeclaration::SYM_REGEX).source ) =~ @type_fqcn - fail "Wrong syntax for type reference, expected eg nspace::a.b.C, !opts!nspace::a.b.C, or :nspace" + fail "Wrong syntax for type reference, expected eg nspace::a.b.C, !opts!nspace::a.b.C, or :nspace, but got \'" + @type_fqcn + "\'" end # If no options, then split produces [@type_fqcn] @@ -130,9 +139,6 @@ class JavadocTag < Liquid::Tag elsif tag_name == "jdoc_old" @use_previous_api_version = true end - end - - def render(var_ctx) artifact_name, @type_fqcn = JDocNamespaceDeclaration::parse_fqcn(@type_fqcn, var_ctx) resolved_type = JavadocTag::fqcn_type(artifact_name, @type_fqcn) diff --git a/docs/pages/pmd/languages/apex.md b/docs/pages/pmd/languages/apex.md index 6ba6bf4ed3..cf93b81a65 100644 --- a/docs/pages/pmd/languages/apex.md +++ b/docs/pages/pmd/languages/apex.md @@ -7,14 +7,7 @@ tags: [languages] summary: "Apex-specific features and guidance" --- -Implementation: {% jdoc apex::lang.apex.ApexLanguageModule %} -Name: Apex -id: apex -PMD: yes -CPD: yes - - -{% include warning.html content="Todo for pmd 7" %} +{% include language_info.html name='Apex' id='apex' implementation='apex::lang.apex.ApexLanguageModule' supports_pmd='✔️' supports_cpd='✔️' %} ## Metrics framework diff --git a/docs/pages/pmd/languages/java.md b/docs/pages/pmd/languages/java.md index aca60936f1..e9aaaea0a0 100644 --- a/docs/pages/pmd/languages/java.md +++ b/docs/pages/pmd/languages/java.md @@ -7,6 +7,8 @@ tags: [languages] summary: "Java-specific features and guidance" --- +{% include language_info.html name='Java' id='java' implementation='java::lang.java.JavaLanguageModule' supports_pmd='✔️' supports_cpd='✔️' %} + {% include warning.html content="WIP, todo for pmd 7" %} ## Overview of supported Java language versions From 107b8e5b670fe27fd62422f8091f04febdf8bcff Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 1 Sep 2023 12:13:56 +0200 Subject: [PATCH 10/58] [doc] Add pages for all supported language --- docs/_data/sidebars/pmd_sidebar.yml | 77 ++++++++++++++++--- docs/_includes/language_info.html | 6 +- docs/_plugins/jdoc_namespace_tag.rb | 7 +- docs/css/customstyles.css | 7 ++ docs/pages/pmd/languages/apex.md | 4 +- docs/pages/pmd/languages/coco.md | 4 + docs/pages/pmd/languages/cpp.md | 8 ++ docs/pages/pmd/languages/cs.md | 8 ++ docs/pages/pmd/languages/dart.md | 8 ++ docs/pages/pmd/languages/fortran.md | 8 ++ docs/pages/pmd/languages/gherkin.md | 4 + docs/pages/pmd/languages/go.md | 8 ++ docs/pages/pmd/languages/groovy.md | 8 ++ docs/pages/pmd/languages/html.md | 11 +-- docs/pages/pmd/languages/java.md | 4 +- docs/pages/pmd/languages/js_ts.md | 5 ++ docs/pages/pmd/languages/jsp.md | 18 +---- docs/pages/pmd/languages/julia.md | 6 +- docs/pages/pmd/languages/kotlin.md | 3 + .../pmd/languages/language_properties.md | 2 +- docs/pages/pmd/languages/lua.md | 8 ++ docs/pages/pmd/languages/matlab.md | 8 ++ docs/pages/pmd/languages/modelica.md | 8 ++ docs/pages/pmd/languages/objectivec.md | 8 ++ docs/pages/pmd/languages/perl.md | 8 ++ docs/pages/pmd/languages/php.md | 8 ++ docs/pages/pmd/languages/plsql.md | 8 +- docs/pages/pmd/languages/python.md | 8 ++ docs/pages/pmd/languages/ruby.md | 8 ++ docs/pages/pmd/languages/scala.md | 8 ++ docs/pages/pmd/languages/swift.md | 8 ++ docs/pages/pmd/languages/tsql.md | 8 ++ docs/pages/pmd/languages/visualforce.md | 11 +-- docs/pages/pmd/languages/vm.md | 8 ++ docs/pages/pmd/languages/xml.md | 8 +- .../pmd/lang/vf/VfLanguageModule.java | 2 +- .../pmd/lang/vm/VmLanguageModule.java | 2 +- 37 files changed, 277 insertions(+), 56 deletions(-) create mode 100644 docs/pages/pmd/languages/cpp.md create mode 100644 docs/pages/pmd/languages/cs.md create mode 100644 docs/pages/pmd/languages/dart.md create mode 100644 docs/pages/pmd/languages/fortran.md create mode 100644 docs/pages/pmd/languages/go.md create mode 100644 docs/pages/pmd/languages/groovy.md create mode 100644 docs/pages/pmd/languages/lua.md create mode 100644 docs/pages/pmd/languages/matlab.md create mode 100644 docs/pages/pmd/languages/modelica.md create mode 100644 docs/pages/pmd/languages/objectivec.md create mode 100644 docs/pages/pmd/languages/perl.md create mode 100644 docs/pages/pmd/languages/php.md create mode 100644 docs/pages/pmd/languages/python.md create mode 100644 docs/pages/pmd/languages/ruby.md create mode 100644 docs/pages/pmd/languages/scala.md create mode 100644 docs/pages/pmd/languages/swift.md create mode 100644 docs/pages/pmd/languages/tsql.md create mode 100644 docs/pages/pmd/languages/vm.md diff --git a/docs/_data/sidebars/pmd_sidebar.yml b/docs/_data/sidebars/pmd_sidebar.yml index 6f3a7abe63..aaab0f02f1 100644 --- a/docs/_data/sidebars/pmd_sidebar.yml +++ b/docs/_data/sidebars/pmd_sidebar.yml @@ -409,6 +409,32 @@ entries: - title: Apex url: /pmd_languages_apex.html output: web, pdf + - title: C/C++ + url: /pmd_languages_cpp.html + output: web, pdf + - title: C# + url: /pmd_languages_cs.html + output: web, pdf + - title: Coco + url: /pmd_languages_coco.html + output: web, pdf + - title: Dart + url: /pmd_languages_dart.html + output: web, pdf + - title: Fortran + url: /pmd_languages_fortran.html + output: web, pdf + - title: Gherkin + url: /pmd_languages_gherkin.html + output: web, pdf + - title: Go + url: /pmd_languages_go.html + output: web, pdf + - title: Groovy + url: /pmd_languages_groovy.html + - title: HTML + url: /pmd_languages_html.html + output: web, pdf - title: Java url: /pmd_languages_java.html output: web, pdf @@ -418,30 +444,57 @@ entries: - title: JSP url: /pmd_languages_jsp.html output: web, pdf + - title: Julia + url: /pmd_languages_julia.html + output: web, pdf - title: Kotlin url: /pmd_languages_kotlin.html output: web, pdf + - title: Lua + url: /pmd_languages_lua.html + output: web, pdf + - title: Matlab + url: /pmd_languages_matlab.html + output: web, pdf + - title: Modelica + url: /pmd_languages_modelica.html + output: web, pdf + - title: Objective-C + url: /pmd_languages_objectivec.html + output: web, pdf + - title: Perl + url: /pmd_languages_perl.html + output: web, pdf + - title: PHP + url: /pmd_languages_php.html + output: web, pdf - title: PLSQL url: /pmd_languages_plsql.html output: web, pdf + - title: Python + url: /pmd_languages_python.html + output: web, pdf + - title: Ruby + url: /pmd_languages_ruby.html + output: web, pdf + - title: Scala + url: /pmd_languages_scala.html + output: web, pdf + - title: Swift + url: /pmd_languages_swift.html + output: web, pdf + - title: TSql + url: /pmd_languages_tsql.html + output: web, pdf - title: Visualforce url: /pmd_languages_visualforce.html output: web, pdf + - title: Velocity Template Language (VTL) + url: /pmd_languages_vm.html + output: web, pdf - title: XML and XML dialects url: /pmd_languages_xml.html output: web, pdf - - title: HTML - url: /pmd_languages_html.html - output: web, pdf - - title: Gherkin - url: /pmd_languages_gherkin.html - output: web, pdf - - title: Julia - url: /pmd_languages_julia.html - output: web, pdf - - title: Coco - url: /pmd_languages_coco.html - output: web, pdf - title: Developer Documentation output: web, pdf folderitems: diff --git a/docs/_includes/language_info.html b/docs/_includes/language_info.html index b36db72904..ac7fa20ff2 100644 --- a/docs/_includes/language_info.html +++ b/docs/_includes/language_info.html @@ -1,9 +1,9 @@ -
- Name: {{include.name}} +
+ Language Info for {{include.name}}
  • Implementation: {% jdoc include.implementation %}
  • -
  • id: {{include.id}}
  • +
  • Id: {{include.id}}
  • PMD: {% if include.supports_pmd %}✔️{% else %}❌{% endif %}
  • CPD: {% if include.supports_cpd %}✔️{% else %}❌{% endif %}
diff --git a/docs/_plugins/jdoc_namespace_tag.rb b/docs/_plugins/jdoc_namespace_tag.rb index 660de18783..88a85e7bbb 100644 --- a/docs/_plugins/jdoc_namespace_tag.rb +++ b/docs/_plugins/jdoc_namespace_tag.rb @@ -99,10 +99,11 @@ class JDocNamespaceDeclaration < Liquid::Tag private JDOC_NAMESPACE_MAP = "jdoc_nspaces" - RESERVED_NSPACES = ['ant', 'apex', 'cli', 'core', 'cpp', 'cs', 'dart', 'dist', 'doc', 'fortran', 'go', 'groovy', 'java', - 'javascript', 'jsp', + RESERVED_NSPACES = ['ant', 'apex', 'cli', 'coco', 'core', 'cpp', 'cs', 'dart', 'dist', 'doc', + 'fortran', 'gherkin', 'go', 'groovy', 'html', 'java', + 'javascript', 'jsp', 'julia', 'kotlin', 'lang-test', 'lua', 'matlab', 'objectivec', 'perl', 'php', 'plsql', 'python', 'ruby', 'scala', 'swift', - 'test', 'test-schema', 'ui', + 'test', 'test-schema', 'tsql', 'ui', 'modelica', 'visualforce', 'vm', 'xml'].flat_map {|m| [m, "pmd-" + m]} def self.make_base_namespaces diff --git a/docs/css/customstyles.css b/docs/css/customstyles.css index 3324e4720f..98b6bee046 100644 --- a/docs/css/customstyles.css +++ b/docs/css/customstyles.css @@ -1008,8 +1008,11 @@ span.soft { } @media (min-height: 600px) and (min-width: 990px) { + /* sticky sidebar for big screens */ #mysidebar { position: fixed !important; + overflow: scroll; + height: 80%; } } @@ -1268,3 +1271,7 @@ h4.panel-title { a.edit-header { font-size: 15px; } + +.language-info { + margin: 2em; +} diff --git a/docs/pages/pmd/languages/apex.md b/docs/pages/pmd/languages/apex.md index cf93b81a65..dc2478d59c 100644 --- a/docs/pages/pmd/languages/apex.md +++ b/docs/pages/pmd/languages/apex.md @@ -1,13 +1,13 @@ --- title: Apex support permalink: pmd_languages_apex.html -author: Clément Fournier last_updated: September 2023 (7.0.0) +author: Clément Fournier tags: [languages] summary: "Apex-specific features and guidance" --- -{% include language_info.html name='Apex' id='apex' implementation='apex::lang.apex.ApexLanguageModule' supports_pmd='✔️' supports_cpd='✔️' %} +{% include language_info.html name='Apex' id='apex' implementation='apex::lang.apex.ApexLanguageModule' supports_pmd=true supports_cpd=true %} ## Metrics framework diff --git a/docs/pages/pmd/languages/coco.md b/docs/pages/pmd/languages/coco.md index 44a6b31939..c3d24166ca 100644 --- a/docs/pages/pmd/languages/coco.md +++ b/docs/pages/pmd/languages/coco.md @@ -1,8 +1,12 @@ --- title: Coco permalink: pmd_languages_coco.html +last_updated: September 2023 (7.0.0) +tags: [languages] --- +{% include language_info.html name='Coco' id='coco' implementation='coco::lang.coco.CocoLanguageModule' supports_cpd=true %} + Coco is a modern programming language designed specifically for building event-driven software. It is part of the Coco Platform from . diff --git a/docs/pages/pmd/languages/cpp.md b/docs/pages/pmd/languages/cpp.md new file mode 100644 index 0000000000..ebd2f43fe1 --- /dev/null +++ b/docs/pages/pmd/languages/cpp.md @@ -0,0 +1,8 @@ +--- +title: C/C++ +permalink: pmd_languages_cpp.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='C++' id='cpp' implementation='cpp::lang.cpp.CppLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/cs.md b/docs/pages/pmd/languages/cs.md new file mode 100644 index 0000000000..8d9d6cd7ba --- /dev/null +++ b/docs/pages/pmd/languages/cs.md @@ -0,0 +1,8 @@ +--- +title: C# +permalink: pmd_languages_cs.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='C#' id='cs' implementation='cs::lang.cs.CsLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/dart.md b/docs/pages/pmd/languages/dart.md new file mode 100644 index 0000000000..14d2b80142 --- /dev/null +++ b/docs/pages/pmd/languages/dart.md @@ -0,0 +1,8 @@ +--- +title: Dart +permalink: pmd_languages_dart.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='Dart' id='dart' implementation='dart::lang.dart.DartLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/fortran.md b/docs/pages/pmd/languages/fortran.md new file mode 100644 index 0000000000..b964cd9aba --- /dev/null +++ b/docs/pages/pmd/languages/fortran.md @@ -0,0 +1,8 @@ +--- +title: Fortran +permalink: pmd_languages_fortran.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='Fortran' id='fortran' implementation='fortran::lang.fortran.FortranLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/gherkin.md b/docs/pages/pmd/languages/gherkin.md index 123bae7d49..f7cf900635 100644 --- a/docs/pages/pmd/languages/gherkin.md +++ b/docs/pages/pmd/languages/gherkin.md @@ -1,8 +1,12 @@ --- title: Gherkin permalink: pmd_languages_gherkin.html +last_updated: September 2023 (7.0.0) +tags: [languages] --- +{% include language_info.html name='Gherkin' id='gherkin' implementation='gherkin::lang.gherkin.GherkinLanguageModule' supports_cpd=true %} + The [Gherkin](https://cucumber.io/docs/gherkin/) language is used to define test cases for the [Cucumber](https://cucumber.io/) testing tool for behavior-driven development. The Gherkin syntax is designed to be non-technical, making it human-readable for a wide audience. diff --git a/docs/pages/pmd/languages/go.md b/docs/pages/pmd/languages/go.md new file mode 100644 index 0000000000..0a7a9ded08 --- /dev/null +++ b/docs/pages/pmd/languages/go.md @@ -0,0 +1,8 @@ +--- +title: Go +permalink: pmd_languages_go.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='Go' id='go' implementation='go::lang.go.GoLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/groovy.md b/docs/pages/pmd/languages/groovy.md new file mode 100644 index 0000000000..30afba2426 --- /dev/null +++ b/docs/pages/pmd/languages/groovy.md @@ -0,0 +1,8 @@ +--- +title: Groovy +permalink: pmd_languages_groovy.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='Groovy' id='groovy' implementation='groovy::lang.groovy.GroovyLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/html.md b/docs/pages/pmd/languages/html.md index 9c905571e1..6766276af8 100644 --- a/docs/pages/pmd/languages/html.md +++ b/docs/pages/pmd/languages/html.md @@ -1,9 +1,12 @@ --- title: Processing HTML files permalink: pmd_languages_html.html -last_updated: April 2022 (6.45.0) +last_updated: September 2023 (7.0.0) +tags: [languages] --- +{% include language_info.html name='HTML' id='html' implementation='html::lang.html.HtmlLanguageModule' supports_pmd=true supports_cpd=true %} + ## The HTML language module **Since:** 6.45.0 @@ -14,11 +17,9 @@ last_updated: April 2022 (6.45.0) The HTML language module uses [jsoup](https://jsoup.org/) for parsing. -XPath 2.0 rules are supported, but the DOM is not always a typical XML/XPath DOM. +XPath rules are supported, but the DOM is not always a typical XML/XPath DOM. In the Designer, text nodes appear as nodes with name "#text", but they can be selected as usual using `text()`. -XML Namespaces are not supported. The local name of attributes include the prefix, +XML Namespaces are not supported. The local name of attributes includes the prefix, so that you have to select attributes by e.g. `//*[@*[local-name() = 'if:true']]`. - -Only XPath 1.0 rules are not supported. diff --git a/docs/pages/pmd/languages/java.md b/docs/pages/pmd/languages/java.md index e9aaaea0a0..137e930a75 100644 --- a/docs/pages/pmd/languages/java.md +++ b/docs/pages/pmd/languages/java.md @@ -2,12 +2,12 @@ title: Java support permalink: pmd_languages_java.html author: Clément Fournier -last_updated: March 2021 (7.0.0) +last_updated: September 2023 (7.0.0) tags: [languages] summary: "Java-specific features and guidance" --- -{% include language_info.html name='Java' id='java' implementation='java::lang.java.JavaLanguageModule' supports_pmd='✔️' supports_cpd='✔️' %} +{% include language_info.html name='Java' id='java' implementation='java::lang.java.JavaLanguageModule' supports_pmd=true supports_cpd=true %} {% include warning.html content="WIP, todo for pmd 7" %} diff --git a/docs/pages/pmd/languages/js_ts.md b/docs/pages/pmd/languages/js_ts.md index 7633105a2d..daefd54b76 100644 --- a/docs/pages/pmd/languages/js_ts.md +++ b/docs/pages/pmd/languages/js_ts.md @@ -1,10 +1,15 @@ --- title: JavaScript and TypeScript permalink: pmd_languages_js_ts.html +last_updated: September 2023 (7.0.0) tags: [languages] summary: "JavaScript and TypeScript infos" --- +{% include language_info.html name='JavaScript' id='ecmascript' implementation='javascript::lang.ecmascript.EcmascriptLanguageModule' supports_pmd=true supports_cpd=true %} +{% include language_info.html name='TypeScript' id='ts' implementation='javascript::lang.typescript.TsLanguageModule' supports_cpd=true %} + + **JavaScript** support is using [Rhino](https://github.com/mozilla/rhino) for parsing and supports CPD as well as PMD with rules. diff --git a/docs/pages/pmd/languages/jsp.md b/docs/pages/pmd/languages/jsp.md index 31b4995e54..3f6809438e 100644 --- a/docs/pages/pmd/languages/jsp.md +++ b/docs/pages/pmd/languages/jsp.md @@ -1,11 +1,14 @@ --- title: JSP Support permalink: pmd_languages_jsp.html -author: Pieter Vanraemdonck +last_updated: September 2023 (7.0.0) tags: [languages] +author: Pieter Vanraemdonck summary: "JSP-specific features and guidance" --- +{% include language_info.html name='Java Server Pages' id='jsp' implementation='jsp::lang.jsp.JspLanguageModule' supports_pmd=true supports_cpd=true %} + ## What is currently supported and what is not In short, JSP files that are XHTML-compliant, are supported. @@ -38,16 +41,3 @@ The XHTML support means that: further broken down. If you want to create rules that check the code inside EL expressions or JSP scriptlets (a.o.), you currently would have to do "manual" string manipulation (e.g. using regular expressions). - -## How to use it - -Using the command-line interface, two new options can be used in the arguments string: - -* "-jsp" : this triggers checking JSP files (they are not checked by default) -* "-nojava" : this tells PMD not to check java source files (they are checked by default) - -Using the Ant task, you decide if PMD must check JSP files by choosing -what files are given to the PMD task. If you use a fileset that -contains only ".java" files, JSP files obviously will not be checked. - -If you want to call the PMD API for checking JSP files, you should investigate the javadoc of PMD. diff --git a/docs/pages/pmd/languages/julia.md b/docs/pages/pmd/languages/julia.md index de36f3e9ea..a064ed1eb8 100644 --- a/docs/pages/pmd/languages/julia.md +++ b/docs/pages/pmd/languages/julia.md @@ -1,9 +1,13 @@ --- title: Julia permalink: pmd_languages_julia.html +last_updated: September 2023 (7.0.0) +tags: [languages] --- -The [Julia](https://julialang.org/) is dynamically typed, like a scripting language, +{% include language_info.html name='Julia' id='julia' implementation='julia::lang.julia.JuliaLanguageModule' supports_cpd=true %} + +The [Julia](https://julialang.org/) language is dynamically typed, like a scripting language, and has good support for interactive use. Julia was designed from the beginning for high performance. Julia programs compile to efficient native code for multiple platforms via LLVM. diff --git a/docs/pages/pmd/languages/kotlin.md b/docs/pages/pmd/languages/kotlin.md index ad9297a248..6e2735fb07 100644 --- a/docs/pages/pmd/languages/kotlin.md +++ b/docs/pages/pmd/languages/kotlin.md @@ -1,10 +1,13 @@ --- title: Kotlin Support permalink: pmd_languages_kotlin.html +last_updated: September 2023 (7.0.0) tags: [languages] summary: "Kotlin-specific features and guidance" --- +{% include language_info.html name='Kotlin' id='kotlin' implementation='kotlin::lang.kotlin.JspLanguageModule' supports_pmd=true supports_cpd=true %} + Kotlin support in PMD is based on the official grammar from . Java-based rules and XPath-based rules are supported. diff --git a/docs/pages/pmd/languages/language_properties.md b/docs/pages/pmd/languages/language_properties.md index d8adf105a9..91f396489f 100644 --- a/docs/pages/pmd/languages/language_properties.md +++ b/docs/pages/pmd/languages/language_properties.md @@ -108,7 +108,7 @@ The Java language can be configured with the following properties: Environment variable: `PMD_APEX_ROOT_DIRECTORY` -## VisualForce language properties +## Visualforce language properties - `apexDirectories`: Comma separated list of directories for Apex classes. Absolute or relative to the Visualforce directory. Default is `../classes`. Specifying an diff --git a/docs/pages/pmd/languages/lua.md b/docs/pages/pmd/languages/lua.md new file mode 100644 index 0000000000..b35a57b4da --- /dev/null +++ b/docs/pages/pmd/languages/lua.md @@ -0,0 +1,8 @@ +--- +title: Lua +permalink: pmd_languages_lua.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='Lua' id='lua' implementation='lua::lang.lua.LuaLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/matlab.md b/docs/pages/pmd/languages/matlab.md new file mode 100644 index 0000000000..5356fb3941 --- /dev/null +++ b/docs/pages/pmd/languages/matlab.md @@ -0,0 +1,8 @@ +--- +title: Matlab +permalink: pmd_languages_matlab.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='Matlab' id='matlab' implementation='matlab::lang.matlab.MatlabLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/modelica.md b/docs/pages/pmd/languages/modelica.md new file mode 100644 index 0000000000..30572d233e --- /dev/null +++ b/docs/pages/pmd/languages/modelica.md @@ -0,0 +1,8 @@ +--- +title: Modelica +permalink: pmd_languages_modelica.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='Modelica' id='modelica' implementation='modelica::lang.modelica.ModelicaLanguageModule' supports_pmd=true supports_cpd=true %} diff --git a/docs/pages/pmd/languages/objectivec.md b/docs/pages/pmd/languages/objectivec.md new file mode 100644 index 0000000000..b8624dcb64 --- /dev/null +++ b/docs/pages/pmd/languages/objectivec.md @@ -0,0 +1,8 @@ +--- +title: Objective-C +permalink: pmd_languages_objectivec.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='objectivec' id='objectivec' implementation='objectivec::lang.objectivec.ObjectiveCLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/perl.md b/docs/pages/pmd/languages/perl.md new file mode 100644 index 0000000000..41993b40d9 --- /dev/null +++ b/docs/pages/pmd/languages/perl.md @@ -0,0 +1,8 @@ +--- +title: Perl +permalink: pmd_languages_perl.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='Perl' id='perl' implementation='perl::lang.perl.PerlLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/php.md b/docs/pages/pmd/languages/php.md new file mode 100644 index 0000000000..f226e58960 --- /dev/null +++ b/docs/pages/pmd/languages/php.md @@ -0,0 +1,8 @@ +--- +title: PHP +permalink: pmd_languages_php.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='PHP' id='php' implementation='php::lang.php.PhpLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/plsql.md b/docs/pages/pmd/languages/plsql.md index 38f22bab03..34c195426f 100644 --- a/docs/pages/pmd/languages/plsql.md +++ b/docs/pages/pmd/languages/plsql.md @@ -1,11 +1,13 @@ --- title: PLSQL Support permalink: pmd_languages_plsql.html -last_updated: March 2021 (6.33.0) +last_updated: September 2023 (7.0.0) tags: [languages] summary: "PLSQL-specific features and guidance" --- +{% include language_info.html name='PLSQL' id='plsql' implementation='plsql::lang.plsql.PLSQLLanguageModule' supports_pmd=true supports_cpd=true %} + ## Parsing Exclusions The grammar for PLSQL used in PMD has several bugs and might not parse all DDL scripts @@ -17,9 +19,9 @@ which cause PMD to treat the source in between these comments more or less like a multi-line comment, or in other words, just not try to parse them. It is good practice to include a reason for excluding inside the -`-- PMD-EXCUDE-BEGIN` comment separated by a colon. +`-- PMD-EXCLUDE-BEGIN` comment separated by a colon. -The `PMD-EXCLUDE-BEGIN` and `PMD-EXLUDE-END` comment lines must not contain +The `PMD-EXCLUDE-BEGIN` and `PMD-EXCLUDE-END` comment lines must not contain other statements, e.g. `do_xy(); -- PMD-EXCLUDE-BEGIN` is invalid. Example: diff --git a/docs/pages/pmd/languages/python.md b/docs/pages/pmd/languages/python.md new file mode 100644 index 0000000000..97a2e609c0 --- /dev/null +++ b/docs/pages/pmd/languages/python.md @@ -0,0 +1,8 @@ +--- +title: Python +permalink: pmd_languages_python.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='Python' id='python' implementation='python::lang.python.PythonLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/ruby.md b/docs/pages/pmd/languages/ruby.md new file mode 100644 index 0000000000..e896bff43d --- /dev/null +++ b/docs/pages/pmd/languages/ruby.md @@ -0,0 +1,8 @@ +--- +title: Ruby +permalink: pmd_languages_ruby.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='Ruby' id='ruby' implementation='ruby::lang.ruby.RubyLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/scala.md b/docs/pages/pmd/languages/scala.md new file mode 100644 index 0000000000..d5c6b13d82 --- /dev/null +++ b/docs/pages/pmd/languages/scala.md @@ -0,0 +1,8 @@ +--- +title: Scala +permalink: pmd_languages_scala.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='Scala' id='scala' implementation='scala::lang.scala.ScalaLanguageModule' supports_pmd=true supports_cpd=true %} diff --git a/docs/pages/pmd/languages/swift.md b/docs/pages/pmd/languages/swift.md new file mode 100644 index 0000000000..548f8e75f8 --- /dev/null +++ b/docs/pages/pmd/languages/swift.md @@ -0,0 +1,8 @@ +--- +title: Swift +permalink: pmd_languages_swift.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='Swift' id='swift' implementation='swift::lang.swift.SwiftLanguageModule' supports_pmd=true supports_cpd=true %} diff --git a/docs/pages/pmd/languages/tsql.md b/docs/pages/pmd/languages/tsql.md new file mode 100644 index 0000000000..03e7afed4f --- /dev/null +++ b/docs/pages/pmd/languages/tsql.md @@ -0,0 +1,8 @@ +--- +title: TSql +permalink: pmd_languages_tsql.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='TSql' id='tsql' implementation='tsql::lang.tsql.TSqlLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/visualforce.md b/docs/pages/pmd/languages/visualforce.md index 84c070d10f..025956d0a5 100644 --- a/docs/pages/pmd/languages/visualforce.md +++ b/docs/pages/pmd/languages/visualforce.md @@ -1,19 +1,16 @@ --- title: Visualforce Support permalink: pmd_languages_visualforce.html -author: Andreas Dangel last_updated: September 2023 +tags: [languages] +author: Andreas Dangel --- -Implementation: {% jdoc visualforce::lang.vf.VfLanguageModule %} -Name: Salesforce VisualForce -id: vf -PMD: yes -CPD: yes +{% include language_info.html name='Salesforce Visualforce' id='vf' implementation='visualforce::lang.vf.VfLanguageModule' supports_pmd=true supports_cpd=true %} ## Language Properties -See [VisualForce language properties](pmd_languages_configuration.html#visualforce-language-properties) +See [Visualforce language properties](pmd_languages_configuration.html#visualforce-language-properties) ## Type resolution diff --git a/docs/pages/pmd/languages/vm.md b/docs/pages/pmd/languages/vm.md new file mode 100644 index 0000000000..3c878791e2 --- /dev/null +++ b/docs/pages/pmd/languages/vm.md @@ -0,0 +1,8 @@ +--- +title: Velocity Template Language (VTL) +permalink: pmd_languages_vm.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +{% include language_info.html name='Velocity Template Language (VTL)' id='vm' implementation='vm::lang.vm.VmLanguageModule' supports_pmd=true supports_cpd=true %} diff --git a/docs/pages/pmd/languages/xml.md b/docs/pages/pmd/languages/xml.md index 409194aa63..9eeac963f9 100644 --- a/docs/pages/pmd/languages/xml.md +++ b/docs/pages/pmd/languages/xml.md @@ -1,9 +1,15 @@ --- title: Processing XML files permalink: pmd_languages_xml.html -last_updated: March 2022 (6.44.0) +last_updated: September 2023 (7.0.0) +tags: [languages] --- +{% include language_info.html name='Maven POM' id='pom' implementation='xml::lang.pom.PomLanguageModule' supports_pmd=true supports_cpd=true %} +{% include language_info.html name='WSDL' id='wsdl' implementation='xml::lang.wsdl.WsdlLanguageModule' supports_pmd=true supports_cpd=true %} +{% include language_info.html name='XML' id='xml' implementation='xml::lang.xml.XmlLanguageModule' supports_pmd=true supports_cpd=true %} +{% include language_info.html name='XSL' id='xsl' implementation='xml::lang.xsl.XslLanguageModule' supports_pmd=true supports_cpd=true %} + ## The XML language module PMD has an XML language module which exposes the [DOM](https://de.wikipedia.org/wiki/Document_Object_Model) diff --git a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/VfLanguageModule.java b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/VfLanguageModule.java index b6d6bd25d6..f596902c2b 100644 --- a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/VfLanguageModule.java +++ b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/VfLanguageModule.java @@ -17,7 +17,7 @@ import net.sourceforge.pmd.lang.vf.cpd.VfTokenizer; */ public class VfLanguageModule extends SimpleLanguageModuleBase implements CpdCapableLanguage { static final String ID = "vf"; - static final String NAME = "Salesforce VisualForce"; + static final String NAME = "Salesforce Visualforce"; public VfLanguageModule() { super(LanguageMetadata.withId(ID).name(NAME) diff --git a/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/VmLanguageModule.java b/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/VmLanguageModule.java index ce35a109ec..b441d472ae 100644 --- a/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/VmLanguageModule.java +++ b/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/VmLanguageModule.java @@ -15,7 +15,7 @@ import net.sourceforge.pmd.lang.vm.cpd.VmTokenizer; */ public class VmLanguageModule extends SimpleLanguageModuleBase { static final String ID = "vm"; - static final String NAME = "VM"; + static final String NAME = "Velocity Template Language (VTL)"; public VmLanguageModule() { super(LanguageMetadata.withId(ID).name(NAME) From 91a1c21680ed281f4036f254d03097a6c24cb84e Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 1 Sep 2023 13:00:45 +0200 Subject: [PATCH 11/58] [doc] jdoc tag: Report location incl. linenumber for warnings --- docs/_plugins/javadoc_tag.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/_plugins/javadoc_tag.rb b/docs/_plugins/javadoc_tag.rb index 2016c442f7..c31b9a655f 100644 --- a/docs/_plugins/javadoc_tag.rb +++ b/docs/_plugins/javadoc_tag.rb @@ -143,7 +143,7 @@ class JavadocTag < Liquid::Tag artifact_name, @type_fqcn = JDocNamespaceDeclaration::parse_fqcn(@type_fqcn, var_ctx) resolved_type = JavadocTag::fqcn_type(artifact_name, @type_fqcn) - JavadocTag::diagnose(artifact_name, @type_fqcn, @is_package_ref, resolved_type) + diagnose(var_ctx, artifact_name, @type_fqcn, @is_package_ref, resolved_type) # Expand FQCN of arguments @member_suffix.gsub!(JDocNamespaceDeclaration::NAMESPACED_FQCN_REGEX) {|fqcn| JDocNamespaceDeclaration::parse_fqcn(fqcn, var_ctx)[1]} @@ -221,15 +221,18 @@ class JavadocTag < Liquid::Tag BASE_PMD_DIR = File.join(File.expand_path(File.dirname(__FILE__)), "..", "..") - def self.diagnose(artifact_id, fqcn, expect_package, resolved_type) + def diagnose(context, artifact_id, fqcn, expect_package, resolved_type) tag_name= expect_package ? "jdoc_package" : "jdoc" + # Note: the line numbers don't account for the frontmatter lines + # See https://github.com/jekyll/jekyll/issues/7192 and https://github.com/jekyll/jekyll/pull/9385 + location = "#{context['page']['path']}:#{@line_number}+?" if resolved_type == :package && !expect_package - warn "\e[33;1m#{tag_name} generated link to #{fqcn}, but it was found to be a package name. Did you mean to use jdoc_package instead of jdoc?\e[0m" + warn "\e[33;1m#{location}: #{tag_name} generated link to #{fqcn}, but it was found to be a package name. Did you mean to use jdoc_package instead of jdoc?\e[0m" elsif resolved_type == :file && expect_package - warn "\e[33;1m#{tag_name} generated link to #{fqcn}, but it was found to be a java file name. Did you mean to use jdoc instead of jdoc_package?\e[0m" + warn "\e[33;1m#{location}: #{tag_name} generated link to #{fqcn}, but it was found to be a java file name. Did you mean to use jdoc instead of jdoc_package?\e[0m" elsif !resolved_type - warn "\e[33;1m#{tag_name} generated link to #{fqcn}, but the #{expect_package ? "directory" : "source file"} couldn't be found in the source tree of #{artifact_id}\e[0m" + warn "\e[33;1m#{location}: #{tag_name} generated link to #{fqcn}, but the #{expect_package ? "directory" : "source file"} couldn't be found in the source tree of #{artifact_id}\e[0m" end end From 92b2718da778ac637f551b1a1ba9371878b6a685 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 4 Sep 2023 19:09:21 +0200 Subject: [PATCH 12/58] Fix unit test --- pmd-doc/src/test/resources/expected/pmd_sidebar.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pmd-doc/src/test/resources/expected/pmd_sidebar.yml b/pmd-doc/src/test/resources/expected/pmd_sidebar.yml index 685cfc5851..756c9ece74 100644 --- a/pmd-doc/src/test/resources/expected/pmd_sidebar.yml +++ b/pmd-doc/src/test/resources/expected/pmd_sidebar.yml @@ -93,7 +93,7 @@ entries: - title: null output: web, pdf subfolders: - - title: Salesforce VisualForce Rules + - title: Salesforce Visualforce Rules output: web, pdf subfolderitems: - title: Index @@ -120,7 +120,7 @@ entries: - title: null output: web, pdf subfolders: - - title: VM Rules + - title: Velocity Template Language (VTL) Rules output: web, pdf subfolderitems: - title: Index From 81b1d7e32b7a2b01cd642c5e91a1479340aace5d Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 4 Sep 2023 19:18:50 +0200 Subject: [PATCH 13/58] [doc] Add tags PmdCapableLanguage and CpdCapableLanguage --- docs/_data/sidebars/pmd_sidebar.yml | 7 ++++-- docs/_data/tags.yml | 2 ++ .../adding_a_new_antlr_based_language.md | 22 ++++++++++++++++++ .../adding_a_new_javacc_based_language.md | 23 +++++++++++++++++++ .../adding_new_cpd_language.md | 21 +++++++++++++++++ docs/pages/pmd/languages/apex.md | 2 +- docs/pages/pmd/languages/coco.md | 2 +- docs/pages/pmd/languages/cpp.md | 2 +- docs/pages/pmd/languages/cs.md | 2 +- docs/pages/pmd/languages/dart.md | 2 +- docs/pages/pmd/languages/fortran.md | 2 +- docs/pages/pmd/languages/gherkin.md | 2 +- docs/pages/pmd/languages/go.md | 2 +- docs/pages/pmd/languages/groovy.md | 2 +- docs/pages/pmd/languages/html.md | 2 +- docs/pages/pmd/languages/index.md | 9 ++++++++ docs/pages/pmd/languages/java.md | 2 +- docs/pages/pmd/languages/js_ts.md | 2 +- docs/pages/pmd/languages/jsp.md | 2 +- docs/pages/pmd/languages/julia.md | 2 +- docs/pages/pmd/languages/kotlin.md | 2 +- docs/pages/pmd/languages/lua.md | 2 +- docs/pages/pmd/languages/matlab.md | 2 +- docs/pages/pmd/languages/modelica.md | 2 +- docs/pages/pmd/languages/objectivec.md | 2 +- docs/pages/pmd/languages/perl.md | 2 +- docs/pages/pmd/languages/php.md | 2 +- docs/pages/pmd/languages/plsql.md | 2 +- docs/pages/pmd/languages/python.md | 2 +- docs/pages/pmd/languages/ruby.md | 2 +- docs/pages/pmd/languages/scala.md | 2 +- docs/pages/pmd/languages/swift.md | 2 +- docs/pages/pmd/languages/tsql.md | 2 +- docs/pages/pmd/languages/visualforce.md | 2 +- docs/pages/pmd/languages/vm.md | 2 +- docs/pages/pmd/languages/xml.md | 2 +- docs/pages/tags/tag_CpdCapableLanguage.md | 11 +++++++++ docs/pages/tags/tag_PmdCapableLanguage.md | 11 +++++++++ 38 files changed, 134 insertions(+), 32 deletions(-) create mode 100644 docs/pages/pmd/languages/index.md create mode 100644 docs/pages/tags/tag_CpdCapableLanguage.md create mode 100644 docs/pages/tags/tag_PmdCapableLanguage.md diff --git a/docs/_data/sidebars/pmd_sidebar.yml b/docs/_data/sidebars/pmd_sidebar.yml index aaab0f02f1..a59bd7ef3c 100644 --- a/docs/_data/sidebars/pmd_sidebar.yml +++ b/docs/_data/sidebars/pmd_sidebar.yml @@ -313,7 +313,7 @@ entries: - title: null output: web, pdf subfolders: - - title: Salesforce VisualForce Rules + - title: Salesforce Visualforce Rules output: web, pdf subfolderitems: - title: Index @@ -349,7 +349,7 @@ entries: - title: null output: web, pdf subfolders: - - title: VM Rules + - title: Velocity Template Language (VTL) Rules output: web, pdf subfolderitems: - title: Index @@ -403,6 +403,9 @@ entries: - title: Language-Specific Documentation output: web, pdf folderitems: + - title: Overview + url: /pmd_languages_index.html + output: web, pdf - title: Language configuration url: /pmd_languages_configuration.html output: web, pdf diff --git a/docs/_data/tags.yml b/docs/_data/tags.yml index 88d01cea93..b543f30c4d 100644 --- a/docs/_data/tags.yml +++ b/docs/_data/tags.yml @@ -10,3 +10,5 @@ allowed-tags: - tools # About tools and integrations, Maven, gradle, etc. - devdocs # About PMD internals, contributing, building, projects - languages # Language-specific documentation pages + - PmdCapableLanguage + - CpdCapableLanguage diff --git a/docs/pages/pmd/devdocs/major_contributions/adding_a_new_antlr_based_language.md b/docs/pages/pmd/devdocs/major_contributions/adding_a_new_antlr_based_language.md index 1433a5fe73..c1b8d09d9e 100644 --- a/docs/pages/pmd/devdocs/major_contributions/adding_a_new_antlr_based_language.md +++ b/docs/pages/pmd/devdocs/major_contributions/adding_a_new_antlr_based_language.md @@ -230,3 +230,25 @@ definitely don't come for free. It is much effort and requires perseverance to i This will load all rulesets and verify, that all required attributes are provided. *Note:* You'll need to add your ruleset to `categories.properties`, so that it can be found. + +### 15. Create documentation page +Finishing up your new language module by adding a page in the documentation. Create a new markdown file +`.md` in `docs/pages/pmd/languages/`. This file should have the following frontmatter: + +``` +--- +title: +permalink: pmd_languages_.html +last_updated: () +tags: [languages, PmdCapableLanguage, CpdCapableLanguage] +--- +``` + +On this page, language specifics can be documented, e.g. when the language was first supported by PMD. +There is also the following Jekyll Include, that creates summary box for the language: + +``` +{% raw %} +{% include language_info.html name='' id='' implementation='::lang..LanguageModule' supports_cpd=true supports_pmd=true %} +{% endraw %} +``` diff --git a/docs/pages/pmd/devdocs/major_contributions/adding_a_new_javacc_based_language.md b/docs/pages/pmd/devdocs/major_contributions/adding_a_new_javacc_based_language.md index bb0ffb6f8a..fb2f7fa6a2 100644 --- a/docs/pages/pmd/devdocs/major_contributions/adding_a_new_javacc_based_language.md +++ b/docs/pages/pmd/devdocs/major_contributions/adding_a_new_javacc_based_language.md @@ -183,6 +183,29 @@ The Scala module also has a test, written in Kotlin instead of Java: *Note:* You'll need to add your category ruleset to `categories.properties`, so that it can be found. +### 13. Create documentation page +Finishing up your new language module by adding a page in the documentation. Create a new markdown file +`.md` in `docs/pages/pmd/languages/`. This file should have the following frontmatter: + +``` +--- +title: +permalink: pmd_languages_.html +last_updated: () +tags: [languages, PmdCapableLanguage, CpdCapableLanguage] +--- +``` + +On this page, language specifics can be documented, e.g. when the language was first supported by PMD. +There is also the following Jekyll Include, that creates summary box for the language: + +``` +{% raw %} +{% include language_info.html name='' id='' implementation='::lang..LanguageModule' supports_cpd=true supports_pmd=true %} +{% endraw %} +``` + + ## Debugging with Rule Designer When implementing your grammar it may be very useful to see how PMD parses your example files. diff --git a/docs/pages/pmd/devdocs/major_contributions/adding_new_cpd_language.md b/docs/pages/pmd/devdocs/major_contributions/adding_new_cpd_language.md index bb3b232c46..665aa7ce18 100644 --- a/docs/pages/pmd/devdocs/major_contributions/adding_new_cpd_language.md +++ b/docs/pages/pmd/devdocs/major_contributions/adding_new_cpd_language.md @@ -79,6 +79,27 @@ If your language only supports CPD, then you can subclass {% jdoc core::lang.imp 5. Add some tests for your tokenizer by following the [section below](#testing-your-implementation). +6. Finishing up your new language module by adding a page in the documentation. Create a new markdown file + `.md` in `docs/pages/pmd/languages/`. This file should have the following frontmatter: + + ``` + --- + title: + permalink: pmd_languages_.html + last_updated: () + tags: [languages, CpdCapableLanguage] + --- + ``` + + On this page, language specifics can be documented, e.g. when the language was first supported by PMD. + There is also the following Jekyll Include, that creates summary box for the language: + + ``` + {% raw %} + {% include language_info.html name='' id='' implementation='::lang..LanguageModule' supports_cpd=true %} + {% endraw %} + ``` + ### Declaring tokenizer options To make the tokenizer configurable, first define some property descriptors using diff --git a/docs/pages/pmd/languages/apex.md b/docs/pages/pmd/languages/apex.md index dc2478d59c..5f32a7aee6 100644 --- a/docs/pages/pmd/languages/apex.md +++ b/docs/pages/pmd/languages/apex.md @@ -3,7 +3,7 @@ title: Apex support permalink: pmd_languages_apex.html last_updated: September 2023 (7.0.0) author: Clément Fournier -tags: [languages] +tags: [languages, PmdCapableLanguage, CpdCapableLanguage] summary: "Apex-specific features and guidance" --- diff --git a/docs/pages/pmd/languages/coco.md b/docs/pages/pmd/languages/coco.md index c3d24166ca..86a2c47dae 100644 --- a/docs/pages/pmd/languages/coco.md +++ b/docs/pages/pmd/languages/coco.md @@ -2,7 +2,7 @@ title: Coco permalink: pmd_languages_coco.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='Coco' id='coco' implementation='coco::lang.coco.CocoLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/cpp.md b/docs/pages/pmd/languages/cpp.md index ebd2f43fe1..aae5e70922 100644 --- a/docs/pages/pmd/languages/cpp.md +++ b/docs/pages/pmd/languages/cpp.md @@ -2,7 +2,7 @@ title: C/C++ permalink: pmd_languages_cpp.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='C++' id='cpp' implementation='cpp::lang.cpp.CppLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/cs.md b/docs/pages/pmd/languages/cs.md index 8d9d6cd7ba..119c0cab51 100644 --- a/docs/pages/pmd/languages/cs.md +++ b/docs/pages/pmd/languages/cs.md @@ -2,7 +2,7 @@ title: C# permalink: pmd_languages_cs.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='C#' id='cs' implementation='cs::lang.cs.CsLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/dart.md b/docs/pages/pmd/languages/dart.md index 14d2b80142..bf2b89343f 100644 --- a/docs/pages/pmd/languages/dart.md +++ b/docs/pages/pmd/languages/dart.md @@ -2,7 +2,7 @@ title: Dart permalink: pmd_languages_dart.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='Dart' id='dart' implementation='dart::lang.dart.DartLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/fortran.md b/docs/pages/pmd/languages/fortran.md index b964cd9aba..5cc6408002 100644 --- a/docs/pages/pmd/languages/fortran.md +++ b/docs/pages/pmd/languages/fortran.md @@ -2,7 +2,7 @@ title: Fortran permalink: pmd_languages_fortran.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='Fortran' id='fortran' implementation='fortran::lang.fortran.FortranLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/gherkin.md b/docs/pages/pmd/languages/gherkin.md index f7cf900635..11f1afe3a0 100644 --- a/docs/pages/pmd/languages/gherkin.md +++ b/docs/pages/pmd/languages/gherkin.md @@ -2,7 +2,7 @@ title: Gherkin permalink: pmd_languages_gherkin.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='Gherkin' id='gherkin' implementation='gherkin::lang.gherkin.GherkinLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/go.md b/docs/pages/pmd/languages/go.md index 0a7a9ded08..492c986a3a 100644 --- a/docs/pages/pmd/languages/go.md +++ b/docs/pages/pmd/languages/go.md @@ -2,7 +2,7 @@ title: Go permalink: pmd_languages_go.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='Go' id='go' implementation='go::lang.go.GoLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/groovy.md b/docs/pages/pmd/languages/groovy.md index 30afba2426..4c4038b99a 100644 --- a/docs/pages/pmd/languages/groovy.md +++ b/docs/pages/pmd/languages/groovy.md @@ -2,7 +2,7 @@ title: Groovy permalink: pmd_languages_groovy.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='Groovy' id='groovy' implementation='groovy::lang.groovy.GroovyLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/html.md b/docs/pages/pmd/languages/html.md index 6766276af8..5df8e57356 100644 --- a/docs/pages/pmd/languages/html.md +++ b/docs/pages/pmd/languages/html.md @@ -2,7 +2,7 @@ title: Processing HTML files permalink: pmd_languages_html.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, PmdCapableLanguage, CpdCapableLanguage] --- {% include language_info.html name='HTML' id='html' implementation='html::lang.html.HtmlLanguageModule' supports_pmd=true supports_cpd=true %} diff --git a/docs/pages/pmd/languages/index.md b/docs/pages/pmd/languages/index.md new file mode 100644 index 0000000000..4e85b73429 --- /dev/null +++ b/docs/pages/pmd/languages/index.md @@ -0,0 +1,9 @@ +--- +title: Overview +permalink: pmd_languages_index.html +last_updated: September 2023 (7.0.0) +tags: [languages] +--- + +* [PmdCapableLanguages](tag_PmdCapableLanguage.html) +* [CpdCapableLanguages](tag_CpdCapableLanguage.html) diff --git a/docs/pages/pmd/languages/java.md b/docs/pages/pmd/languages/java.md index 137e930a75..3c1d6d8ca5 100644 --- a/docs/pages/pmd/languages/java.md +++ b/docs/pages/pmd/languages/java.md @@ -3,7 +3,7 @@ title: Java support permalink: pmd_languages_java.html author: Clément Fournier last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, PmdCapableLanguage, CpdCapableLanguage] summary: "Java-specific features and guidance" --- diff --git a/docs/pages/pmd/languages/js_ts.md b/docs/pages/pmd/languages/js_ts.md index daefd54b76..1634cd41e9 100644 --- a/docs/pages/pmd/languages/js_ts.md +++ b/docs/pages/pmd/languages/js_ts.md @@ -2,7 +2,7 @@ title: JavaScript and TypeScript permalink: pmd_languages_js_ts.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, PmdCapableLanguage, CpdCapableLanguage] summary: "JavaScript and TypeScript infos" --- diff --git a/docs/pages/pmd/languages/jsp.md b/docs/pages/pmd/languages/jsp.md index 3f6809438e..ea53015d0e 100644 --- a/docs/pages/pmd/languages/jsp.md +++ b/docs/pages/pmd/languages/jsp.md @@ -2,7 +2,7 @@ title: JSP Support permalink: pmd_languages_jsp.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, PmdCapableLanguage, CpdCapableLanguage] author: Pieter Vanraemdonck summary: "JSP-specific features and guidance" --- diff --git a/docs/pages/pmd/languages/julia.md b/docs/pages/pmd/languages/julia.md index a064ed1eb8..dc8facd2c6 100644 --- a/docs/pages/pmd/languages/julia.md +++ b/docs/pages/pmd/languages/julia.md @@ -2,7 +2,7 @@ title: Julia permalink: pmd_languages_julia.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='Julia' id='julia' implementation='julia::lang.julia.JuliaLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/kotlin.md b/docs/pages/pmd/languages/kotlin.md index 6e2735fb07..191946bdfb 100644 --- a/docs/pages/pmd/languages/kotlin.md +++ b/docs/pages/pmd/languages/kotlin.md @@ -2,7 +2,7 @@ title: Kotlin Support permalink: pmd_languages_kotlin.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, PmdCapableLanguage, CpdCapableLanguage] summary: "Kotlin-specific features and guidance" --- diff --git a/docs/pages/pmd/languages/lua.md b/docs/pages/pmd/languages/lua.md index b35a57b4da..ab0fd1873c 100644 --- a/docs/pages/pmd/languages/lua.md +++ b/docs/pages/pmd/languages/lua.md @@ -2,7 +2,7 @@ title: Lua permalink: pmd_languages_lua.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='Lua' id='lua' implementation='lua::lang.lua.LuaLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/matlab.md b/docs/pages/pmd/languages/matlab.md index 5356fb3941..623d53372d 100644 --- a/docs/pages/pmd/languages/matlab.md +++ b/docs/pages/pmd/languages/matlab.md @@ -2,7 +2,7 @@ title: Matlab permalink: pmd_languages_matlab.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='Matlab' id='matlab' implementation='matlab::lang.matlab.MatlabLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/modelica.md b/docs/pages/pmd/languages/modelica.md index 30572d233e..5022e7e877 100644 --- a/docs/pages/pmd/languages/modelica.md +++ b/docs/pages/pmd/languages/modelica.md @@ -2,7 +2,7 @@ title: Modelica permalink: pmd_languages_modelica.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, PmdCapableLanguage, CpdCapableLanguage] --- {% include language_info.html name='Modelica' id='modelica' implementation='modelica::lang.modelica.ModelicaLanguageModule' supports_pmd=true supports_cpd=true %} diff --git a/docs/pages/pmd/languages/objectivec.md b/docs/pages/pmd/languages/objectivec.md index b8624dcb64..a1e18fcc1c 100644 --- a/docs/pages/pmd/languages/objectivec.md +++ b/docs/pages/pmd/languages/objectivec.md @@ -2,7 +2,7 @@ title: Objective-C permalink: pmd_languages_objectivec.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='objectivec' id='objectivec' implementation='objectivec::lang.objectivec.ObjectiveCLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/perl.md b/docs/pages/pmd/languages/perl.md index 41993b40d9..e2fc04a58b 100644 --- a/docs/pages/pmd/languages/perl.md +++ b/docs/pages/pmd/languages/perl.md @@ -2,7 +2,7 @@ title: Perl permalink: pmd_languages_perl.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='Perl' id='perl' implementation='perl::lang.perl.PerlLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/php.md b/docs/pages/pmd/languages/php.md index f226e58960..430e92a310 100644 --- a/docs/pages/pmd/languages/php.md +++ b/docs/pages/pmd/languages/php.md @@ -2,7 +2,7 @@ title: PHP permalink: pmd_languages_php.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='PHP' id='php' implementation='php::lang.php.PhpLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/plsql.md b/docs/pages/pmd/languages/plsql.md index 34c195426f..e130d03fca 100644 --- a/docs/pages/pmd/languages/plsql.md +++ b/docs/pages/pmd/languages/plsql.md @@ -2,7 +2,7 @@ title: PLSQL Support permalink: pmd_languages_plsql.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, PmdCapableLanguage, CpdCapableLanguage] summary: "PLSQL-specific features and guidance" --- diff --git a/docs/pages/pmd/languages/python.md b/docs/pages/pmd/languages/python.md index 97a2e609c0..3db917aa3b 100644 --- a/docs/pages/pmd/languages/python.md +++ b/docs/pages/pmd/languages/python.md @@ -2,7 +2,7 @@ title: Python permalink: pmd_languages_python.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='Python' id='python' implementation='python::lang.python.PythonLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/ruby.md b/docs/pages/pmd/languages/ruby.md index e896bff43d..ec23a7b2ea 100644 --- a/docs/pages/pmd/languages/ruby.md +++ b/docs/pages/pmd/languages/ruby.md @@ -2,7 +2,7 @@ title: Ruby permalink: pmd_languages_ruby.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='Ruby' id='ruby' implementation='ruby::lang.ruby.RubyLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/scala.md b/docs/pages/pmd/languages/scala.md index d5c6b13d82..2dddf16d1b 100644 --- a/docs/pages/pmd/languages/scala.md +++ b/docs/pages/pmd/languages/scala.md @@ -2,7 +2,7 @@ title: Scala permalink: pmd_languages_scala.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, PmdCapableLanguage, CpdCapableLanguage] --- {% include language_info.html name='Scala' id='scala' implementation='scala::lang.scala.ScalaLanguageModule' supports_pmd=true supports_cpd=true %} diff --git a/docs/pages/pmd/languages/swift.md b/docs/pages/pmd/languages/swift.md index 548f8e75f8..050ebe578b 100644 --- a/docs/pages/pmd/languages/swift.md +++ b/docs/pages/pmd/languages/swift.md @@ -2,7 +2,7 @@ title: Swift permalink: pmd_languages_swift.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, PmdCapableLanguage, CpdCapableLanguage] --- {% include language_info.html name='Swift' id='swift' implementation='swift::lang.swift.SwiftLanguageModule' supports_pmd=true supports_cpd=true %} diff --git a/docs/pages/pmd/languages/tsql.md b/docs/pages/pmd/languages/tsql.md index 03e7afed4f..b19c1d780d 100644 --- a/docs/pages/pmd/languages/tsql.md +++ b/docs/pages/pmd/languages/tsql.md @@ -2,7 +2,7 @@ title: TSql permalink: pmd_languages_tsql.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, CpdCapableLanguage] --- {% include language_info.html name='TSql' id='tsql' implementation='tsql::lang.tsql.TSqlLanguageModule' supports_cpd=true %} diff --git a/docs/pages/pmd/languages/visualforce.md b/docs/pages/pmd/languages/visualforce.md index 025956d0a5..e7e36584b7 100644 --- a/docs/pages/pmd/languages/visualforce.md +++ b/docs/pages/pmd/languages/visualforce.md @@ -2,7 +2,7 @@ title: Visualforce Support permalink: pmd_languages_visualforce.html last_updated: September 2023 -tags: [languages] +tags: [languages, PmdCapableLanguage, CpdCapableLanguage] author: Andreas Dangel --- diff --git a/docs/pages/pmd/languages/vm.md b/docs/pages/pmd/languages/vm.md index 3c878791e2..bdeeb8f454 100644 --- a/docs/pages/pmd/languages/vm.md +++ b/docs/pages/pmd/languages/vm.md @@ -2,7 +2,7 @@ title: Velocity Template Language (VTL) permalink: pmd_languages_vm.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, PmdCapableLanguage, CpdCapableLanguage] --- {% include language_info.html name='Velocity Template Language (VTL)' id='vm' implementation='vm::lang.vm.VmLanguageModule' supports_pmd=true supports_cpd=true %} diff --git a/docs/pages/pmd/languages/xml.md b/docs/pages/pmd/languages/xml.md index 9eeac963f9..b08c35f26b 100644 --- a/docs/pages/pmd/languages/xml.md +++ b/docs/pages/pmd/languages/xml.md @@ -2,7 +2,7 @@ title: Processing XML files permalink: pmd_languages_xml.html last_updated: September 2023 (7.0.0) -tags: [languages] +tags: [languages, PmdCapableLanguage, CpdCapableLanguage] --- {% include language_info.html name='Maven POM' id='pom' implementation='xml::lang.pom.PomLanguageModule' supports_pmd=true supports_cpd=true %} diff --git a/docs/pages/tags/tag_CpdCapableLanguage.md b/docs/pages/tags/tag_CpdCapableLanguage.md new file mode 100644 index 0000000000..e3af0232fc --- /dev/null +++ b/docs/pages/tags/tag_CpdCapableLanguage.md @@ -0,0 +1,11 @@ +--- +title: "CPD Capable Languages" +tagName: CpdCapableLanguage +search: exclude +permalink: tag_CpdCapableLanguage.html +sidebar: pmd_sidebar +folder: tags +--- +{% include taglogic.html %} + +{% include links.html %} diff --git a/docs/pages/tags/tag_PmdCapableLanguage.md b/docs/pages/tags/tag_PmdCapableLanguage.md new file mode 100644 index 0000000000..30d464c7b8 --- /dev/null +++ b/docs/pages/tags/tag_PmdCapableLanguage.md @@ -0,0 +1,11 @@ +--- +title: "PMD Capable Languages" +tagName: PmdCapableLanguage +search: exclude +permalink: tag_PmdCapableLanguage.html +sidebar: pmd_sidebar +folder: tags +--- +{% include taglogic.html %} + +{% include links.html %} From 039f5fbd853e83c3156e4a6954d0993b574298e7 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 5 Sep 2023 19:53:21 +0200 Subject: [PATCH 14/58] [doc] Improve language docs --- docs/_includes/language_info.html | 1 + docs/pages/pmd/languages/apex.md | 20 +++++++++++++------- docs/pages/pmd/languages/coco.md | 9 +++++---- docs/pages/pmd/languages/cpp.md | 3 ++- docs/pages/pmd/languages/cs.md | 3 ++- docs/pages/pmd/languages/dart.md | 5 +++-- docs/pages/pmd/languages/fortran.md | 3 ++- docs/pages/pmd/languages/gherkin.md | 7 ++++--- docs/pages/pmd/languages/go.md | 7 +++++-- docs/pages/pmd/languages/groovy.md | 9 +++++++-- docs/pages/pmd/languages/js_ts.md | 2 +- docs/pages/pmd/languages/julia.md | 2 +- docs/pages/pmd/languages/matlab.md | 2 +- docs/pages/pmd/languages/objectivec.md | 2 +- docs/pages/pmd/languages/perl.md | 2 +- docs/pages/pmd/languages/python.md | 2 +- docs/pages/pmd/languages/scala.md | 2 +- docs/pages/pmd/languages/swift.md | 2 +- 18 files changed, 52 insertions(+), 31 deletions(-) diff --git a/docs/_includes/language_info.html b/docs/_includes/language_info.html index ac7fa20ff2..3b47eba14c 100644 --- a/docs/_includes/language_info.html +++ b/docs/_includes/language_info.html @@ -2,6 +2,7 @@ Language Info for {{include.name}}