Closed meghana-viswanath closed 7 years ago
We have a similar case in our codebase:
val dimensions = Seq(
Dimensions(120, 240),
Dimensions(240, 360),
...
)
It would be very difficult to spot all such cases automatically, I imagine, especially with nested collections and custom collections. The workaround that works well for us is to surround the val definition with // scalastyle:on/off magic.number
. FWIW.
I too think that it would be difficult to spot all of these problems automatically. I would suggest using scalastyle:on/off. Closed. If there is still an issue, please reopen.
Hi,
The magic number rule, in my opinion, incorrectly flags a collection of numbers assigned to a variable, eg. val numbers = Array(5,10,20,25,30) The intention behind the array is explicitly defined by the variable name.
Thanks, Meghana.