Salesforce Code Scanner – How to Bake Quality in Your Code with Apex PMDThere are a series of best practices that Salesforce recommends you to follow when working on the technology. Whether you are an admin or consultant doing the configuration or a developer writing code, these best practices help you build a solid foundation, improve quality, avoid making mistakes and become better in what you do.

But this is also true that most of the time these best practices are not being followed. This may be because people are ignorant, following requires extra effort and/or extra investment in tool/technology. 

If you are a Salesforce developer, here is one such tool which is free and easy to use and will guide you to bake quality in your code as you are developing it. After learning how to do it, there will be no reason for you not to use it in your day to day work and become an awesome developer. 🙂

Called Apex PMD (stands for Programming Mistake Detector), this is a tool that analyses source code to flag deviation from best practices, programming errors, bugs, stylistic errors, and suspicious constructs. You can perform Apex Static Analysis directly in Visual Studio Code on Apex and Visualforce files.  Apex PMD is available as an extension for Visual Studio Code. 

(If you haven’t yet switched to Visual Studio Code for your Salesforce development work, you may want to refer to my step-by-step guide on “How To Get Started with Visual Studio Code for Salesforce)

Supported Actions

With Apex PMD, analysis can be performed when file is opened or closed. It can be performed on a single file or on the entire workspace at once. You can also define your custom rulesets in .jar files to meet your code compliance needs.

Apex PMD is a very useful tool. You can refer to the suggestions/problems highlighted by the tool from the initial stages in development cycle and make changes in your code accordingly. This will help you learn and follow the best practices right from the beginning, making you a better developer in the process with high quality work. 

Follow this guide and in less than 15 minutes (literally), you will learn how to install and use Apex PMD. Here’s what this guide covers:

  • Install Apex PMD in Visual Studio Code
  • Perform Apex Static Analysis on File
  • Perform Apex Static Analysis on Workspace
  • Clear analysis Problems from Visual Studio Code Panel
  • Set Preferences for Apex PMD

After going through it, you will come to know that you can have a code companion to guide you in developing compliant, efficient, secure, scalable and sustainable applications.


To download a PDF copy of the presentation above



check to receive weekly updates on more of such awesome guides





(You'll never be spammed on my watch. And that's a promise)

If you haven’t yet started using Visual Studio Code for Salesforce development, I will highly recommend to start using the same as Salesforce itself has come up with an extension on VS Code and will continue to enhance it.   

Here is my another blog post that contains step-by-step guide on “How To Get Started with Visual Studio Code for Salesforce

References: