-
-
Notifications
You must be signed in to change notification settings - Fork 276
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 new RSpec/BeNil
cop
#1239
Add new RSpec/BeNil
cop
#1239
Conversation
Check that `be_nil` is used instead of `be(nil)`. RSpec has a built-in `be_nil` matcher specifically for expecting `nil`. For consistent specs, we recommend using that instead of `be(nil).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you!
Note that it's not 100% safe.
More importantly, I see absolutely no reason to prefer |
We couldn't figure out a real example. |
Well, that is true 😅 Should we consider making the cop configurable to users can enforce either one style or the other? |
Make `RSpec/BeNil` cop configurable with a `be_nil` and a `be` style. Inspired by @marcandre's comment at #1239 (comment) I see absolutely no reason to prefer `be_nil` to `be nil`. The latter is stricter, simpler and requires less knowledge of rspec.
Make `RSpec/BeNil` cop configurable with a `be_nil` and a `be` style. Inspired by @marcandre's comment at #1239 (comment) I see absolutely no reason to prefer `be_nil` to `be nil`. The latter is stricter, simpler and requires less knowledge of rspec.
Make `RSpec/BeNil` cop configurable with a `be_nil` and a `be` style. Inspired by @marcandre's comment at #1239 (comment) I see absolutely no reason to prefer `be_nil` to `be nil`. The latter is stricter, simpler and requires less knowledge of rspec.
Make `RSpec/BeNil` cop configurable with a `be_nil` and a `be` style. Inspired by @marcandre's comment at #1239 (comment) I see absolutely no reason to prefer `be_nil` to `be nil`. The latter is stricter, simpler and requires less knowledge of rspec.
Make `RSpec/BeNil` cop configurable with a `be_nil` and a `be` style. Inspired by @marcandre's comment at #1239 (comment) I see absolutely no reason to prefer `be_nil` to `be nil`. The latter is stricter, simpler and requires less knowledge of rspec.
Make `RSpec/BeNil` cop configurable with a `be_nil` and a `be` style. Inspired by @marcandre's comment at #1239 (comment) I see absolutely no reason to prefer `be_nil` to `be nil`. The latter is stricter, simpler and requires less knowledge of rspec.
Make `RSpec/BeNil` cop configurable with a `be_nil` and a `be` style. Inspired by @marcandre's comment at #1239 (comment) I see absolutely no reason to prefer `be_nil` to `be nil`. The latter is stricter, simpler and requires less knowledge of rspec.
Make `RSpec/BeNil` cop configurable with a `be_nil` and a `be` style. Inspired by @marcandre's comment at #1239 (comment) I see absolutely no reason to prefer `be_nil` to `be nil`. The latter is stricter, simpler and requires less knowledge of rspec.
Make `RSpec/BeNil` cop configurable with a `be_nil` and a `be` style. Inspired by @marcandre's comment at rubocop/rubocop-rspec#1239 (comment) I see absolutely no reason to prefer `be_nil` to `be nil`. The latter is stricter, simpler and requires less knowledge of rspec.
Make `RSpec/BeNil` cop configurable with a `be_nil` and a `be` style. Inspired by @marcandre's comment at rubocop/rubocop-rspec#1239 (comment) I see absolutely no reason to prefer `be_nil` to `be nil`. The latter is stricter, simpler and requires less knowledge of rspec.
Make `RSpec/BeNil` cop configurable with a `be_nil` and a `be` style. Inspired by @marcandre's comment at rubocop/rubocop-rspec#1239 (comment) I see absolutely no reason to prefer `be_nil` to `be nil`. The latter is stricter, simpler and requires less knowledge of rspec.
Make `RSpec/BeNil` cop configurable with a `be_nil` and a `be` style. Inspired by @marcandre's comment at rubocop/rubocop-rspec#1239 (comment) I see absolutely no reason to prefer `be_nil` to `be nil`. The latter is stricter, simpler and requires less knowledge of rspec.
Check that
be_nil
is used instead ofbe(nil)
.RSpec has a built-in
be_nil
matcher specifically for expectingnil
. For consistent specs, we recommend using that instead ofbe(nil)
.Partially fixes #244.
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).CHANGELOG.md
if the new code introduces user-observable changes.bundle exec rake
) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).If you have created a new cop:
config/default.yml
.Enabled: pending
inconfig/default.yml
.VersionAdded
indefault/config.yml
to the next minor version.If you have modified an existing cop's configuration options:
VersionChanged
inconfig/default.yml
to the next major version.