Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions pmd-cataloger/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ tasks.register<Delete>("deletePmdCatalogerDist") {

// ======== DEFINE/UPDATE PMD7 DIST RELATED TASKS =====================================================================
val pmd7DistDir = "$distDir/pmd7"
val pmd7Version = "7.1.0"
val pmd7Version = "7.2.0"
val pmd7File = "pmd-dist-$pmd7Version-bin.zip"

tasks.register<de.undercouch.gradle.tasks.download.Download>("downloadPmd7") {
Expand All @@ -76,12 +76,26 @@ tasks.register<Copy>("installPmd7") {
dependsOn("downloadPmd7")
from(zipTree("$buildDir/$pmd7File"))

// I went to https://github.com/pmd/pmd/tree/pmd_releases/7.1.0 and for each of the languages that we support
// TO KEEP THE BELOW MODULE DEPENDENCIES LIST CORRECT AND UP TO DATE:
// I went to https://github.com/pmd/pmd/tree/pmd_releases/7.2.0 and for each of the languages that we support
// (apex, java, visualforce, xml), I took a look at its direct and indirect dependencies at
// https://central.sonatype.com/artifact/net.sourceforge.pmd/pmd-apex/dependencies
// by selecting the 7.1.0 dropdown and clicking on "Dependencies" and selecting "All Dependencies".
// by selecting the 7.2.0 dropdown and clicking on "Dependencies" and selecting "All Dependencies".
// For completeness, I listed the modules and all their compile time dependencies (direct and indirect).
// Duplicates don't matter since we use setOf.
//
// A tip when we upgrade to see if there are any differences between minor releases of a given module:
// 1) Open the following in two different tabs (using pmd-core as an example):
// * Go to https://mvnrepository.com/artifact/net.sourceforge.pmd/pmd-core/7.1.0
// * Go to https://mvnrepository.com/artifact/net.sourceforge.pmd/pmd-core/7.2.0
// Then compare the compile dependencies and their versions to see if there are any changes.
// Do this will all modules we care about. Obviously the pmd-core dependency version will change but if nothing else
// changes then this means no updates are needed for that module. If there are changes to pmd-core's dependencies...
// then all modules that depend on pmd-core should be updated below with their new indirect dependencies.
// 2) As a sanity check it is also worth comparing the versions of the jars that are bundled between the two release
// zip files to spot any version differences.
// * https://github.com/pmd/pmd/archive/refs/tags/pmd_releases/7.2.0.zip
// * https://github.com/pmd/pmd/archive/refs/tags/pmd_releases/7.1.0.zip
val pmd7ModulesToInclude = setOf(
// LANGUAGE MODULE DEPENDENCIES (direct and indirect)
"pmd-apex", "Saxon-HE", "annotations", "antlr4-runtime", "apex-parser", "apexlink", "asm", "checker-compat-qual", "checker-qual", "commons-lang3", "error_prone_annotations", "failureaccess", "flogger", "flogger-system-backend", "geny_2.13", "gson", "gson-extras", "guava", "j2objc-annotations", "jsr250-api", "jsr305", "jul-to-slf4j", "kotlin-stdlib", "kotlin-stdlib-common", "kotlin-stdlib-jdk7", "kotlin-stdlib-jdk8", "listenablefuture", "nice-xml-messages", "pcollections", "pkgforce_2.13", "pmd-core", "runforce", "scala-collection-compat_2.13", "scala-json-rpc-upickle-json-serializer_2.13", "scala-json-rpc_2.13", "scala-library", "scala-parallel-collections_2.13", "scala-reflect", "scala-xml_2.13", "slf4j-api", "summit-ast", "ujson_2.13", "upack_2.13", "upickle-core_2.13", "upickle-implicits_2.13", "upickle_2.13", "xmlresolver",
Expand All @@ -91,7 +105,7 @@ tasks.register<Copy>("installPmd7") {
"pmd-visualforce", "Saxon-HE", "antlr4-runtime", "apex-parser", "apexlink", "asm", "checker-compat-qual", "checker-qual", "commons-lang3", "error_prone_annotations", "failureaccess", "flogger", "flogger-system-backend", "geny_2.13", "gson", "gson-extras", "guava", "j2objc-annotations", "jsr250-api", "jsr305", "jul-to-slf4j", "kotlin-stdlib", "kotlin-stdlib-common", "kotlin-stdlib-jdk7", "kotlin-stdlib-jdk8", "listenablefuture", "nice-xml-messages", "pcollections", "pkgforce_2.13", "pmd-apex", "pmd-core", "runforce", "scala-collection-compat_2.13", "scala-json-rpc-upickle-json-serializer_2.13", "scala-json-rpc_2.13", "scala-library", "scala-parallel-collections_2.13", "scala-reflect", "scala-xml_2.13", "slf4j-api", "summit-ast", "ujson_2.13", "upack_2.13", "upickle-core_2.13", "upickle-implicits_2.13", "upickle_2.13", "xmlresolver",
"pmd-xml", "Saxon-HE", "antlr4-runtime", "asm", "checker-qual", "commons-lang3", "gson", "jul-to-slf4j", "nice-xml-messages", "pcollections", "pmd-core", "slf4j-api", "xmlresolver",
// MAIN CLI MODULE DEPENDENCIES (direct and indirect)
"pmd-cli", "Saxon-HE", "antlr4-runtime", "asm", "checker-qual", "commons-lang3", "gson", "jline", "jul-to-slf4j", "nice-xml-messages", "pcollections", "picocli", "pmd-core", "progressbar", "slf4j-api", "slf4j-simple", "xmlresolver",
"pmd-cli", "Saxon-HE", "antlr4-runtime", "asm", "checker-qual", "commons-lang3", "gson", "jline", "jul-to-slf4j", "nice-xml-messages", "pcollections", "picocli", "pmd-core", "progressbar", "slf4j-api", "slf4j-simple", "xmlresolver", // Do not include pmd-designer since we don't use it
)
val pmd7JarsToIncludeRegexes = mutableSetOf("""^LICENSE""".toRegex())
pmd7ModulesToInclude.forEach {
Expand Down
2 changes: 1 addition & 1 deletion src/Constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os = require('os');
import path = require('path');

export const PMD7_VERSION = '7.1.0';
export const PMD7_VERSION = '7.2.0';
export const PMD_APPEXCHANGE_RULES_VERSION = '0.12';
export const SFGE_VERSION = '1.0.1-pilot';
export const DEFAULT_SCANNER_PATH = path.join(os.homedir(), '.sfdx-scanner');
Expand Down
5 changes: 2 additions & 3 deletions src/lib/pmd/PmdCommandInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {PMD7_LIB, PMD7_VERSION} from "../../Constants";
import * as path from 'path';

const PMD7_CLI_CLASS = 'net.sourceforge.pmd.cli.PmdCli';
const HEAP_SIZE = '-Xmx1024m';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stephen-carter-at-sf - Why are we not passing HEAP_SIZE anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the discussion in slack. But the idea basically is to get around this bug https://salesforce-internal.slack.com/archives/G02JGHG9NSE/p1718287697404169?thread_ts=1718287579.150129&cid=G02JGHG9NSE

If we do not supply the heap size, then the default is roughly a 1/4 of whatever your machines memory is. Most machines have more than 4g of memory and thus this would naturally get set to higher than 1g. If not, then users can control this themselves with the JDK_JAVA_OPTIONS environment variable. For example:

export JDK_JAVA_OPTIONS="-Xmx2g"


export interface PmdCommandInfo {
getVersion(): string
Expand All @@ -25,7 +24,7 @@ export class Pmd7CommandInfo implements PmdCommandInfo {

constructJavaCommandArgsForPmd(fileList: string, classPathsForExternalRules: string[], rulesets: string): string[] {
const classpath = classPathsForExternalRules.concat([`${PMD7_LIB}/*`]).join(path.delimiter);
const args = ['-cp', classpath, HEAP_SIZE, PMD7_CLI_CLASS, 'check', '--file-list', fileList,
const args = ['-cp', classpath, PMD7_CLI_CLASS, 'check', '--file-list', fileList,
'--format', 'xml'];
if (rulesets.length > 0) {
args.push('--rulesets', rulesets);
Expand All @@ -35,7 +34,7 @@ export class Pmd7CommandInfo implements PmdCommandInfo {

constructJavaCommandArgsForCpd(fileList: string, minimumTokens: number, language: string): string[] {
const classpath = `${PMD7_LIB}/*`;
return ['-cp', classpath, HEAP_SIZE, PMD7_CLI_CLASS, 'cpd', '--file-list', fileList, '--format', 'xml',
return ['-cp', classpath, PMD7_CLI_CLASS, 'cpd', '--file-list', fileList, '--format', 'xml',
'--minimum-tokens', minimumTokens.toString(), '--language', language, '--skip-lexical-errors'];
}
}