Skip to content

[java] Update rule ConsecutiveLiteralAppends#3335

Merged
adangel merged 3 commits into
pmd:pmd/7.0.xfrom
adangel:pmd7-update-ConsecutiveLiteralAppends
Jun 25, 2021
Merged

[java] Update rule ConsecutiveLiteralAppends#3335
adangel merged 3 commits into
pmd:pmd/7.0.xfrom
adangel:pmd7-update-ConsecutiveLiteralAppends

Conversation

@adangel

@adangel adangel commented Jun 11, 2021

Copy link
Copy Markdown
Member

Describe the PR

Note: This fixes a false positive: intervening calls to toString() are no longer ignored, as the result of toString() would
change if the consecutive append calls would be merged. The same of length().

E.g.

StringBuilder sb = new StringBuilder();
sb.append("a");
System.out.println(sb.toString());
System.out.println(sb.length());
sb.append("b");

This is no longer flagged since merging the two append calls into sb.append("ab"); will change the result of the program....

Related issues

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)

Fixes a false positive: intervening calls to toString()
are no longer ignored, as the result of toString() would
change if the consecutive append calls would be merged.
@adangel adangel added this to the 7.0.0 milestone Jun 11, 2021
@ghost

ghost commented Jun 11, 2021

Copy link
Copy Markdown
2 Messages
📖 Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 65 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report
📖 Compared to master:
This changeset changes 0 violations,
introduces 5 new violations, 1 new errors and 0 new configuration errors,
removes 304748 violations, 8 errors and 2 configuration errors.
Full report
Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 65 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report
Compared to master:
This changeset changes 1 violations,
introduces 5 new violations, 1 new errors and 0 new configuration errors,
removes 304748 violations, 8 errors and 2 configuration errors.
Full report
Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 78 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report
Compared to master:
This changeset changes 2 violations,
introduces 18 new violations, 1 new errors and 0 new configuration errors,
removes 304746 violations, 8 errors and 2 configuration errors.
Full report

Generated by 🚫 Danger

@adangel adangel marked this pull request as ready for review June 11, 2021 15:36
@adangel adangel self-assigned this Jun 25, 2021
@adangel adangel merged commit 62a1bfe into pmd:pmd/7.0.x Jun 25, 2021
@adangel adangel deleted the pmd7-update-ConsecutiveLiteralAppends branch June 25, 2021 14:43
@adangel adangel mentioned this pull request Jan 23, 2023
55 tasks
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