New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[xml] Allow to check Salesforce XML Metadata using XPath rules #2133
Comments
I'm trying to do this to be able to add to PMD's Salesforce analysis capabilities. In particular, Salesforce Process Builder processes are stored in xml files ending .flow. It's nice and easy to write some XPath rules, but PMD returned a parsing error when I tried to run them on a .flow file. I tried:
Which resulted in:
If I copy the flow to end in .xml, and run:
Then PMD runs successfully and finds the problems I expected it to in the file. Currently, I use PMD in Gearset to monitor code quality in my Salesforce production system. Ultimately, I want to be able to use PMD on XML files with Gearset to monitor declarative tools like Process Builder and hold them to standards the same way as we do for Apex. |
@aidan-harding reading through the history of the related issues I thing changing the PMD CLI would be to hard and inflexible. I'd go for an additional "extensions" attribute in the ruleset. Check my last comment in #1540. |
Thanks for following up! I wonder if accepting files from stdin might be another route? Or would that run into the same inflexibility within the CLI? |
Not sure but my goal would be to make this a small and non-invasive extension that could be:
|
@gwilymatgearset just in case you want to work on this, I assigned it to you, me and @aidan-harding who had some interest and ideas into that. It would be great if we could collab a bit on that here. |
My few use case are:
|
@ankushsomani09 can you please be a bit more specific per use case e.g. describing this: Use Case: Don't allow Users as recipients in workflow email alert.
|
@oowekyala I saw your recently deprecated Abstract XML rules classes like "AbstractWsdlRule". If we want to add Java-based rules for Salesforce XML dialects is there a new way to go? Please advise me and @aidan-harding |
For reference, the parse exception is because we fall back on the java parser because we don't recognize the extension.
I believe if there really is a push to support java XML rules then they should directly use the underlying DOM nodes. I think that should still be supported. However I think while XPath suffices, it should be preferred. Note that the XPath API can be extended with language-specific functions. They're implemented in java, so are very powerful, but XPath rules can use them in an idiomatic way. This is how pmd-java has FWIW I don't see why #2133 (comment) couldn't be implemented with just XPath rules |
To answer your "I don't see why #2133 (comment) couldn't be implemented with just XPath rules" : XML XPath rules would work but only when the file extension is This is the reason why I am so keen on helping @aidan-harding move forward with his current contributions #3413 and #2133 Does that make sense to you @oowekyala ? |
Yes but XML Java rules would have the same problem. Maybe I misunderstood, but I was opposing XPath rules to rules written in java, since you wanted to know how to write java rules for an xml dialect. |
Late to comment. Our rule was like this : |
I want to use the XML version of PMD to find issues in Salesforce.com metadata which is often XML formatted. The problem is those files never end as ".xml" but as ".flow" or ".meta-xml".
How would I need to run PMD to make that work? Or is this currently unsupported as this open issue might support #1540?
The text was updated successfully, but these errors were encountered: