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
Magic Number #5
Comments
Sorry for the late reply. That's the reason it's only partially implemented. It detects the fact that a magic number is used, but can't tell the context, so there isn't a way to comply. The eventual rule will be something like you say. If the magic number is part of an expression which is directly assigned to a val, whether in an object, class or trait, then you won't get an error. It's on my list of things to do, but if you wanted to submit a patch, that would be welcome :-) |
Yeah will give it a go :) |
I still haven't implemented this yet, but this is what I'm planning: A magic number is a number that is not -1,0,1,2 (configurable) which appears. The rule will not raise an warning if the value is directly assigned to a val in an object, such as: object Foo { and optionally, the same thing but in a class: class Foo { If the number is not a direct assignment, then this will always raise a warning: object Foo { This is because we can't guarantee that Foo is immutable. |
I can see it's only partially implemented but how would currently comply ?
I'd expect
object Something {
val someVal = 50
}
to pass
The text was updated successfully, but these errors were encountered: