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

Require RuboCop 0.90 or higher due to use RESTRICT_ON_SEND #125

Merged
merged 1 commit into from Mar 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -13,6 +13,7 @@
### Changes

* [#118](https://github.com/rubocop/rubocop-minitest/pull/118): **(BREAKING)** Fix `Minitest/AssertEmptyLiteral` by making it check for `assert_equal([], array)` instead of `assert([], array)`. ([@cstyles][])
* [#125](https://github.com/rubocop/rubocop-minitest/pull/125): Require RuboCop 0.90 or higher. ([@koic][])

## 0.10.3 (2021-01-12)

Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/minitest/assert_empty_literal.rb
Expand Up @@ -19,6 +19,7 @@ class AssertEmptyLiteral < Cop

MSG = 'Prefer using `assert_empty(%<arguments>s)` over ' \
'`assert_equal(%<literal>s, %<arguments>s)`.'
RESTRICT_ON_SEND = %i[assert_equal].freeze

def_node_matcher :assert_equal_with_empty_literal, <<~PATTERN
(send nil? :assert_equal ${hash array} $...)
Expand Down
2 changes: 2 additions & 0 deletions lib/rubocop/cop/minitest/assert_in_delta.rb
Expand Up @@ -18,6 +18,8 @@ module Minitest
class AssertInDelta < Cop
include InDeltaMixin

RESTRICT_ON_SEND = %i[assert_equal].freeze

def_node_matcher :equal_floats_call, <<~PATTERN
(send nil? :assert_equal $_ $_ $...)
PATTERN
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/minitest/assert_nil.rb
Expand Up @@ -20,6 +20,7 @@ class AssertNil < Cop

MSG = 'Prefer using `assert_nil(%<arguments>s)` over ' \
'`assert_equal(nil, %<arguments>s)`.'
RESTRICT_ON_SEND = %i[assert_equal].freeze

def_node_matcher :assert_equal_with_nil, <<~PATTERN
(send nil? :assert_equal nil $_ $...)
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/minitest/assert_path_exists.rb
Expand Up @@ -17,6 +17,7 @@ module Minitest
#
class AssertPathExists < Cop
MSG = 'Prefer using `%<good_method>s` over `%<bad_method>s`.'
RESTRICT_ON_SEND = %i[assert].freeze

def_node_matcher :assert_file_exists, <<~PATTERN
(send nil? :assert
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/minitest/assert_truthy.rb
Expand Up @@ -20,6 +20,7 @@ class AssertTruthy < Cop

MSG = 'Prefer using `assert(%<arguments>s)` over ' \
'`assert_equal(true, %<arguments>s)`.'
RESTRICT_ON_SEND = %i[assert_equal].freeze

def_node_matcher :assert_equal_with_truthy, <<~PATTERN
(send nil? :assert_equal true $_ $...)
Expand Down
2 changes: 2 additions & 0 deletions lib/rubocop/cop/minitest/global_expectations.rb
Expand Up @@ -30,6 +30,8 @@ class GlobalExpectations < Cop

BLOCK_MATCHERS = %i[must_output must_raise must_be_silent must_throw].freeze

RESTRICT_ON_SEND = VALUE_MATCHERS + BLOCK_MATCHERS

VALUE_MATCHERS_STR = VALUE_MATCHERS.map do |m|
":#{m}"
end.join(' ').freeze
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/minitest/literal_as_actual_argument.rb
Expand Up @@ -21,6 +21,7 @@ class LiteralAsActualArgument < Cop
include ArgumentRangeHelper

MSG = 'Replace the literal with the first argument.'
RESTRICT_ON_SEND = %i[assert_equal].freeze

def on_send(node)
return unless node.method?(:assert_equal)
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/minitest/refute_equal.rb
Expand Up @@ -19,6 +19,7 @@ class RefuteEqual < Cop

MSG = 'Prefer using `refute_equal(%<preferred>s)` over ' \
'`assert(%<over>s)`.'
RESTRICT_ON_SEND = %i[assert].freeze

def_node_matcher :assert_not_equal, <<~PATTERN
(send nil? :assert ${(send $_ :!= $_) (send (send $_ :! ) :== $_) } $... )
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/minitest/refute_false.rb
Expand Up @@ -25,6 +25,7 @@ class RefuteFalse < Cop
'`assert_equal(false, %<arguments>s)`.'
MSG_FOR_ASSERT = 'Prefer using `refute(%<arguments>s)` over ' \
'`assert(!%<arguments>s)`.'
RESTRICT_ON_SEND = %i[assert_equal assert].freeze

def_node_matcher :assert_equal_with_false, <<~PATTERN
(send nil? :assert_equal false $_ $...)
Expand Down
2 changes: 2 additions & 0 deletions lib/rubocop/cop/minitest/refute_in_delta.rb
Expand Up @@ -18,6 +18,8 @@ module Minitest
class RefuteInDelta < Cop
include InDeltaMixin

RESTRICT_ON_SEND = %i[refute_equal].freeze

def_node_matcher :equal_floats_call, <<~PATTERN
(send nil? :refute_equal $_ $_ $...)
PATTERN
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/minitest/refute_nil.rb
Expand Up @@ -20,6 +20,7 @@ class RefuteNil < Cop

MSG = 'Prefer using `refute_nil(%<arguments>s)` over ' \
'`refute_equal(nil, %<arguments>s)`.'
RESTRICT_ON_SEND = %i[refute_equal].freeze

def_node_matcher :refute_equal_with_nil, <<~PATTERN
(send nil? :refute_equal nil $_ $...)
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/minitest/refute_path_exists.rb
Expand Up @@ -17,6 +17,7 @@ module Minitest
#
class RefutePathExists < Cop
MSG = 'Prefer using `%<good_method>s` over `%<bad_method>s`.'
RESTRICT_ON_SEND = %i[refute].freeze

def_node_matcher :refute_file_exists, <<~PATTERN
(send nil? :refute
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/mixin/minitest_cop_rule.rb
Expand Up @@ -29,6 +29,7 @@ def define_rule(assertion_method, target_method:, preferred_method: nil, inverse

MSG = 'Prefer using `#{preferred_method}(%<new_arguments>s)` over ' \
'`#{assertion_method}(%<original_arguments>s)`.'
RESTRICT_ON_SEND = %i[#{assertion_method}].freeze

def on_send(node)
return unless node.method?(:#{assertion_method})
Expand Down
2 changes: 1 addition & 1 deletion rubocop-minitest.gemspec
Expand Up @@ -34,6 +34,6 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_runtime_dependency 'rubocop', '>= 0.87', '< 2.0'
spec.add_runtime_dependency 'rubocop', '>= 0.90', '< 2.0'
spec.add_development_dependency 'minitest', '~> 5.11'
end