It is always a best practice to ensure you comply with the coding standards when you write your apex classes or triggers and you probably already make sure you do that. But how do you make sure to your entire team is complying to the coding standard, how do you make sure your team, your company is delivering the best to the client?
The answer to this is Static code analysis. There are n number of tools available in the market which will run the static code analysis against salesforce code base. Few of them:
Both Checkmarx & fortify are paid whereas PMD is completely free of cost. The next question that comes to your mind: How do I run PMD against my code base?
Well, there are multiple options:
- You can download the executable, configure it, identify the rules and run it locally everytime you want to push the code to UAT or Production.
- You and your entire team installs the Apex PMD VScode plugin and this will throw the error everytime your code. But again apex can also be coded using dev console or other online IDEs like aside.io so you cannot always rely on your teammates to use Apex PMD.
- The simplest option, install the Salesforce Advanced Code searcher Chrome extension which once installed will allow you to run the PMD checks right inside your browser. It will spit out the results in an excel sheet which you can then analyze and assign to team members to fix. And this will work in sandboxes and Production org.
So, what are you waiting for?? Install the plugin and discover the mess your developers have created 🙂
P.S: This extension also allows you to run static code analysis against your aura components.