Skip to content

Conversation

mihnita
Copy link
Member

@mihnita mihnita commented Oct 19, 2025

Fix for #5278

Copy link
Contributor

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

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

Just something I noticed on a quick skim.

Copy link
Collaborator

@cushon cushon left a comment

Choose a reason for hiding this comment

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

Thanks for this!

+ " (which takes in an IETF BCP 47-formatted string) or a Locale.Builder"
+ " (which throws exceptions when the input is not well-formed).\n"
+ "Please read the Error Prone documentation page for UnsafeLocaleUsage for"
+ " more information.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

The generated diagnostics automatically include the link to the full 'explanation', so writing this out here isn't necessary

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Description.Builder descriptionBuilder =
buildDescription(tree)
.setMessage(
"Avoid using Locale.of static methods (which do not check their arguments for"
Copy link
Collaborator

Choose a reason for hiding this comment

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

By default, the message is the BugPattern.summary. Is there information here that applies to all findings that could go in the summary instead?

If you want to customize this to mention e.g. Locale.of vs. Locale constructors, WDYT about refactoring and using a format string to share the text that's the same for both?

Copy link
Member Author

Choose a reason for hiding this comment

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

Between constructors and Locale.of there is a lot of sharing (they are basically the same).
I refactored the messages to share, as suggested.

toString throws a wrench in reusing much in the summary.
But while reviewing it I discovered that java.util.Locale is not a library :-), and I fixed that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Member Author

@mihnita mihnita left a comment

Choose a reason for hiding this comment

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

Done, thank you.

Description.Builder descriptionBuilder =
buildDescription(tree)
.setMessage(
"Avoid using Locale.of static methods (which do not check their arguments for"
Copy link
Member Author

Choose a reason for hiding this comment

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

Between constructors and Locale.of there is a lot of sharing (they are basically the same).
I refactored the messages to share, as suggested.

toString throws a wrench in reusing much in the summary.
But while reviewing it I discovered that java.util.Locale is not a library :-), and I fixed that.

+ " (which takes in an IETF BCP 47-formatted string) or a Locale.Builder"
+ " (which throws exceptions when the input is not well-formed).\n"
+ "Please read the Error Prone documentation page for UnsafeLocaleUsage for"
+ " more information.");
Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@mihnita mihnita requested a review from cushon October 20, 2025 15:44
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.

3 participants