The Apex Code Quality Report in Metazoa Snapshot uses PMD static analysis to find quality problems in Apex classes and triggers. Admins and developers can prioritize findings, inspect affected code, request AI explanations or improvements, and prepare edits for deployment.
When To Use This Report
- Review technical debt involving security, performance, design, and coding practices.
- Inspect Apex quality before a release.
- Schedule recurring reports and priority-based email alerts as new snapshots become available.
Unlike Apex Code Coverage, this report analyzes code patterns rather than measuring which lines Apex tests execute.
Open The Report
- Right-click a Metadata Snapshot item on the Snapshot desktop.
- Select Apex Code Quality.
Select Apex Classes
Start with PMD Connection and use Test Installation to check that Snapshot can run the local PMD command.
Select a class or trigger to generate an immediate preview. Check the boxes beside the classes and triggers to include in Display Report; selecting a row and checking a box serve different purposes. Use Quick Find Apex Classes and Triggers or the list's right-click options to narrow the selection.
The middle pane lists findings for the selected asset. Select a finding to see the related code on the right, then use the affected line range, documentation link, and details to investigate.
Editing Palette
Click Editing Palette to expose three editing choices:
- Manual Editing opens the selected class or trigger for direct edits.
- Quality Improvement opens an AI improvement dialog. On Code Quality, select issues and inspect Issue Description, Example Code, and Issue Correction. On Apex Code, click Submit to generate Improved Code beside Original Code.
- Multiple Improvements processes multiple checked classes and triggers using the Quality Improvement prompt. Click Submit to begin.
Edit Prompts provides prompt customization for single-asset improvements. OK saves edits; Cancel discards changes in the editing dialog. Hold Escape to cancel a multiple-improvement operation. After cancellation, inspect the edited assets before starting another batch; the interface does not describe automatic resume behavior.
Display Report
This tab reports on the checked assets. Use Manage Quality to choose rules with Include Rule In Report and assign priorities from Priority 1) Change Mandatory through Priority 5) Change Optional. Default restores the default rule selections and priorities.
The five Show priority options control which findings appear. Show Links, Show Details, and Color Code change presentation. Clean Report removes empty tables, not code problems.
| Column | Description |
|---|---|
| Rule Set | The PMD category containing the rule: Best Practices, Code Style, Design, Documentation, Error Prone, Performance, or Security. |
| Priority | The configured urgency, from 1 for Mandatory to 5 for Optional. |
| Action | The response label derived from the configured priority, such as Change Required. |
| Total Changes | In Summary, the number of quality findings for an asset, not the number of edits already made. |
| Optional %, Suggested %, Recommended %, Required %, Mandatory % | The proportion of reported findings in each priority tier. |
Reports displays detailed tables. Click Dashboards to reveal charts grouped by action, rule set, class, and rule. Click Summary to reveal per-asset finding counts, priority distributions, and a cumulative Totals row.
Schedule Report
Use Schedule Report to run the configured analysis automatically on a schedule and deliver results to Email, Slack, Content, Chatter, or the Assistant. Choose an output format, such as PDF, and configure conditional email alerts based on issue priority when new snapshots are evaluated. The Assistant destination stores the selected document as Org Intelligence and replaces the previous recording after every run.
What The Results Tell You
Each finding establishes that selected snapshot code matches an included PMD rule. With Color Code enabled, the labels and colors mean:
- Change Mandatory: priority 1, red; the highest configured urgency.
- Change Required: priority 2, orange; a required correction under the configured rules.
- Change Recommended: priority 3, yellow; a recommended correction.
- Change Suggested: priority 4, lime; a suggested improvement.
- Change Optional: priority 5, green; the lowest configured urgency.
These labels reflect configurable priorities, not proof of a production failure or an exploitable vulnerability. An empty report means no findings are displayed for the selected assets, included rules, and active filters; an empty report does not establish test coverage, correct runtime behavior, or the absence of security defects.
Before accepting or deploying manual or AI edits, the admin and responsible developer confirm the intended business behavior, inspect the code differences, and retain an unchanged snapshot for recovery. After the change, rerun PMD and verify behavior with appropriate Apex tests and sandbox testing, rather than relying only on a lower finding count.
Try The Report
Use a sandbox finding to test recurring quality monitoring:
- Capture the sandbox metadata and select a class or trigger with a PMD finding.
- In Manage Quality, include that finding's rule and assign Priority 1) Change Mandatory.
- Open Display Report, enable Show Mandatory, and export a baseline PDF. The finding should show Change Mandatory, demonstrating that the configured priority controls the action label.
- Configure a recurring PDF email on Schedule Report with a Mandatory threshold.
- Have the developer correct the issue in the sandbox, then refresh the snapshot before the next scheduled evaluation.
Compare the next report with the saved baseline. A successful correction should remove that rule's finding at the corrected location; unresolved findings retain the configured action labels. Investigate remaining findings rather than treating the entire class as corrected.
Export, Explain, And Deploy Results
Right-click a report table to choose Export As CSV, Export As XLSX, Export As PDF, or Export As HTML. Keep exported baselines when comparing runs over time.
Explain Report Table opens an AI conversation about the findings and supports follow-up questions. Right-clicking the code also provides Explain Apex Classes. These explanations clarify findings; explanations do not execute tests or apply corrections.
After code edits, Deploy becomes available. The button saves edits to the current snapshot and opens deployment tools for an org or a local Salesforce DX project. A local project destination lets the team carry the changed files through an existing Git or release process instead of immediately changing an org.
Reference
PMD Installation And Connection Errors
The PMD Connection dialog lists PMD and Java JRE 1.7 as prerequisites. Set the platform-specific installation path to the local PMD command; a macOS path follows the form $HOME/pmd-bin-VERSION/bin/pmd check. Update the path when the installed PMD folder changes.
Click Test Installation and look for PMD is installed. If Snapshot reports that PMD is required or that the PMD command line could not run, correct the installation or path and test again. A failed PMD invocation is not a clean quality result.
Common Questions
Does Apex Code Quality Replace Apex Tests?
No. PMD checks static code patterns. Use Apex Code Coverage and functional testing to investigate execution coverage and behavior.
Why Does The Same Rule Have A Different Priority?
Manage Quality allows custom priorities. Compare rule settings before interpreting priority differences between reports.
Who Approves AI-Generated Apex Fixes?
AI generates proposed code. Saving edits with OK and choosing deployment remain user actions; the report does not provide an enforced approval workflow.
Can I Schedule Apex Code Quality Alerts?
Yes. Schedule Report supports recurring output and conditional email alerts based on issue priority. Refresh the underlying snapshot to evaluate newer org code.
Related Articles
- Apex Code Coverage Report - measure execution coverage from selected tests.
- Metadata Quality Report - evaluate quality beyond Apex.
- Deploy Metadata - compare destinations and configure deployment checks.
- Developer Project - work with local Salesforce DX files or a Git repository.
- Take Snapshot - refresh metadata before reporting.
Further Reading
- Org Cleanup and Optimization - technical debt reviews and staged cleanup.
- Salesforce Org Monitoring - recurring snapshots, reports, and alerts.
- Change and Release Management - quality checks within a broader release process.