mitchspano / sfdx-scan-pull-request

Runs sfdx-scanner on a pull request and generates in-line comments with the findings.
Apache License 2.0
71 stars 24 forks source link

Run SFDX Scanner Issue #51

Closed marcopinder closed 1 year ago

marcopinder commented 1 year ago

When trying to run this GitHub Action I encounter the following error:

Error: Command failed: npx sfdx scanner:run --pmdconfig ruleset.xml --target "unpackaged/main/default/classes/ClientAtRiskTriggerHelper.cls" --json

Please find portion of log file with error attached.

There is a line in the log that states:

node:internal/errors:841

Contents of my YAML file also attached.

I'm not sure if this is the issue, or how to fix it. Any help you can provide would be much appreciated, thanks.

4_Run SFDX Scanner - Report findings as comments.txt

sfca.txt

mitchspano commented 1 year ago

Thanks for reporting this issue. I will try to improve the error logging on the sfdx scanner:run command to help us find out what is going on here.

mitchspano commented 1 year ago

@marcopinder I have made a modification of the code to improve the error logging on a branch called improveErrorLogging

Can you use this branch and let me know what you observe?

name: Run SFDX Scanner - Report findings as comments
uses: mitchspano/sfdx-scan-pull-request@improveErrorLogging
marcopinder commented 1 year ago

@mitchspano Thanks for this, I have tried today against the new branch and I'm seeing errors as per the attached.

1_analyze (1).txt

mitchspano commented 1 year ago

Dows your project have a ruleset.xml file? If not, you should omit the pmdconfig declaration:

 - name: Run SFDX Scanner - Report findings as comments
     uses: mitchspano/sfdx-scan-pull-request@v0.1.11
     with:
       pmdconfig: ruleset.xml #omit this line
       severity-threshold: 4
       strictly-enforced-rules: '[{ "engine": "pmd", "category": "Performance", "rule": "AvoidDebugStatements" }]'
     env:
       GITHUB_TOKEN: ${{ secrets.TOKEN }}
mitchspano commented 1 year ago

This was caused by an unnecessary reference to pmdconfig: ruleset.xml in the YML file.

I have improved the output of the scan when an error is encountered so if something goes wrong when calling the sfdx commands, you will be able to see the string representation of the error instead of the raw buffer.

I have also updated the README to have better instructions - explicitly calling out that the inputs to the scan are all optional.