-
Notifications
You must be signed in to change notification settings - Fork 16
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
base: master
Are you sure you want to change the base?
Add a new wart: NonPrimitiveInStringInterpolation #55
Conversation
fd1a602
to
9136eb1
Compare
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). |
9136eb1
to
2139eab
Compare
I thought it would be better to allow |
I welcome discussions about what types should be allowed 🤔 |
I don't think there's a definite answer, but I think you're right that |
By the way, how can we provide settings/configurations to wart? 🤔 |
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. 😅 |
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 🤔 |
I think the optimization is up to |
2139eab
to
7d02a5c
Compare
@xuwei-k Could you please check this PR? 🙇 |
474db6c
to
4b27f7f
Compare
I changed that it also allows us to use the other primitive types, not only |
Thanks for linking. I will look for more ideas over here. |
primitive value in the string interpolation such asString
s"hello $caseClass"
whereval caseClass = Dummy("world")
String
to an other type, then most of places I have to fix were pointed out as compilation errorsNonPrimitiveInStringInterpolation
, which does not allow us to use string interpolations that contain non-primitive value as the argumentsString
String