PMD 7.00 through 7.2.0 inclusive PMD loading error.

Issue #2580 resolved
Kevin Poorman created an issue

Greetings Scott,

First, thanks for supporting PMD 7. I know their release broke a lot of things.

I have followed the release notes to best of my ability. To wit:

  • I have scrubbed my ruleset.xml file to reconfigure my xpath rules
  • Removed the ‘message’ param from built-in rules
  • Ensure I’m not using the other properties listed.
  • Ensured that my ruleset is only referencing built-in rules atm.

Yet, when I try to enable the PMD inspection for any of the following versions of PMD:

  • 7.0.0-rc4
  • 7.0.0
  • 7.1.0
  • 7.2.0

I receive the following error (see attached screen shot.)

Now, what’s bonkerballs to me, is that the following command line execution of PMD works.

pmd check -R pmd/ruleset.xml -d force-app/main/default/classes -r pmd.csv --verbose

It does throw two false-positive syntax errors that I’ve filed the following bugs for:

Neither of those, however, seem to be related to a class loading issue.

When I run PMD from the command line, in verbose mode I can see the classes it’s loading and I don’t see any class loading errors:

[DEBUG] Rules loaded from pmd/ruleset.xml:
[DEBUG] - ExcessiveClassLength (Apex)
[DEBUG] - ExcessiveParameterList (Apex)
[DEBUG] - ExcessivePublicCount (Apex)
[DEBUG] - NcssConstructorCount (Apex)
[DEBUG] - NcssMethodCount (Apex)
[DEBUG] - NcssTypeCount (Apex)
[DEBUG] - StdCyclomaticComplexity (Apex)
[DEBUG] - TooManyFields (Apex)
[DEBUG] - AvoidDeeplyNestedIfStmts (Apex)
[DEBUG] - CyclomaticComplexity (Apex)
[DEBUG] - CognitiveComplexity (Apex)
[DEBUG] - OperationWithLimitsInLoop (Apex)
[DEBUG] - AvoidLogicInTrigger (Apex)
[DEBUG] - AvoidGlobalModifier (Apex)
[DEBUG] - EagerlyLoadedDescribeSObjectResult (Apex)
[DEBUG] - AvoidDebugStatements (Apex)
[DEBUG] - MethodNamingConventions (Apex)
[DEBUG] - FieldNamingConventions (Apex)
[DEBUG] - FormalParameterNamingConventions (Apex)
[DEBUG] - LocalVariableNamingConventions (Apex)
[DEBUG] - PropertyNamingConventions (Apex)
[DEBUG] - ApexUnitTestShouldNotUseSeeAllDataTrue (Apex)
[DEBUG] - ApexUnitTestClassShouldHaveRunAs (Apex)
[DEBUG] - ApexAssertionsShouldIncludeMessage (Apex)
[DEBUG] - ApexUnitTestMethodShouldHaveIsTestAnnotation (Apex)
[DEBUG] - ApexUnitTestClassShouldHaveAsserts (Apex)
[DEBUG] - ApexBadCrypto (Apex)
[DEBUG] - ApexCRUDViolation (Apex)
[DEBUG] - ApexDangerousMethods (Apex)
[DEBUG] - ApexInsecureEndpoint (Apex)
[DEBUG] - ApexOpenRedirect (Apex)
[DEBUG] - ApexSharingViolations (Apex)
[DEBUG] - ApexSOQLInjection (Apex)
[DEBUG] - ApexSuggestUsingNamedCred (Apex)
[DEBUG] - ApexXSSFromEscapeFalse (Apex)
[DEBUG] - ApexXSSFromURLParam (Apex)
[DEBUG] - IfStmtsMustUseBraces (Apex)
[DEBUG] - WhileLoopsMustUseBraces (Apex)
[DEBUG] - IfElseStmtsMustUseBraces (Apex)
[DEBUG] - ForLoopsMustUseBraces (Apex)
[DEBUG] - ApexCSRF (Apex)
[DEBUG] - AvoidDirectAccessTriggerMap (Apex)
[DEBUG] - AvoidHardcodingId (Apex)
[DEBUG] - AvoidNonExistentAnnotations (Apex)
[DEBUG] - EmptyCatchBlock (Apex)
[DEBUG] - EmptyIfStmt (Apex)
[DEBUG] - EmptyStatementBlock (Apex)
[DEBUG] - EmptyTryOrFinallyBlock (Apex)
[DEBUG] - EmptyWhileStmt (Apex)
[DEBUG] - InaccessibleAuraEnabledGetter (Apex)
[DEBUG] - MethodWithSameNameAsEnclosingClass (Apex)
[DEBUG] - OverrideBothEqualsAndHashcode (Apex)
[DEBUG] - TestMethodsMustBeInTestClasses (Apex)
[DEBUG] - OneDeclarationPerLine (Apex)
[DEBUG] - FieldDeclarationsShouldBeAtStart (Apex)
[DEBUG] - ApexDoc (Apex)
[DEBUG] - DebugsShouldUseLoggingLevel (Apex)
[DEBUG] - UnusedLocalVariable (Apex)
[DEBUG] - NullValueCheckBeforeEmptyCheck (Apex)
[DEBUG] - BumpApiVersion (XML)
[DEBUG] - ModifyOrViewAllOnPermSet (XML)
[DEBUG] - ModifyOrViewAllOnSysAdminProfile (XML)
[DEBUG] - ManageUsersByNonSysAdmins (XML)
[DEBUG] - ViewSetupByNonSysAdmins (XML)
[DEBUG] Runtime classpath:
/Users/kevinpoorman/pmd-bin-7.2.0/conf:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-javascript-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/upack_2.13-1.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/scala-library-2.13.13.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-perl-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-apex-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/scala-json-rpc_2.13-1.0.1.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/flogger-system-backend-0.7.4.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-swift-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/guava-33.0.0-jre.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/trees_2.13-4.9.1.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-ant-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/slf4j-api-1.7.36.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/picocli-4.7.5.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/kotlin-stdlib-common-1.7.20.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/gson-extras-1.0.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/slf4j-simple-1.7.36.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/kotlin-stdlib-jdk8-1.7.20.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/scalapb-runtime_2.13-0.11.15.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pcollections-3.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/j2objc-annotations-2.8.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-julia-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/kotlin-stdlib-1.7.20.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/upickle_2.13-1.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-tsql-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/upickle-core_2.13-1.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/groovy-4.0.19.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-plsql-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/gson-2.10.1.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pkgforce_2.13-2.3.7.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/asm-9.6.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-ruby-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/xmlresolver-5.2.2-data.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/ujson_2.13-1.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/lenses_2.13-0.11.15.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/rhino-1.7.14.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-html-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-python-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-cli-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/parsers_2.13-4.9.1.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/Saxon-HE-12.4.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-velocity-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/apex-parser-3.6.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/checker-qual-2.11.1.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/apexlink-2.3.7.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/failureaccess-1.0.2.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-gherkin-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-cpp-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/kotlin-stdlib-jdk7-1.7.20.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/upickle-implicits_2.13-1.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-fortran-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/jline-3.21.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-php-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-jsp-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-objectivec-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/progressbar-0.9.5.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/runforce-55.5.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/error_prone_annotations-2.23.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-scala_2.13-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/scala-collection-compat_2.13-2.11.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/summit-ast-2.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/geny_2.13-0.6.2.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/protobuf-java-3.25.3.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-core-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/xmlresolver-5.2.2.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/jul-to-slf4j-1.7.36.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-xml-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/jsoup-1.17.2.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-groovy-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/commons-codec-1.15.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/httpcore5-5.1.3.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-coco-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-lua-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-go-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/scala-parallel-collections_2.13-1.0.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/httpclient5-5.1.3.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/scala-xml_2.13-1.3.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-kotlin-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/nice-xml-messages-3.1.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-dart-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/sourcecode_2.13-0.3.1.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/common_2.13-4.9.1.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-modelica-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/antlr4-runtime-4.9.3.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/scala-reflect-2.13.13.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-matlab-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/jsr305-3.0.2.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-cs-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/checker-compat-qual-2.5.3.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/scala-json-rpc-upickle-json-serializer_2.13-1.0.1.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/flogger-0.7.4.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-designer-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-visualforce-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/jsr250-api-1.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/pmd-java-7.2.0.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/httpcore5-h2-5.1.3.jar:/Users/kevinpoorman/pmd-bin-7.2.0/lib/commons-lang3-3.14.0.jar
[DEBUG] Aux classpath: jdk.internal.loader.ClassLoaders$AppClassLoader@42110406
[TRACE] Using Apex version ''apex 60''
[TRACE] Using XML version ''xml 1.1''
[WARN] This analysis could be faster, please consider using Incremental Analysis: https://docs.pmd-code.org/pmd-doc-7.2.0/pmd_userdocs_incremental_analysis.html
Processing files   0% [                                                                                                                                                                                                                                                                                        ]    0/2394 (0:00:00) Violations:0, Errors:0
[DEBUG] MultiFile Analysis created for Optional[]
[DEBUG] Using rule chain for XPath rule: EagerlyLoadedDescribeSObjectResult (Performance)
[DEBUG] Using rule chain for XPath rule: AvoidDebugStatements (Basic Ruleset)
[DEBUG] Using rule chain for XPath rule: ApexUnitTestMethodShouldHaveIsTestAnnotation (Best Practices)
[DEBUG] Using rule chain for XPath rule: IfStmtsMustUseBraces (Code Style)
[DEBUG] Using rule chain for XPath rule: WhileLoopsMustUseBraces (Code Style)
[DEBUG] Using rule chain for XPath rule: IfElseStmtsMustUseBraces (Code Style)
[DEBUG] Using rule chain for XPath rule: ForLoopsMustUseBraces (Code Style)
[DEBUG] Using rule chain for XPath rule: AvoidDirectAccessTriggerMap (Error Prone)
[DEBUG] Using rule chain for XPath rule: EmptyCatchBlock (Error Prone)
[DEBUG] Using rule chain for XPath rule: EmptyIfStmt (Error Prone)
[DEBUG] Using rule chain for XPath rule: EmptyStatementBlock (Error Prone)
[DEBUG] Using rule chain for XPath rule: EmptyTryOrFinallyBlock (Error Prone)
[DEBUG] Using rule chain for XPath rule: EmptyWhileStmt (Error Prone)
[DEBUG] Using rule chain for XPath rule: TestMethodsMustBeInTestClasses (Error Prone)
[DEBUG] Using rule chain for XPath rule: OneDeclarationPerLine (Code Style)
[DEBUG] Using rule chain for XPath rule: DebugsShouldUseLoggingLevel (Best Practices)
[DEBUG] Using rule chain for XPath rule: NullValueCheckBeforeEmptyCheck (Basic Ruleset)
[DEBUG] Using rule chain for XPath rule: BumpApiVersion (Basic Ruleset)
[DEBUG] Using rule chain for XPath rule: ModifyOrViewAllOnPermSet (Basic Ruleset)
[DEBUG] Using rule chain for XPath rule: ModifyOrViewAllOnSysAdminProfile (Basic Ruleset)
[DEBUG] Using rule chain for XPath rule: ManageUsersByNonSysAdmins (Basic Ruleset)
[DEBUG] Using rule chain for XPath rule: EagerlyLoadedDescribeSObjectResult (Performance)
[DEBUG] Using rule chain for XPath rule: AvoidDebugStatements (Basic Ruleset)
[DEBUG] Using rule chain for XPath rule: ApexUnitTestMethodShouldHaveIsTestAnnotation (Best Practices)
[DEBUG] Using rule chain for XPath rule: IfStmtsMustUseBraces (Code Style)
[DEBUG] Using rule chain for XPath rule: WhileLoopsMustUseBraces (Code Style)
[DEBUG] Using rule chain for XPath rule: IfElseStmtsMustUseBraces (Code Style)
[DEBUG] Using rule chain for XPath rule: ForLoopsMustUseBraces (Code Style)
[DEBUG] Using rule chain for XPath rule: AvoidDirectAccessTriggerMap (Error Prone)
[DEBUG] Using rule chain for XPath rule: EmptyCatchBlock (Error Prone)
[DEBUG] Using rule chain for XPath rule: EmptyIfStmt (Error Prone)
[DEBUG] Using rule chain for XPath rule: EmptyStatementBlock (Error Prone)
[DEBUG] Using rule chain for XPath rule: EmptyTryOrFinallyBlock (Error Prone)
[DEBUG] Using rule chain for XPath rule: EmptyWhileStmt (Error Prone)
[DEBUG] Using rule chain for XPath rule: TestMethodsMustBeInTestClasses (Error Prone)
[DEBUG] Using rule chain for XPath rule: OneDeclarationPerLine (Code Style)
[DEBUG] Using rule chain for XPath rule: DebugsShouldUseLoggingLevel (Best Practices)
[DEBUG] Using rule chain for XPath rule: NullValueCheckBeforeEmptyCheck (Basic Ruleset)
[DEBUG] Using rule chain for XPath rule: BumpApiVersion (Basic Ruleset)
[DEBUG] Using rule chain for XPath rule: ModifyOrViewAllOnPermSet (Basic Ruleset)
[DEBUG] Using rule chain for XPath rule: ModifyOrViewAllOnSysAdminProfile (Basic Ruleset)
[DEBUG] Using rule chain for XPath rule: ManageUsersByNonSysAdmins (Basic Ruleset)

