Add support for PMD 7

Issue #2537 resolved
Scott Wells repo owner created an issue

IC2 is currently incompatible with the final PMD 7 release. After digging in a bit – and creating a working integration – it turns out that this is because of fairly significant changes to the Java calling interface for PMD between PMD 6 and PMD 7. As I said, I’ve already made the necessary changes to work with PMD 7, but it’s looking to be extremely difficult to have a single integration that works with both PMD 6 and PMD 7 due to these calling interface changes.

I’d normally just say that everyone should plan to move up to PMD 7 as it does use the new Apex parser that addresses issues in PMD 6 with newer grammar constructs such as the null coalescing operator. However, the PMD AppExchange rules from the Salesforce Code Analyzer are currently explicitly built against PMD 6 and are not compatible with PMD 7. I have a question in with Salesforce on if/when those will be updated to be compatible with PMD 7, but my guess is that it won’t happen very soon.

While I’m waiting on an answer to that question, I’m going to continue trying to find a way to have IC2 work with both PMD 6 and PMD 7 to cover the bases. In the meantime, users should continue to use PMD 6.55.0 as the latest supported build of PMD for IC2’s PMD Salesforce code inspection.

Comments (4)

  1. Scott Wells reporter

    As a quick update, I’ve just chatted a bit with the PMD folks regarding how to make a single direct API integration compatible with both PMD 6 and PMD 7, and it’s actually quite difficult. They’ve added a backward-compatibility facade, but it’s only been tuned for the PMD Maven integration and is incomplete. Right now having a single implementation that works with both would require a conversion to an almost 100% reflection-based approach which brings along its own share of issues.

    I’ve also chatted a bit with Salesforce PM, though, and it sounds like they may already be quite close on PMD 7 updates to Salesforce Code Analyzer – including the PMD AppExchange rules – so right now I’m thinking/hoping that they’ll have that ready to go in short enough order that it won’t make sense to continue to pursue something that works with both versions.

    Once they update Code Analyzer for PMD 7, I’ll confirm that everything works well in IC2 with my own PMD 7 changes and release that in an official IC2 update. Note that even for end users, the migration to PMD 7 doesn’t seem to be a drop-in replacement. I had to make several changes to my test ruleset XML files for them to work properly in PMD 7. I’ll plan to enumerate the changes I’ve had to make for other users to help them in a successful and smooth transition.

  2. Scott Wells reporter

    Another quick update. I spoke with Salesforce PM today who informed me that a PMD 7-compatible update to the Salesforce Code Analyzer will be released as a beta very soon (possibly today…possibly already?!). I will install that version and confirm whether or not it fixes the issues with IC2’s integration of the PMD AppExchange rules. Assuming/hoping that it does, I will try to release a version of IC2 with PMD 7 – and only PMD 7 as it’s untenable to support both PMD 6 and PMD 7 – very soon…perhaps as early as next week. That will, of course, require users to migrate to PMD 7 (at least for IC2) and the beta version of the Salesforce Code Analyzer if using it. I wish there were some reasonable way to support both PMD 6 and PMD 7, but I’ve exhausted pretty much every avenue I can find, and they all resulted in dead ends.

    I’ll post additional information here once I’ve had some burn-in time on the new beta release of Salesforce Code Analyzer.

  3. Scott Wells reporter

    And another update. I just installed the beta build of Salesforce Code Analyzer and it seems to work well with PMD 7 alongside my IC2 changes for that version. Note that I have had to make several updates to the rulesets, specifically changing all references to vf to visualforce, commenting out a few rule properties that weren’t working properly (I’ll check for replacements), and migrating ApexXPathRule to XPathRule where appropriate.

    I already have this week’s release in final testing – and don’t want to release such a big update on top of a beta that was itself just released in the last few hours without significantly more burn-in time – but I’m hoping that I’ll be able to update IC2 for PMD 7 in next week’s build. I can even make an early access version of such a build available if anyone is interested. That wouldn’t likely be until after this week’s IC2 release and would be built upon that release, but I think I should be able to make something available Thursday afternoon if there’s sufficient interest.

  4. Log in to comment