Improve the quality, performance and security of your code with Gearset’s static code analysis

Ellis Toms on November 28th 2017


To ensure that you are writing high quality, easily maintainable Apex code, it's important that you follow a few best practices in terms of code structure and content. With our latest release, Gearset now automatically performs static code analysis on the Apex in your orgs, helping you write higher quality and more effective code and ultimately speed up release cycles.

How Gearset’s static code analysis works

With Gearset, you can ensure that your code quality and performance is maintained throughout the whole development process, as and when changes are made. Every time a change monitoring job runs, Gearset’s PMD-based static code analysis will evaluate code quality and structure to identify bad programming habits, highlight inconsistent code and warn you of any issues within the codebase. This will allow you to quickly amend and fix any problematic code, keeping code quality high and reducing the chances of bugs.

Currently, static code analysis automatically runs as part of Gearset's change monitoring jobs. To get started all you have to do is set up a change monitor job to run on your org. For more help on how to do this see our handy quick start guide.

Reviewing the static code analysis results

Under the Monitoring and Backup page, you can view all the change monitoring jobs running across your Salesforce organizations. Click View history to see the results of the monitoring job.

Navigate to the Change monitoring overview page

From here, simply click View code analysis... for any of the job runs to see the full rundown of the changing state of your Apex code.

Dive into the static code analysis for each job run

On the static code analysis results page, Gearset will display any warnings or rule violations detected. You can dive into any potential issues within your codebase by looking at the class and type of violation and the location within the code, while a detailed description of the rule violated makes it easy to understand why the code has been flagged as problematic.

View the automatically generated static code analysis results

For more information on each specific rule and how it works, the ‘Check name’ field will take you to the PMD library for a more in-depth look at the individual rule and its Java implementation.

Use the Check name field for a more in-depth understanding of the rule that the PMD library has flagged up

With this analysis you’ll be able to review your code as you develop it, making sure you and your team are consistently writing high quality code, and ensuring that when problems arise they are quickly understood and fixed.

This is just the start for static code analysis

While our current integrated static code analysis will help teams maintain code and ensure secure, quality development, there are more exciting updates to this feature arriving soon! Very shortly, static code analysis will also run when configuring a comparison and deployment, and will proactively warn you of any issues within your code before you deploy. You’ll also be able to configure your code analysis to customise which rules you have switched on/off and set levels of importance, making it simple to write safe and efficient code, tailored to meet the needs of your team.

Want to try it out?

If you are interested in trying out our static code analysis click here to begin your completely free 30-day trial of Gearset today.

As always, if you have any questions or feedback on this feature or Gearset then please do get in touch via our in-app chat or through [email protected].

Ready to get started with Gearset?

Sign up now to start your completely free 30 day trial
try it now