forcedotcom / sfdx-scanner

MIT License
217 stars 50 forks source link

[Feature Request] Allow custom PMD rules to be referenced by relative path instread of absolute path. #1244

Open keirbowden opened 1 year ago

keirbowden commented 1 year ago

Is your feature request related to an issue that you encountered with Salesforce Code Analyzer? No

Describe the solution that you want: I would like to be able to create a standard ruleset for my organisation that includes references to custom rules. After adding a custom rule to the scanner, I find I can only reference the rule by providing the absolute pathname, which may not match everyone else's setup.

For example, I have a custom rule defined in ~/bm-pmd-rules-new/category/iprules.xml, which I add to the scanner.

To reference this in a ruleset, I have to provide the absolute pathname, including my home directory:

<rule ref="/Users/kbowden/bm-pmd-rules-new/category/apex/iprules.xml/SoqlOnlyInTestAndAccessorClasses"/>

The rest of my organisation won't have the home directory of /Users/kbowden, so I can't publish this ruleset and have them use it without editing.

Describe alternatives that you've considered: This isn't a big deal as I can declare the rules inline in the ruleset, but it does mean that I have to maintain it in multiple places.

Additional Context:

Workaround: Declaring the rule inline works fine, but in my example I now have it as a custom rule and in the ruleset, so if I need changes I have to change in two places.

Urgency: Nice to have.

git2gus[bot] commented 1 year ago

This issue has been linked to a new work item: W-14494855

johnbelo commented 1 year ago

Many thanks @keirbowden - we are going to expand our capabilities around customization in the future and this is one that we are planning to address. Stay tuned!