Gearset’s static code analysis now runs on PMD 6.3.0

Gearset’s static code analysis now runs on PMD 6.3.0

Ellis Toms on

Share with


Gearset’s PMD-based static code analysis has been running on users’ deployments and backups since the start of 2018, helping improve Apex code standards across Salesforce development teams.

We’ve recently upgraded the version of PMD our static code analysis is built on, from 5.8.1 to 6.3.0. In this upgrade PMD fixed a few bugs but also added some useful and exciting functionality that you can take advantage of with Gearset. The new version brings the ability to suppress Apex code warnings, as well as 16 new rules, giving you more power to tailor your rule set to your needs.

New rules

PMD 6.3.0 has introduced 16 new rules to the standard ruleset, including CyclomaticComplexity to detect nested logic and help with code readability, and AvoidSoslInLoops to monitor code performance.

While the new rules cover a variety of areas, the main focus is on detecting code that is likely to cause errors. This helps your team pick up error-prone code syntax before it ever hits your orgs, making it easier for your team to maintain coding standards. To turn on these new rules, team owners should go to the static code analysis rule sets page.

Live eventConvene, Chicago

DevOps Dreamin’ Chicago 2024

Find out more

Suppress warnings

This has been available in PMD for other languages for some time and was introduced for Apex in version 6. You can turn off static code analysis for particular Apex classes - either as a whole or for specific rules, allowing you to customize your rule set to ignore false positives or violations in specific classes.

How it works:

To suppress warnings you’ll need to add the flag to the top of your Apex class either in Salesforce or through your IDE:

// This will suppress all the PMD warnings in this class
public class Foo {
  void foo () {
    int var;

You can also suppress specific rules by adding them by name to a comma separated list, for example:

@SuppressWarnings('PMD.VariableNamingConventions, PMD.ApexUnitTestClassShouldHaveAsserts')

Doing this will stop Gearset’s static code analysis from reporting violations of the specified rules for the classes in question. You’ll be able to focus on what’s important to you, giving your team more flexibility to get the static code analysis results that mean the most for your organisation and what you’re working on.

Try it out!

Static code analysis continues to run just as it did before, so users will continue to reap all the benefits of consistent best practice and code standards across their team. Team owners can turn on the new rules, and configure existing rules, via their static code analysis accounts page - and now developers can even fine tune what runs on each class.

If you want to test out this feature for yourself, sign up for a 30-day free trial of Gearset today. And don’t worry, there’s no credit card information required or anything to install in your orgs - just log in, and get going!

Try all of Gearset for free