GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] Fix #6237: Deprecate AddEmptyString without replacement by amritkang165 · Pull Request #7311 · pmd/pmd

Conversation

@amritkang165

@amritkang165 amritkang165 commented Nov 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Describe the PR

AddEmptyString recommends replacing empty-string concatenation for performance reasons, but that advice no longer holds on modern JDKs. This deprecates the rule without a replacement in PMD 7.30.0, for removal in PMD 8.0.0, following the direction in the issue.

Explicit rule references continue to work during the deprecation period, while references to the whole Performance category exclude it. The patch updates the rule description, examples, Java deprecation annotation, and release notes, and adjusts an existing warning snapshot for the XML line-number change. Existing ruleset-loading tests cover deprecation behavior; the rule's eight XML test cases remain unchanged.

Validation: all 121 selected tests passed (AddEmptyStringTest, core and Java RuleSetFactoryTest, and QuickstartRulesetTest). Checkstyle and git diff --check passed. The full ./mvnw clean verify build was not run locally.

Related issues

  • Fixes [java] AddEmptyString: Deprecate rule because performance claim is not valid anymore #6327

Ready?

  • Added unit tests for fixed bug/feature (existing coverage retained; redundant additions removed following review)
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@amritkang165
[java] Deprecate AddEmptyString without replacement
08d91ca
@amritkang165
amritkang165 force-pushed the deprecate-6327-add-empty-string branch from 6560cca to 08d91ca Compare November 10, 2026 12:08
@UncleOwen UncleOwen changed the title [java] Deprecate AddEmptyString without replacement [java] Fix #6237: Deprecate AddEmptyString without replacement Nov 10, 2026
zbynek
zbynek reviewed Nov 10, 2026
View reviewed changes
Comment thread pmd-java/src/main/resources/category/java/performance.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

@pmd-actions-helper

pmd-actions-helper Bot commented Nov 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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 3216 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-11-10 22:49:11+00:00 for fce9a57)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@amritkang165
Simplify AddEmptyString example comments
a5b7dab
zbynek
zbynek approved these changes Nov 10, 2026
View reviewed changes
UncleOwen
UncleOwen reviewed Nov 10, 2026
View reviewed changes
Comment thread pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/performance/AddEmptyStringTest.java Outdated
Comment on lines +19 to +40

@Test
void explicitReferenceStillLoadsDeprecatedRule() {
Rule rule = new RuleSetLoader().warnDeprecated(false)
.loadFromResource("category/java/performance.xml/AddEmptyString")
.getRuleByName("AddEmptyString");

assertNotNull(rule);
assertTrue(rule.isDeprecated());
}

@Test
void categoryReferenceExcludesDeprecatedRule() {
RuleSet rules = new RuleSetLoader().loadFromString("ruleset.xml",
"<ruleset name=\"test\">"
+ "<description>Performance rules</description>"
+ "<rule ref=\"category/java/performance.xml\"/>"
+ "</ruleset>");

assertNull(rules.getRuleByName("AddEmptyString"));
assertNotNull(rules.getRuleByName("AppendCharacterWithChar"));
}

@UncleOwen UncleOwen Nov 10, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We already have tests that verify that a a deprecated rule isn't loaded when a whole category is included. See https://github.com/pmd/pmd/blob/main/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryTest.java#L809

Please remove this, it's just one more thing to forget when we remove the rule.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@amritkang165 amritkang165 Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Removed the duplicate test and unused imports in 2cfc635. Tests and Checkstyle pass. Thanks for pointing this out!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@zbynek zbynek Nov 10, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think this should apply to both tests, you can remove the second one too (most deprecated rules have just the .xml based tests).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@amritkang165 amritkang165 Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Removed the second test too in fce9a57. The existing XML tests are unchanged, and all 121 selected tests and Checkstyle pass. Thanks

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
amritkang165 added 2 commits November 11, 2026 02:08
@amritkang165
Remove redundant deprecated-rule category test
2cfc635
@amritkang165
Remove redundant explicit deprecated-rule reference test
fce9a57
UncleOwen
UncleOwen approved these changes Nov 11, 2026
View reviewed changes

@UncleOwen UncleOwen left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@UncleOwen UncleOwen added this to the 7.30.0 milestone Nov 11, 2026
@UncleOwen
UncleOwen merged commit 84ed9dc into pmd:main Nov 11, 2026
13 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@adangel adangel added the is:deprecation The main focus is deprecating public APIs or rules, eg to make them internal, or removing them label Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@zbynek zbynek zbynek approved these changes
@UncleOwen UncleOwen UncleOwen approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

is:deprecation The main focus is deprecating public APIs or rules, eg to make them internal, or removing them

Projects

None yet

Milestone

7.30.0

Development

Successfully merging this pull request may close these issues.

[java] AddEmptyString: Deprecate rule because performance claim is not valid anymore

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@amritkang165 @zbynek @UncleOwen @adangel
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.