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

Should NullChecker have a "allowNullChecks" parameter? #204

Open
k0ala opened this issue May 17, 2016 · 1 comment
Open

Should NullChecker have a "allowNullChecks" parameter? #204

k0ala opened this issue May 17, 2016 · 1 comment
Labels

Comments

@k0ala
Copy link

k0ala commented May 17, 2016

The NullChecker currently complains about any null it finds in the codebase. However, even Scala's creator advises checking for nulls with x != null.

Perhaps this checker should have a parameter like allowNullChecks, that would permit testing for nulls, but would complain if it finds null in an assignment.

@matthewfarwell
Copy link
Member

Good idea. You can use Option.apply of course as well.

If you still want this, would you like to add the parameter and submit a PR?

k0ala added a commit to k0ala/scalastyle that referenced this issue Apr 19, 2017
The NullChecker takes a parameter allowNullChecks (which defaults to true)
indicating that 'null' is tolerated in the code if it is preceded by
equality '==' or inequality '!='.

Added a test which covers both above cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants