To help your team maintain clean and consistent code in Salesforce, Clayton allows you to define and enforce specific naming standards . This guide will walk you through the process of customizing the "Intentional" policy in Clayton to establish and apply your desired naming conventions, ensuring that your development practices are standardized and your codebase remains healthy
How to Editing the "Intentional" Policy
To configure your naming convention rules, you'll want to focus on editing the "Intentional" policy and specifically adjusting its Pattern
with regular expressions (regex) that align with your team's naming conventions.
Accessing Policies in Clayton
From your Clayton homepage, navigate to the Admin Tool located at the bottom left of the page. Next select the dropdown menu, select Policies. You'll now see a list of your configured policies.
Locate the Intentional policy in the list and select the pencil icon. You will now see all the rules within this policy. Within this policy a number of rules that flag Inconsistent naming in different objects exist
"Inconsistent naming Apex classes"
"Inconsistent naming Apex methods"
"Inconsistent naming Apex test classes"
"Inconsistent naming Apex test classes (inner classes)"
"Inconsistent naming Apex triggers"
"Inconsistent naming Apex variables"
"Inconsistent naming Aura controller properties"
"Inconsistent naming custom fields"
"Inconsistent naming custom object"
For each of these rules, you can edit its Pattern
to define your specific naming convention using regular expressions. To do this simply select the pencil icon.
Let's say your team has adopted a standard where all Apex class names must start with "Clayton", followed by a capital letter, to denote code managed or strictly adhering to Clayton's best practices. You would configure this for the "Inconsistent naming Apex classes" rule as follows:
Find the "Inconsistent naming Apex classes" rule and select the pencil icon on the right hand side.
Enter the regular expression that matches your desired naming convention. For this example, it would be:
^Clayton[A-Z][a-zA-Z0-9]*$
^
: Asserts the start of the string.Clayton
: Matches the literal string "Clayton".[A-Z]
: Matches any single uppercase letter (ensuring the next character after "Clayton" is capitalized).[a-zA-Z0-9]*
: Matches zero or more alphanumeric characters (allowing for subsequent valid class name characters).$
: Asserts the end of the string.
Save the changes for that specific rule.
If you're not familiar with them, wWe highly recommend using an online regex tester (such as https://regex101.com/) to experiment and ensure your pattern accurately captures your desired naming convention while avoiding unintended matches.
Publishing the Updated Policy
Once you have configured all the relevant naming convention rules within the "Intentional" policy: