Skip to content

chore(pmd): update PMD rulesets and add Salesforce Code Analyzer - #274

Merged
dschach merged 3 commits into
mainfrom
chore/update-pmd
Oct 9, 2026
Merged

dschach merged 3 commits into
mainfrom
chore/update-pmd

Conversation

@dschach

@dschach dschach commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

This pull request updates the PMD setup for the project. It adds Salesforce Code Analyzer. It replaces the quickstart ruleset with a full ruleset of all standard Apex rules.

Changes

PMD rulesets

  • Rename pmd/apexQuickStart.xml to pmd/apexStandardRules.xml.
  • Add all non-deprecated Apex rules from PMD 7.28.0 to the ruleset.
  • Give each rule its default priority.
  • Give each rule its properties with the default values.
  • Remove the rule messages.
  • Group the rules into sections by topic.
  • Comment out the deprecated rule ExcessiveClassLength.
  • Add pmd/allApexPMDCategories.xml. It references each standard Apex category and excludes the deprecated rules.

Salesforce Code Analyzer

  • Add code-analyzer.yml with the rule overrides.
  • Add the codeanalyzer:config script to package.json.
  • Add the Code Analyzer settings to .vscode/settings.json.
  • Point the Apex PMD extension to the new ruleset.

Workflows

  • Use pmd/apexStandardRules.xml in ci.yml and in pmd.yml.

Apex code

  • Add LIMIT 2000 to the RecordType query in recordTypesIdMap.
  • Add @SuppressWarnings annotations for the new PMD rules.
  • Change @testVisible to @TestVisible.
  • Format the asserts in UnpackagedRecordTypesTest and make the class without sharing.

Other files

  • Remove .eslintignore.
  • Add a changelog entry to README.md.

Review notes

  • The branch is now rebased on main. The merge conflict in package.json is resolved.

Testing

  1. Run pmd check --dir force-app --rulesets pmd/apexStandardRules.xml.
  2. Confirm that PMD loads the ruleset without an error.

BEGIN_NESTED_COMMIT
chore(pmd): replace apexQuickStart.xml with apexStandardRules.xml
END_NESTED_COMMIT

BEGIN_NESTED_COMMIT
chore(pmd): add allApexPMDCategories.xml ruleset
END_NESTED_COMMIT

BEGIN_NESTED_COMMIT
build(code-analyzer): add Salesforce Code Analyzer configuration
END_NESTED_COMMIT

BEGIN_NESTED_COMMIT
ci(pmd): use apexStandardRules.xml in the PMD workflows
END_NESTED_COMMIT

BEGIN_NESTED_COMMIT
perf(RecordTypes): add LIMIT 2000 to the RecordType query
END_NESTED_COMMIT

BEGIN_NESTED_COMMIT
style(RecordTypes): add PMD suppressions and fix the TestVisible case
END_NESTED_COMMIT

BEGIN_NESTED_COMMIT
test(unpackaged): format asserts and set the test class to without sharing
END_NESTED_COMMIT

BEGIN_NESTED_COMMIT
docs(readme): add a changelog entry for Code Analyzer
END_NESTED_COMMIT

dschach and others added 2 commits October 9, 2026 19:11
…ject

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.18%. Comparing base (90ea466) to head (dc4798d).
⚠️ Report is 219 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #274      +/-   ##
==========================================
+ Coverage   98.48%   99.18%   +0.69%     
==========================================
  Files           1        2       +1     
  Lines         132      244     +112     
==========================================
+ Hits          130      242     +112     
  Misses          2        2              
Flag Coverage Δ
Apex 99.18% <100.00%> (+0.69%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dschach
dschach merged commit 9ebf4ba into main Oct 9, 2026
10 of 12 checks passed
@dschach
dschach deleted the chore/update-pmd branch October 9, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant