From 8218c4c94592e5a96b05e4d063c6104396bcf47d Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 9 Feb 2024 21:02:05 -0800 Subject: [PATCH 1/2] Bumped dependencies --- .vscode/launch.json | 16 ++-------------- .vscode/settings.json | 4 +++- lib/bld/bld-wrapper.jar | Bin 27293 -> 27293 bytes .../rife/bld/extension/PmdOperationBuild.java | 10 +++++----- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 90264e1..f4d8eb7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,23 +1,11 @@ { "version": "0.2.0", "configurations": [ - { - "type": "java", - "name": "Run Main", - "request": "launch", - "mainClass": "rife.bld.extension.PmdOperation }, { "type": "java", "name": "Run Tests", "request": "launch", - "mainClass": "org.junit.platform.console.ConsoleLauncher", - "args": [ - "--details=verbose", - "--scan-classpath", - "--disable-banner", - "--disable-ansi-colors", - "--exclude-engine=junit-platform-suite", - "--exclude-engine=junit-vintage"] + "mainClass": "rife.bld.extension.PmdOperationTest" } ] -} +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 5dd7145..1b057c3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,8 +7,10 @@ ], "java.configuration.updateBuildConfiguration": "automatic", "java.project.referencedLibraries": [ - "${HOME}bld-1.7.0-SNAPSHOT.jar", + "${HOME}/.bld/dist/bld-1.8.0.jar", + "lib/bld/*.jar", "lib/compile/*.jar", + "lib/provided/*.jar", "lib/runtime/*.jar", "lib/test/*.jar" ] diff --git a/lib/bld/bld-wrapper.jar b/lib/bld/bld-wrapper.jar index cc3d9e7d9368f955647964970438101c20454116..ae7f26d88f97c512175ff4e5894e49546c6721f8 100644 GIT binary patch delta 131 zcmbPxm2vJ>M&1B#W)=|!4h{~6)9c(P^42i}sf~T2#vpq0GUIM0FvG;`moAuLm~x&G w%wSG41WQde&#(sxOs>pu2Gjd9Ji#<~W(b&0%5(+Ot1{yt;#vM+IyTDz0LO1L?f?J) delta 131 zcmbPxm2vJ>M&1B#W)=|!4h{|m{*87MdFz;g)W$whV-UT0nQ=E0m|C<07*?LQUCw| diff --git a/src/bld/java/rife/bld/extension/PmdOperationBuild.java b/src/bld/java/rife/bld/extension/PmdOperationBuild.java index 932a2ae..b3b9438 100644 --- a/src/bld/java/rife/bld/extension/PmdOperationBuild.java +++ b/src/bld/java/rife/bld/extension/PmdOperationBuild.java @@ -34,7 +34,7 @@ public class PmdOperationBuild extends Project { public PmdOperationBuild() { pkg = "rife.bld.extension"; name = "bld-pmd"; - version = version(0, 9, 5); + version = version(0, 9, 6); javaRelease = 17; downloadSources = true; @@ -47,11 +47,11 @@ public class PmdOperationBuild extends Project { .include(dependency("net.sourceforge.pmd", "pmd-java", pmd)); scope(runtime) .include(dependency("net.sourceforge.pmd", "pmd-java", pmd)) - .include(dependency("org.slf4j", "slf4j-simple", version(2, 0, 11))); + .include(dependency("org.slf4j", "slf4j-simple", version(2, 0, 12))); scope(test) - .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 1))) - .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 1))) - .include(dependency("org.assertj", "assertj-core", version(3, 25, 2))); + .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 2))) + .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 2))) + .include(dependency("org.assertj", "assertj-core", version(3, 25, 3))); javadocOperation() .javadocOptions() From 9d301b5ef6b7d1d45f045cd25efd77f2256a86be Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 9 Feb 2024 21:07:22 -0800 Subject: [PATCH 2/2] Added option to toggle the violation's line number in source file URI --- .../java/rife/bld/extension/PmdOperation.java | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/main/java/rife/bld/extension/PmdOperation.java b/src/main/java/rife/bld/extension/PmdOperation.java index a7aaf05..f55c13e 100644 --- a/src/main/java/rife/bld/extension/PmdOperation.java +++ b/src/main/java/rife/bld/extension/PmdOperation.java @@ -81,6 +81,10 @@ public class PmdOperation extends AbstractOperation { * The path of the ignore file */ Path ignoreFile_; + /** + * The include line number toggle. + */ + boolean includeLineNumber_ = true; /** * The incremental analysis toggle. */ @@ -300,6 +304,18 @@ public class PmdOperation extends AbstractOperation { return this; } + /** + * Enables or disables including the line number for the beginning of the violation in the analyzed source file URI. + *

+ * While clicking on the URI works in IntelliJ IDEA, Visual Studio Code, etc.; it might not in terminal emulators. + *

+ * Default: {@code TRUE} + */ + public PmdOperation includeLineNumber(boolean includeLineNumber) { + includeLineNumber_ = includeLineNumber; + return this; + } + /** * Enables or disables incremental analysis. */ @@ -399,14 +415,17 @@ public class PmdOperation extends AbstractOperation { } var numErrors = report.getViolations().size(); if (numErrors > 0) { - var msg = String.format( - "[%s] %d rule violations were found. See the report at: %s", commandName, numErrors, - config.getReportFilePath().toUri()); for (var v : report.getViolations()) { if (LOGGER.isLoggable(Level.WARNING)) { - LOGGER.log(Level.WARNING, "[{0}] {1}:{2}:\n\t{3} ({4})\n\t\t--> {5}", + final String msg; + if (includeLineNumber_) { + msg = "[{0}] {1}:{2}\n\t{3} ({4})\n\t\t--> {5}"; + } else { + msg = "\"[{0}] {1} (line: {2})\\n\\t{3} ({4})\\n\\t\\t--> {5}\""; + } + LOGGER.log(Level.WARNING, msg, new Object[]{commandName, - v.getFileId().getAbsolutePath(), + v.getFileId().getUriString(), v.getBeginLine(), v.getRule().getName(), v.getRule().getExternalInfoUrl() //TODO bug in PMD? @@ -415,11 +434,15 @@ public class PmdOperation extends AbstractOperation { v.getDescription()}); } } + + var violations = String.format( + "[%s] %d rule violations were found. See the report at: %s", commandName, numErrors, + config.getReportFilePath().toUri()); if (config.isFailOnViolation()) { - throw new RuntimeException(msg); // NOPMD + throw new RuntimeException(violations); // NOPMD } else { if (LOGGER.isLoggable(Level.WARNING)) { - LOGGER.warning(msg); + LOGGER.warning(violations); } } } else {