Skip to content

[core] Tokens: Add asserts - start of a location is never after the end of the location - #7123

Merged
adangel merged 2 commits into
pmd:mainfrom
UncleOwen:add-asserts
Oct 23, 2026
Merged

adangel merged 2 commits into
pmd:mainfrom
UncleOwen:add-asserts

Conversation

@UncleOwen

Copy link
Copy Markdown
Member

Describe the PR

This doesn't look correct: the end column should never be smaller than the begin column...

Since the build is actually running, we might be missing an assert in pmd-core for Tokens.

Originally posted by @adangel in #7050 (comment)

As promised, here's the PR that adds the assertion in TokenEntry.java. I found a similar missing assertion in TextRange2d.java. MarkTest was failing with the new assertion, so I fixed it.

Related issues

  • None

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

The beginning of a location must never be after its end.

Fix MarkTest to not violate that assert.
@pmd-actions-helper

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, 0 errors and 0 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-09-29 17:05:55+00:00 for 2cf01d5)

@adangel adangel added in:pmd-internals Affects PMD's internals in:cpd Affects the copy-paste detector labels Oct 23, 2026
@adangel adangel changed the title [core] Add two asserts - start of a location is never after the end of the location [core] Tokens: Add asserts - start of a location is never after the end of the location Oct 23, 2026
@adangel adangel added this to the 7.29.0 milestone Oct 23, 2026

@adangel adangel 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!

@adangel
adangel merged commit 8a860d5 into pmd:main Oct 23, 2026
13 checks passed
@UncleOwen
UncleOwen deleted the add-asserts branch October 23, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:cpd Affects the copy-paste detector in:pmd-internals Affects PMD's internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants