PMD not working

54 views
Skip to first unread message

Theodoor van Donge

unread,
Jul 31, 2023, 10:05:29 AM7/31/23
to Illuminated Cloud Q&A
I have got PMD setup, it also works when i run it manually like so: 

/usr/local/bin/pmd pmd -d mydir/ -R pmd-config.xml

But when I setup Illuminated Cloud like so, nothing happens: 
Settings > Editor > Inspections > PMD Salesforce: 
Distribution: /usr/local/bin/pmd
Ruleset: point to the same path as the command above


Scott

unread,
Jul 31, 2023, 10:31:35 AM7/31/23
to Illuminated Cloud Q&A, theodoor...@casenine.com
Hi. IC2 2.2.7.5 added support for PMD 7 which has an incompatible Java API vs. PMD 6 (which is also still supported):


Can you please confirm that you're on the latest build of IC2 and either PMD 6.55.0 or 7.0.0-rc3 when this happens? If so, can you please enable debug logging for PMD, reproduce the issue, and send the resulting idea.log file to sup...@illuminatedcloud.com for review along with the version of PMD being used and, if possible, the ruleset file?

Regards,
Scott Wells

Peter Yao

unread,
Mar 25, 2024, 9:26:50 AMMar 25
to Illuminated Cloud Q&A, Scott
Hi Scott

I'm using IC2 2.3.0.3, IJ 2023.3.6 and trying to get PMD 7.0.0 working.

I'm using the quickstart ruleset from the project:

PMD 7.0.0 works from the command line with this ruleset:
C:\git\SMP2>pmd check -R ruleset.xml --file-list file.txt
[WARN] Progressbar rendering conflicts with reporting to STDOUT. No progressbar will be shown. Try running with argument -r <file> to output the report to a file instead.
[WARN] This analysis could be faster, please consider using Incremental Analysis: https://docs.pmd-code.org/pmd-doc-7.0.0/pmd_userdocs_incremental_analysis.html
force-app\main\default\classes\Foo.cls:8:        FieldNamingConventions: The constant field name 'leadSelector' doesn't match '[A-Z][A-Z0-9_]*'

C:\git\SMP2>pmd --version
  ΓûêΓûêΓûêΓûê                            ΓûêΓûêΓûêΓûê
  ΓûêΓûê                                ΓûêΓûê
  ΓûêΓûê  ΓûêΓûêΓûêΓûêΓûê Γûê ΓûêΓûêΓûê    ΓûêΓûêΓûê  ΓûêΓûêΓûêΓûêΓûêΓûêΓûê   ΓûêΓûê
 ΓûêΓûêΓûê  ΓûêΓûê  ΓûêΓûêΓûê ΓûêΓûêΓûêΓûê  ΓûêΓûêΓûêΓûê  ΓûêΓûê    ΓûêΓûê  ΓûêΓûêΓûê
 ΓûêΓûêΓûê  ΓûêΓûêΓûêΓûêΓûêΓûêΓûê ΓûêΓûê ΓûêΓûêΓûêΓûê ΓûêΓûê  ΓûêΓûê    ΓûêΓûê  ΓûêΓûêΓûê
  ΓûêΓûê  ΓûêΓûê      ΓûêΓûê  ΓûêΓûê  ΓûêΓûê  ΓûêΓûêΓûêΓûêΓûêΓûêΓûê   ΓûêΓûê
  ΓûêΓûê                                ΓûêΓûê
  ΓûêΓûêΓûêΓûê                            ΓûêΓûêΓûêΓûê
PMD 7.0.0 (7979570d39909195e173de05450fb1acf8b3eec5, 2024-03-22T07:17:27Z)
Java version: 22, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-22

I have the IJ inspection set up with
PMD Distribution: C:/Program Files/pmd-bin-7.0.0
PMD ruleset: C:/git/SMP2/ruleset.xml
PMD AppExchange: (unchecked)

The log, which I attached, has this error:
java.lang.Throwable: Failed to execute PMD: net/sourceforge/pmd/RuleSetLoadException
net.sourceforge.pmd.RuleSetLoadException
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376)
at com.illuminatedcloud.intellij.pmd.inspection.pmd.PMDInspection.checkFile(SourceFile:253)

The IJ inspection works with PMD 6.55.0 and a ruleset without OperationWithHighCostInLoop if I remove the null coalescing operator from the source file.

I couldn't find anyone else with the same issue - do you have any ideas on where to go from here?

Thanks as always!
Peter
idea.log

Scott

unread,
Mar 25, 2024, 10:47:39 AMMar 25
to Illuminated Cloud Q&A, peter...@gmail.com, Scott
Hi. PMD 7 was just released and I haven't adjusted yet for support. I did adjust for several of the release candidates, and each one required several small changes because of backward-incompatible SDK changes, jar repackaging, etc. I'm assuming that the final release of PMD 7 will require the same. I'll take a look this week and -- hopefully but no promises as I don't know what changes will be required -- try to get a compatible update out in the next official build.

The reason that PMD 6 doesn't work properly with the null coalescing operator is that it still uses the older Apex parser that did not support it. PMD 7 uses a newer, open-source Apex parser that does include an updated grammar.

Regards,
Scott Wells

Peter Yao

unread,
Mar 25, 2024, 10:49:55 AMMar 25
to Illuminated Cloud Q&A, Scott
Great! No problem waiting for it, good to know it's not me.

Thanks again -

Scott

unread,
Mar 25, 2024, 3:30:47 PMMar 25
to Illuminated Cloud Q&A, peter...@gmail.com, Scott
FYI, I've spent some time on this today and have captured current thoughts/status here:


The TL/DR is that:
  1. I've already made the changes locally to support PMD 7, but...
  2. Due to major changes in the PMD API -- and a discussion about those changes with the PMD devs/maintainers -- simultaneously supporting both 6 and 7 is unlikely, and...
  3. The Salesforce Code Analyzer's PMD AppExchange rules are currently compiled against PMD 6, so moving immediately to 7 would temporarily break/lose that valuable integration, so...
  4. I've spoken with Salesforce and (again, no guarantees), it sounds like a PMD 7 update for Code Analyzer / PMD AppExchange is already underway.
Based on all of that, I'm planning to release PMD 7 support for IC2 once Salesforce has released PMD 7 support for Code Analyzer / PMD AppExchange. Once released, IC2 will drop support for PMD 6 altogether and only support PMD 7. Note that, based on my own experience, that migration will likely also require some small ruleset tweaks for many(/most?) users.

Anyway, if you want to follow further progress and updates, feel free to add yourself as a watcher on the public issue tracker item linked above. I'll plan to post all updates there.

Regards,
Scott Wells
Reply all
Reply to author
Forward
0 new messages