Skip to content

Instantly share code, notes, and snippets.

@aidan-harding
Created August 2, 2021 10:15
Show Gist options
  • Save aidan-harding/e670cef0217f4eb5dfbe052c88fc6d75 to your computer and use it in GitHub Desktop.
Save aidan-harding/e670cef0217f4eb5dfbe052c88fc6d75 to your computer and use it in GitHub Desktop.
XPath PMD rule to check that Salesforce custom fields contain no underscores
<?xml version="1.0"?>
<ruleset name="Salesforce Custom Rules"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>
My Salesforce rules
</description>
<rule name="NoUnderscoresInFieldNames"
language="xml"
message="Custom fields should not contain underscores."
class="net.sourceforge.pmd.lang.rule.XPathRule" >
<description>
TODO
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//fields/fullName/text[matches(@Image, ".*_.*__c")]
]]>
</value>
</property>
</properties>
</rule>
</ruleset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment