Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce RedundantStringEscape check #1138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Stephan202
Copy link
Member

@Stephan202 Stephan202 commented Apr 14, 2024

Suggested commit message:

Introduce `RedundantStringEscape` check (#1138)

This check aims to simplify string constants by dropping redundant
single quote escape sequences. The check is optimized for performance.

While there, update existing checks such that they do not introduce
violations of the type flagged by this new check.

This check aims to simplify string constants by dropping redundant
single quote escape sequences. The check is optimized for performance.

While there, update existing checks such that they do not introduce
violations of the type flagged by this new check.
@Stephan202 Stephan202 added this to the 0.17.0 milestone Apr 14, 2024
@Stephan202 Stephan202 requested a review from rickie April 14, 2024 17:27
Copy link

sonarcloud bot commented Apr 14, 2024

Copy link

  • Surviving mutants in this change: 1
  • Killed mutants in this change: 31
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.RedundantStringEscape 1 21
🎉tech.picnic.errorprone.utils.SourceCode 0 5
🎉tech.picnic.errorprone.bugpatterns.StringJoin 0 1
🎉tech.picnic.errorprone.bugpatterns.Slf4jLogStatement 0 2
🎉tech.picnic.errorprone.guidelines.bugpatterns.ErrorProneRuntimeClasspath 0 2

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Override
public Description matchLiteral(LiteralTree tree, VisitorState state) {
String constant = ASTHelpers.constValue(tree, String.class);
if (constant == null || constant.indexOf('\'') == -1) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Pitest is correct that the || constant.indexOf('\'') == -1 condition can be dropped. It's here for performance reasons.

@werli werli self-requested a review April 15, 2024 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant