mitchspano / sfdx-scan-pull-request

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

Allow input for registering custom rules #14

Closed mitchspano closed 1 year ago

mitchspano commented 2 years ago

When using a PMD ruleset file which contains a custom rule, sfdx scanner requires the registration of the rules before they can be picked up by the scan. For each file, we need to call sfdx scanner:rule:add with the appropriate --language and --path arguments.

The sfdx-scan-pull-request action should enable users to define the languages and paths that they want to register before scan execution.

For additional context, see this comment.

mitchspano commented 1 year ago

I've began working on this in the feature/registerCustomRules branch.

We can test it out like this:

- name: Run SFDX Scanner - Report findings as comments
  uses: mitchspano/sfdx-scan-pull-request@feature/registerCustomRules
  with:
    report-mode: comments
    pmdconfig: "pmd/category/xml/custom.xml"
    custom-pmd-rules: '[{ "rulesetPath": "pmd/category/xml/custom.xml", "language": "xml"}]'
  env:
    GITHUB_TOKEN: ${{ secrets.TOKEN }}
mitchspano commented 1 year ago

I was able to register custom Apex rules and have them executed with the scan:

image

I will make some additional minor changes over the weekend, but looking forward to publishing this improvement to the action!