-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add URLEqualHashCode Recipe #251
base: main
Are you sure you want to change the base?
Add URLEqualHashCode Recipe #251
Conversation
Interesting. I suppose there are also legitimate uses (like file URLs). Otherwise any HashSet or HashMap would also be problematic. In this case the URLs are known to be for files: https://github.com/jetty/jetty.project/blob/5d9679adf861bc589fdb213758a88f16436f6286/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaInfConfiguration.java#L660 |
Interesting insight. Not sure if there's a great way to detect that. In general, this could be an optionally applied recipe. Dealing with collections could be super complicated, especially when the collection is returned/escapes the scope of the method. |
4114518
to
4d7dd97
Compare
4d7dd97
to
c85c709
Compare
Is this good to merge? |
description = "Uses of equals() and hashCode() cause java.net.URL to make blocking internet connections. " + | ||
"Instead, use java.net.URI.", | ||
tags = {"errorprone"} | ||
) |
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 we should add some Markdown formatting here. Also, I don't think the errorprone
tag is very useful. Does Errorprone have a check of this type?
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.
https://errorprone.info/bugpattern/URLEqualsHashCode
I'll add the markdown formatting. Good point. 😄
Based upon, but not completely fixing this: https://errorprone.info/bugpattern/URLEqualsHashCode Signed-off-by: Jonathan Leitschuh <Jonathan.Leitschuh@gmail.com>
c85c709
to
c3f647d
Compare
Based upon, but not completely fixing this: https://errorprone.info/bugpattern/URLEqualsHashCode
Signed-off-by: Jonathan Leitschuh Jonathan.Leitschuh@gmail.com
What's changed?
Adds a recipe
URLEqualsHashCode
.What's your motivation?
I was curious about trying out the new template recipe generation. This seemed like a fun way to try it out.
Anything in particular you'd like reviewers to focus on?
Are there any use cases/tests that I likely missed?
Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
Thought about writing the recipe not using the template engine, but this seemed like a good use case.
Also, the reason I'm using
URI#toString
to create a URI, instead ofURL#toURI
is becauseURL#toURI
throws a checked exceptionAny additional context
Checklist