I’ve been poking around trying to see if i can see how IC is running PMD, but I’ve not been able to find logs on it.

Also, uhm, can we revisit adding custom .jars?

Comments (10)

  1. Scott Wells repo owner
    • changed status to open

    Hi, Kevin. I just confirmed that IC2's integration is still working properly with 7.2 in addition to 7.0 and 7.1. Note that it will not work with 7.0.0-rc4 as that still had (mostly) the PMD 6 Java API.

    How have you installed PMD? Is it installed using the distribution archive or some package manager? If via a package manager, which one and what do you get if you type which pmd from the command-line?

    IC2 executes PMD in-process, not via any executable script wrapper. When you configure the inspection, it should pick up the distribution directory based on the system execution path ($PATH), though you can obviously specify the distribution directory yourself if you'd prefer. The logic to find the distribution directory automatically from the executable script definitely works for an archive-installed distribution. It's possible that things are different with a package manager-based install? Anyway, IC2 uses the distribution directory to find the required jars that it then uses in a custom classloader to execute PMD in-process.

    Let me know if that doesn't help.

  2. Kevin Poorman reporter

    Hi Scott,

    I have installed PMD 7.0.0, 7.1.0, 7.2.0 from distribution zips on the pmd website. I’ve unzipped them all to my home folder into versioned directory names: ie: /Users/thecodefriar/pmd-bin-7.2.0 and I’ve pointed IC’s PMD config at that folder plus /bin

    is there anyway to see logs beyond what the modal shows?

  3. Scott Wells repo owner

    The configured distribution directory should not include /bin. Here’s my config that’s based on the %PATH% / $PATH environment variable, but I’m able to to point it explicitly at any of 7.0.0, 7.1.0, or 7.2.0:

    You can get considerably more debug logging for the integration by enabling debug logging for PMD Salesforce. Here’s the relevant part of my log as it initializes off of a proper configuration:

    2024-06-05 17:23:44,767 [  20144]   FINE - #com.illuminatedcloud.intellij.pmd.inspection.pmd.PMDInspection - Used the execution path to find PMD as 'C:/dev/pmd-bin-7.2.0'.
    2024-06-05 17:23:44,785 [  20162]   FINE - #com.illuminatedcloud.intellij.pmd.inspection.pmd.PMDInspection - Subscribing project 'new_deploy_retrieve_commands' for inspection profile changes.
    2024-06-05 17:23:44,790 [  20167]   FINE - #com.illuminatedcloud.intellij.pmd.runner.PMDClassLoaderUtil - Creating a PMD class loader for 'C:/dev/pmd-bin-7.2.0::C:/Users/Scott/AppData/Local/sf/node_modules/@salesforce/sfdx-scanner/pmd-appexchange'.
    2024-06-05 17:23:44,826 [  20203]   FINE - #com.illuminatedcloud.intellij.pmd.runner.PMDClassLoaderUtil -   Adding the following jars to the PMD class loader:
      * C:\dev\pmd-bin-7.2.0\lib\antlr4-runtime-4.9.3.jar
      * C:\dev\pmd-bin-7.2.0\lib\apex-parser-3.6.0.jar
      * C:\dev\pmd-bin-7.2.0\lib\apexlink-2.3.7.jar
      * C:\dev\pmd-bin-7.2.0\lib\asm-9.6.jar
      * C:\dev\pmd-bin-7.2.0\lib\failureaccess-1.0.2.jar
      * C:\dev\pmd-bin-7.2.0\lib\flogger-0.7.4.jar
      * C:\dev\pmd-bin-7.2.0\lib\flogger-system-backend-0.7.4.jar
      * C:\dev\pmd-bin-7.2.0\lib\guava-33.0.0-jre.jar
      * C:\dev\pmd-bin-7.2.0\lib\jul-to-slf4j-1.7.36.jar
      * C:\dev\pmd-bin-7.2.0\lib\nice-xml-messages-3.1.jar
      * C:\dev\pmd-bin-7.2.0\lib\pcollections-3.2.0.jar
      * C:\dev\pmd-bin-7.2.0\lib\pkgforce_2.13-2.3.7.jar
      * C:\dev\pmd-bin-7.2.0\lib\pmd-apex-7.2.0.jar
      * C:\dev\pmd-bin-7.2.0\lib\pmd-core-7.2.0.jar
      * C:\dev\pmd-bin-7.2.0\lib\pmd-html-7.2.0.jar
      * C:\dev\pmd-bin-7.2.0\lib\pmd-javascript-7.2.0.jar
      * C:\dev\pmd-bin-7.2.0\lib\pmd-visualforce-7.2.0.jar
      * C:\dev\pmd-bin-7.2.0\lib\pmd-xml-7.2.0.jar
      * C:\dev\pmd-bin-7.2.0\lib\Saxon-HE-12.4.jar
      * C:\dev\pmd-bin-7.2.0\lib\scala-library-2.13.13.jar
      * C:\dev\pmd-bin-7.2.0\lib\slf4j-api-1.7.36.jar
      * C:\dev\pmd-bin-7.2.0\lib\summit-ast-2.2.0.jar
      * C:\dev\pmd-bin-7.2.0\lib\xmlresolver-5.2.2.jar
      * C:\Users\Scott\AppData\Local\sf\node_modules\@salesforce\sfdx-scanner\pmd-appexchange\lib\pmd-xml-sf-0.0.1.jar
      * C:\Users\Scott\AppData\Local\sf\node_modules\@salesforce\sfdx-scanner\pmd-appexchange\lib\sfca-pmd-apex-0.12.jar
      * C:\Users\Scott\AppData\Local\sf\node_modules\@salesforce\sfdx-scanner\pmd-appexchange\lib\sfca-pmd-html-0.12.jar
      * C:\Users\Scott\AppData\Local\sf\node_modules\@salesforce\sfdx-scanner\pmd-appexchange\lib\sfca-pmd-javascript-0.12.jar
      * C:\Users\Scott\AppData\Local\sf\node_modules\@salesforce\sfdx-scanner\pmd-appexchange\lib\sfca-pmd-sfmetadata-0.12.jar
      * C:\Users\Scott\AppData\Local\sf\node_modules\@salesforce\sfdx-scanner\pmd-appexchange\lib\sfca-pmd-visualforce-0.12.jar
      * C:\Users\Scott\AppData\Local\sf\node_modules\@salesforce\sfdx-scanner\pmd-appexchange\lib\sfca-pmd-xml-0.12.jar
      * C:\Users\Scott\AppData\Local\JetBrains\IntelliJIdea2024.1\plugins-sandbox\plugins\IlluminatedCloud2\lib\IlluminatedCloud.jar
    2024-06-05 17:23:45,371 [  20748]   FINE - #com.illuminatedcloud.intellij.pmd.runner.PMDRunner - Cached rule sets for file 'C:/Users/Scott/dev/projects/IlluminatedCloudTestProjects/df17-with-manifest/pmd-ruleset.xml' are missing. Loading and populating now.
    2024-06-05 17:23:46,124 [  21501]   FINE - #com.illuminatedcloud.intellij.pmd.runner.PMDRunner - Removing rules from rule sets that overlap with enabled Apex code inspections.
    2024-06-05 17:23:46,143 [  21520]   INFO - #com.illuminatedcloud.intellij.pmd.runner.PMDRuleSetsCache - Caching PMD rule sets for minimumRulePriority=Medium, rulesetFile='C:\Users\Scott\dev\projects\IlluminatedCloudTestProjects\df17-with-manifest\pmd-ruleset.xml', rulesetFileLastModified=1712164919266, ignoreRedundantRules=true, numApexRules=41, numVisualforceRules=3, numXmlRules=10, numHtmlRules=2, numJavascriptRules=0.
    2024-06-05 17:23:46,143 [  21520]   FINE - #com.illuminatedcloud.intellij.pmd.runner.PMDRunner - Cached rule sets for file 'C:/Users/Scott/dev/projects/IlluminatedCloudTestProjects/df17-with-manifest/pmd-appexchange-ruleset.xml' are missing. Loading and populating now.
    2024-06-05 17:23:46,194 [  21571]   FINE - #com.illuminatedcloud.intellij.pmd.runner.PMDRunner - Removing rules from rule sets that overlap with enabled Apex code inspections.
    2024-06-05 17:23:46,195 [  21572]   INFO - #com.illuminatedcloud.intellij.pmd.runner.PMDRuleSetsCache - Caching PMD rule sets for minimumRulePriority=Medium, rulesetFile='C:\Users\Scott\dev\projects\IlluminatedCloudTestProjects\df17-with-manifest\pmd-appexchange-ruleset.xml', rulesetFileLastModified=1711486427830, ignoreRedundantRules=true, numApexRules=10, numVisualforceRules=6, numXmlRules=7, numHtmlRules=1, numJavascriptRules=1.
    

    Let me know if that doesn’t help.

  4. Kevin Poorman reporter

    Scott,

    With those logs, I was able to quickly figure it out. I don’t know that I can explain the difference in execution between the CLI and IC, but here’s what’s happening.

    we had 4 rules that were otherwise valid, but had no class= attribute. In this case, they’d been ‘ignored’ by a prior developer. When executing from the command line, those rules without a class= attribute are seemingly silently ignored. IC’s execution fails to load the ruleset, because of xml validation errors. Here’s the log snippet that clue’d me in.

    java.lang.RuntimeException: Cannot load ruleset /Users/kevinpoorman/src/va-teams-secondary/pmd/ruleset.xml: 4 XML validation errors occurred
    Error at /Users/kevinpoorman/src/Project/pmd/ruleset.xml:82:5
     80|     </rule>
     81|     <rule ref="category/apex/performance.xml/EagerlyLoadedDescribeSObjectResult" />
     82|     <rule name="AvoidDebugStatements" language="apex" >
             ^^^^^ Required attribute ''class'' is missing
    
     83|         <priority>1</priority>
     84|         <properties>
    Error at /Users/kevinpoorman/src/Project/pmd/ruleset.xml:200:5
     198|
     199|     <!-- CUSTOM RULES -->
     200|     <rule name="NullValueCheckBeforeEmptyCheck" language="apex" >
              ^^^^^ Required attribute ''class'' is missing
    
     201|         <priority>2</priority>
     202|         <properties>
    Error at /Users/kevinpoorman/src/Project/pmd/ruleset.xml:213:5
     211|     </rule>
     212|
     213|     <rule name="BumpApiVersion" language="xml" >
              ^^^^^ Required attribute ''class'' is missing
    
     214|         <priority>3</priority>
     215|         <properties>
    Error at /Users/kevinpoorman/src/Project/pmd/ruleset.xml:295:5
     293|     </rule>
     294|
     295|     <rule name="ViewSetupByNonSysAdmins" language="xml" >
              ^^^^^ Required attribute ''class'' is missing
    
     296|         <priority>1</priority>
     297|         <properties>
    

    If I might suggest a slight edit to the debugging pmd issues before bothering scott page:
    1. Enable the debug logs.
    2. Grep -A10 -B10 /\^{5,5}/ idea.log

  5. Scott Wells repo owner

    Gotcha. I can see why you’re getting the error you are as well. The exception is bubbling out of the custom class loader, and the caller doesn’t have access to the original RuleSetLoadException so that’s masking the real error. I just made a change to drop the incompatible exception type while retaining the message.

  6. Scott Wells repo owner

    This is what you’d see with the changes I made:

    The entire mesage can be copied for external review.

  7. Log in to comment