rubocop-minitest 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitattributes +1 -0
- data/.rubocop_todo.yml +1 -1
- data/CHANGELOG.md +13 -0
- data/README.md +4 -0
- data/config/default.yml +7 -2
- data/lib/rubocop/cop/minitest/assert_empty.rb +4 -30
- data/lib/rubocop/cop/minitest/assert_includes.rb +4 -4
- data/lib/rubocop/cop/minitest/assert_instance_of.rb +4 -38
- data/lib/rubocop/cop/minitest/assert_match.rb +4 -39
- data/lib/rubocop/cop/minitest/assert_nil.rb +2 -2
- data/lib/rubocop/cop/minitest/assert_respond_to.rb +10 -45
- data/lib/rubocop/cop/minitest/assert_truthy.rb +2 -2
- data/lib/rubocop/cop/minitest/global_expectations.rb +74 -0
- data/lib/rubocop/cop/minitest/refute_empty.rb +4 -30
- data/lib/rubocop/cop/minitest/refute_false.rb +3 -3
- data/lib/rubocop/cop/minitest/refute_includes.rb +4 -4
- data/lib/rubocop/cop/minitest/refute_instance_of.rb +4 -38
- data/lib/rubocop/cop/minitest/refute_match.rb +4 -39
- data/lib/rubocop/cop/minitest/refute_nil.rb +2 -2
- data/lib/rubocop/cop/minitest/refute_respond_to.rb +10 -45
- data/lib/rubocop/cop/minitest_cops.rb +2 -1
- data/lib/rubocop/cop/mixin/minitest_cop_rule.rb +104 -0
- data/lib/rubocop/minitest/version.rb +1 -1
- data/manual/cops.md +1 -0
- data/manual/cops_minitest.md +62 -41
- data/relnotes/v0.6.2.md +5 -0
- data/relnotes/v0.7.0.md +13 -0
- metadata +8 -5
- data/lib/rubocop/cop/mixin/includes_cop_rule.rb +0 -78
data/relnotes/v0.6.2.md
ADDED
data/relnotes/v0.7.0.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
### New features
|
2
|
+
|
3
|
+
* [#60](https://github.com/rubocop-hq/rubocop-minitest/issues/60): Add new cop `Minitest/GlobalExpectations` to check for deprecated global expectations. ([@tejasbubane][])
|
4
|
+
|
5
|
+
### Bug fixes
|
6
|
+
|
7
|
+
* [#58](https://github.com/rubocop-hq/rubocop-minitest/pull/58): Fix a false negative for `Minitest/AssertMatch` and `Minitest/RefuteMatch` when an argument is enclosed in redundant parentheses. ([@koic][])
|
8
|
+
* [#59](https://github.com/rubocop-hq/rubocop-minitest/pull/59): Fix a false negative for `Minitest/AssertRespondTo` and `Minitest/RefuteRespondTo` when an argument is enclosed in redundant parentheses. ([@koic][])
|
9
|
+
* [#61](https://github.com/rubocop-hq/rubocop-minitest/pull/61): Fix a false negative for `Minitest/AssertInstanceOf` and `Minitest/RefuteInstanceOf` when an argument is enclosed in redundant parentheses. ([@koic][])
|
10
|
+
* [#62](https://github.com/rubocop-hq/rubocop-minitest/pull/62): Fix a false negative for `Minitest/AssertEmpty` and `Minitest/RefuteEmpty` when an argument is enclosed in redundant parentheses. ([@koic][])
|
11
|
+
|
12
|
+
[@tejasbubane]: https://github.com/tejasbubane
|
13
|
+
[@koic]: https://github.com/koic
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-03-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -49,6 +49,7 @@ extensions: []
|
|
49
49
|
extra_rdoc_files: []
|
50
50
|
files:
|
51
51
|
- ".circleci/config.yml"
|
52
|
+
- ".gitattributes"
|
52
53
|
- ".github/FUNDING.yml"
|
53
54
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
54
55
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
@@ -75,6 +76,7 @@ files:
|
|
75
76
|
- lib/rubocop/cop/minitest/assert_nil.rb
|
76
77
|
- lib/rubocop/cop/minitest/assert_respond_to.rb
|
77
78
|
- lib/rubocop/cop/minitest/assert_truthy.rb
|
79
|
+
- lib/rubocop/cop/minitest/global_expectations.rb
|
78
80
|
- lib/rubocop/cop/minitest/refute_empty.rb
|
79
81
|
- lib/rubocop/cop/minitest/refute_equal.rb
|
80
82
|
- lib/rubocop/cop/minitest/refute_false.rb
|
@@ -85,7 +87,7 @@ files:
|
|
85
87
|
- lib/rubocop/cop/minitest/refute_respond_to.rb
|
86
88
|
- lib/rubocop/cop/minitest_cops.rb
|
87
89
|
- lib/rubocop/cop/mixin/argument_range_helper.rb
|
88
|
-
- lib/rubocop/cop/mixin/
|
90
|
+
- lib/rubocop/cop/mixin/minitest_cop_rule.rb
|
89
91
|
- lib/rubocop/minitest.rb
|
90
92
|
- lib/rubocop/minitest/inject.rb
|
91
93
|
- lib/rubocop/minitest/version.rb
|
@@ -106,6 +108,8 @@ files:
|
|
106
108
|
- relnotes/v0.5.1.md
|
107
109
|
- relnotes/v0.6.0.md
|
108
110
|
- relnotes/v0.6.1.md
|
111
|
+
- relnotes/v0.6.2.md
|
112
|
+
- relnotes/v0.7.0.md
|
109
113
|
- rubocop-minitest.gemspec
|
110
114
|
- tasks/cops_documentation.rake
|
111
115
|
- tasks/cut_release.rake
|
@@ -133,8 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
137
|
- !ruby/object:Gem::Version
|
134
138
|
version: '0'
|
135
139
|
requirements: []
|
136
|
-
|
137
|
-
rubygems_version: 2.5.2.3
|
140
|
+
rubygems_version: 3.1.2
|
138
141
|
signing_key:
|
139
142
|
specification_version: 4
|
140
143
|
summary: Automatic Minitest code style checking tool.
|
@@ -1,78 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
# Define the rule for `Minitest/AssertIncludes` and `Minitest/RefuteIncludes` cops.
|
6
|
-
module IncludesCopRule
|
7
|
-
def rule(target_method:, prefer_method:)
|
8
|
-
class_eval(<<~RUBY, __FILE__, __LINE__ + 1)
|
9
|
-
include ArgumentRangeHelper
|
10
|
-
|
11
|
-
MSG = 'Prefer using `#{prefer_method}(%<new_arguments>s)` over ' \
|
12
|
-
'`#{target_method}(%<original_arguments>s)`.'
|
13
|
-
|
14
|
-
def on_send(node)
|
15
|
-
return unless node.method?(:#{target_method})
|
16
|
-
return unless (arguments = peel_redundant_parentheses_from(node.arguments))
|
17
|
-
return unless arguments.first.respond_to?(:method?) && arguments.first.method?(:include?)
|
18
|
-
|
19
|
-
add_offense(node, message: offense_message(arguments))
|
20
|
-
end
|
21
|
-
|
22
|
-
def autocorrect(node)
|
23
|
-
lambda do |corrector|
|
24
|
-
corrector.replace(node.loc.selector, '#{prefer_method}')
|
25
|
-
|
26
|
-
arguments = peel_redundant_parentheses_from(node.arguments)
|
27
|
-
|
28
|
-
new_arguments = [
|
29
|
-
arguments.first.receiver.source,
|
30
|
-
arguments.first.arguments.map(&:source)
|
31
|
-
].join(', ')
|
32
|
-
|
33
|
-
if enclosed_in_redundant_parentheses?(node)
|
34
|
-
new_arguments = '(' + new_arguments + ')'
|
35
|
-
end
|
36
|
-
|
37
|
-
corrector.replace(first_argument_range(node), new_arguments)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def peel_redundant_parentheses_from(arguments)
|
44
|
-
return arguments unless arguments.first.begin_type?
|
45
|
-
|
46
|
-
peel_redundant_parentheses_from(arguments.first.children)
|
47
|
-
end
|
48
|
-
|
49
|
-
def offense_message(arguments)
|
50
|
-
new_arguments = new_arguments(arguments)
|
51
|
-
|
52
|
-
original_arguments = arguments.map(&:source).join(', ')
|
53
|
-
|
54
|
-
format(
|
55
|
-
MSG,
|
56
|
-
new_arguments: new_arguments,
|
57
|
-
original_arguments: original_arguments
|
58
|
-
)
|
59
|
-
end
|
60
|
-
|
61
|
-
def new_arguments(arguments)
|
62
|
-
message_argument = arguments.last if arguments.first != arguments.last
|
63
|
-
|
64
|
-
[
|
65
|
-
arguments.first.receiver,
|
66
|
-
arguments.first.arguments.first,
|
67
|
-
message_argument
|
68
|
-
].compact.map(&:source).join(', ')
|
69
|
-
end
|
70
|
-
|
71
|
-
def enclosed_in_redundant_parentheses?(node)
|
72
|
-
node.arguments.first.begin_type?
|
73
|
-
end
|
74
|
-
RUBY
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|