forcedotcom / sfdx-scanner

MIT License
207 stars 49 forks source link

[BUG] <v4.3.0 run gives error ERROR net.sourceforge.pmd.cli, whereas v3.26.0 runs fine> #1523

Closed 6andrey closed 1 week ago

6andrey commented 1 week ago

Have you tried to resolve this issue yourself first?

Yes

Bug Description

About 1 hour ago, very close to v4.3.0 has been release our GitHub that uses SFDX Scanner got error on the first run. We also see that installing via sfdx plugins:install @salesforce/sfdx-scanner doesn't install v3.x anymore but installs v4.3.0

Output / Logs

Install Scanner step

sfdx plugins:install @salesforce/sfdx-scanner shell: /usr/bin/bash -e {0} Successfully validated digital signature for @salesforce/sfdx-scanner. Finished digital signature check. @salesforce/cli: Installing plugin @salesforce/sfdx-scanner@latest... installed v4.3.0

Run Scanner step

sfdx scanner:run --target "deployment_path_that_does_not_contain_any_Apex_classes" --pmdconfig "ruleset/apexunit.xml" --format "table" --engine "pmd" --normalize-severity --severity-threshold 1

Error received

About to run PMD with custom config in ruleset/apexunit.xml. Please make sure that any custom rule references have already been added to the plugin through scanner:rule:add command. Error (1): [main] ERROR net.sourceforge.pmd.cli - Error at ruleset/apexunit.xml:18:5 16| 1 17| 18| ^^^^^ Unable to find referenced rule AvoidDmlStatementsInLoops; perhaps the rule name is misspelled?

1[9]| 1 20| [main] ERROR net.sourceforge.pmd.cli - Error at ruleset/apexunit.xml:21:5 19| 1 20| 21| ^^^^^ Unable to find referenced rule AvoidSoqlInLoops; perhaps the rule name is misspelled?

22| 1 23| [main] ERROR net.sourceforge.pmd.cli - Cannot load ruleset ruleset/apexunit.xml: 2 XML validation errors occurred [main] WARN net.sourceforge.pmd.cli - Progressbar rendering conflicts with reporting to STDOUT. No progressbar will be shown. Try running with argument -r to output the report to a file instead.

Error: Process completed with exit code 1.

Steps To Reproduce

  1. install the scanner plugin

    sfdx plugins:install @salesforce/sfdx-scanner

  2. confirm version installed is v4.3.0
  3. run scanner

    sfdx scanner:run --target "deployment_path_that_does_not_contain_any_Apex_classes" --pmdconfig "ruleset/apexunit.xml" --format "table" --engine "pmd" --normalize-severity --severity-threshold 1

Expected Behavior

Scanner run is completed without error on v3.26.0

Operating System

Ubuntu 22.04.4 LTS

Salesforce CLI Version

@salesforce/cli/2.46.6 linux-x64 node-v20.14.0

Code Analyzer Plugin (@salesforce/sfdx-scanner) Version

4.3.0

Additional Context (Screenshots, Files, etc)

No response

Workaround

To roll back to v3.26.0

Urgency

High

stephen-carter-at-sf commented 1 week ago

I see that you are using a custom PMD config (as shown by your use of the --pmdconfig flag). Most likely you'll need to migrate your rules to work with PMD 7.

As stated by the release notes from yesterday's release:

If you're using custom PMD rules, you might need to migrate your rules to work with PMD 7. See Migration Guide for PMD 7 for more information.

You may have noticed a warning for the past few months regarding upgrading v4. If you did not see this and need to buy some time, then feel free to temporarily downgrade to 3.26.0 with: sf plugins install @salesforce/sfdx-scanner@3.26.0


I'll leave this issue for a few days before I close it (so that others can learn from it).