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

Add a new wart: NonPrimitiveInStringInterpolation #55

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

y-yu
Copy link
Contributor

@y-yu y-yu commented Sep 20, 2020

@y-yu y-yu requested a review from xuwei-k as a code owner September 20, 2020 08:11
@y-yu y-yu force-pushed the add-wart-NonStringInStringInterpolation branch 2 times, most recently from fd1a602 to 9136eb1 Compare September 20, 2020 13:15
@reibitto
Copy link

I've found myself wanting a rule for this too. Restricting this to just String might be a little too much though? Primitive types seem mostly alright to me. I don't know... maybe it's a fine default though.

If you could define a Set of types that are allowed in the config, it might cover more cases. Like, I might want to say "allow only String and all primitives except Float/Double" (since I might want to make sure floating-point numbers are always explicitly formatted).

@y-yu y-yu force-pushed the add-wart-NonStringInStringInterpolation branch from 9136eb1 to 2139eab Compare September 20, 2020 13:45
@y-yu
Copy link
Contributor Author

y-yu commented Sep 20, 2020

Primitive types seem mostly alright to me

I thought it would be better to allow CharSequence rather than String...
I also think that it doesn't make sense to allow us to use all primitive types. As you said, some people cannot determine if it can be OK to use Float and Double in string interpolations. The only type we can use in string interpolations is String, which is very clear and simple to understand. I don't know it's good or not but I prefer clearness and simpleness than extensibility.

@y-yu
Copy link
Contributor Author

y-yu commented Sep 20, 2020

I welcome discussions about what types should be allowed 🤔

@reibitto
Copy link

I don't think there's a definite answer, but I think you're right that String/CharSequence might be the "safest" default. I'm only bringing up the idea of customizable sets of types because I think it would be a shame if this PR gets closed due to no consensus being reached. Even if I would prefer some primitive types to be included too, I'd rather use this String-only rule as is than not having it at all.

@y-yu
Copy link
Contributor Author

y-yu commented Sep 20, 2020

By the way, how can we provide settings/configurations to wart? 🤔

@reibitto
Copy link

Oh, hmm, there might not be a built-in way of customizing rules. Sorry, I assumed there was. Using properties or something isn't exactly ideal...

If there is no nice way of doing it currently, I guess that kind of eliminates my suggestion. Oh well, carry on. 😅

@y-yu
Copy link
Contributor Author

y-yu commented Sep 23, 2020

I thought https://github.com/wartremover/wartremover-contrib/pull/55/files#diff-bbbae801164db9c1ce1a89a3fe34c5c7R34 👈 this is the result of a new optimization provided by Scala2.13 🤔
If it's true, this wart maybe give us true negative decisions due to the optimization. I think it's a problem.

@y-yu
Copy link
Contributor Author

y-yu commented Sep 23, 2020

@y-yu y-yu force-pushed the add-wart-NonStringInStringInterpolation branch from 2139eab to 7d02a5c Compare September 23, 2020 17:12
@y-yu
Copy link
Contributor Author

y-yu commented Oct 5, 2020

@xuwei-k Could you please check this PR? 🙇

@y-yu y-yu force-pushed the add-wart-NonStringInStringInterpolation branch from 474db6c to 4b27f7f Compare December 16, 2020 13:10
@y-yu y-yu changed the title Add a new wart: NonStringInStringInterpolation Add a new wart: NonPrimitiveInStringInterpolation Dec 16, 2020
@y-yu
Copy link
Contributor Author

y-yu commented Dec 16, 2020

I changed that it also allows us to use the other primitive types, not only String. I used it, and I think it would be better. Thanks @reibitto for your suggestion.

@xuwei-k
Copy link
Contributor

xuwei-k commented May 8, 2024

@som-snytt
Copy link

Thanks for linking. I will look for more ideas over here.

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.

4 participants