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

Add cop to enfore refute_empty over refute(actual.empty?) #20

Merged
merged 1 commit into from
Oct 7, 2019

Conversation

abhaynikam
Copy link
Contributor

PR adds cops to enforce the use of refute_empty over refute(actual.empty?)

Ref: https://github.com/rubocop-hq/minitest-style-guide#refute-empty

RUBY
end

def test_registers_offense_when_using_refute_with_empty_and_variable_message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't tests with variable/constant message redundant? The way I see it you only check for the argument count in the cop itself, so this is bound to work whatever you pass to it.

module RuboCop
module Cop
module Minitest
# Check if your test uses `refute_empty` instead of `refute(actual.empty?)`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant to write this the other way around.

@abhaynikam
Copy link
Contributor Author

@bbatsov : Resolved the comments on this PR too. Please have a look.

module Cop
module Minitest
# This cop enforces to use `refute_empty` instead of
# using `refute(actual.empty?)`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actual -> object

RUBY
end

def test_registers_offense_when_using_refute_with_empty_and_string_message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess "string message" can be shortened to just "message".

@abhaynikam
Copy link
Contributor Author

@bbatsov : Rebased and resolved the comments. Please have a look. Thanks

@bbatsov bbatsov merged commit 9579de7 into rubocop:master Oct 7, 2019
@bbatsov
Copy link
Contributor

bbatsov commented Oct 7, 2019

Looks good. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants