Skip to content

[apex] Fix ApexUnitTestShouldNotUseSeeAllDataTrue violation location - #6955

Merged
UncleOwen merged 3 commits into
pmd:mainfrom
tarann26:fix/apex-seealldata-violation-node
Aug 8, 2026
Merged

UncleOwen merged 3 commits into
pmd:mainfrom
tarann26:fix/apex-seealldata-violation-node

Conversation

@tarann26

@tarann26 tarann26 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #5904.

ApexUnitTestShouldNotUseSeeAllDataTrue was reporting the violation on the whole class or method node instead of the seeAllData annotation parameter itself. In practice this means the highlighted range in editor integrations (e.g. the Salesforce Code Analyzer VS Code extension, per the issue) covers the entire test method instead of just the offending annotation.

The fix is a one-liner: report on the parameter node that was already being matched, instead of the enclosing class/method node.

Updated the existing expected-violation line numbers in the rule's test XML to match the parameter's actual position (previously they matched the class/method declaration's line, which happened to be adjacent to the annotation in those fixtures), and added a new test case with a multi-line, multi-parameter @isTest(...) annotation to make the range-narrowing behavior explicit and hard to regress.

The rule reported the violation on the whole class or method node
instead of the offending seeAllData annotation parameter, which
made the highlighted range span the entire test method in editor
integrations. Report the violation on the parameter node itself and
update the expected line numbers in the rule's test data accordingly.

Fixes pmd#5904
@pmd-actions-helper

pmd-actions-helper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 25 errors and 9 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-08-08 16:43:57+00:00 for 6179593)

@UncleOwen UncleOwen added this to the 7.27.0 milestone Aug 8, 2026

@UncleOwen UncleOwen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@UncleOwen
UncleOwen merged commit 2c829a3 into pmd:main Aug 8, 2026
13 checks passed
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.

[apex] ApexUnitTestShouldNotUseSeeAllDataTrue violation range should only be the annotation and not the entire test method

2 participants