rubocop-minitest 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +0 -7
- data/CHANGELOG.md +7 -0
- data/lib/rubocop/cop/minitest/global_expectations.rb +25 -9
- data/lib/rubocop/cop/mixin/minitest_cop_rule.rb +1 -3
- data/lib/rubocop/minitest/version.rb +1 -1
- data/relnotes/v0.8.1.md +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7583581a57a2d02e2794742beda02c84256b1b61e1139095e28d7f95832afa26
|
4
|
+
data.tar.gz: 724e5254b30b3862ecf1101ca7d33dacb67880abd4d1d84f6dff9b4ab21d433c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3095ba19f3e22c2d8219d1ef6fc87de197d9c27f74e2d62e4ee2336c3bbe47642606a5c406fa4f8f14134fe160cbde7b31e975f982cbddf1dd02c6706c409adc
|
7
|
+
data.tar.gz: f1d4837b08291f388ea6ec949949d186f59da810ebb05014c6c6375977fe2bcaa545759cd04a1d19d4e48446a5261a31ddd7a8f3ab41fea9fd3586c3cdb8810e
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -14,10 +14,3 @@ Metrics/AbcSize:
|
|
14
14
|
# Configuration parameters: CountComments, ExcludedMethods.
|
15
15
|
Metrics/MethodLength:
|
16
16
|
Max: 14
|
17
|
-
|
18
|
-
# Offense count: 40
|
19
|
-
# Cop supports --auto-correct.
|
20
|
-
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
21
|
-
# URISchemes: http, https
|
22
|
-
Layout/LineLength:
|
23
|
-
Max: 100
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 0.8.1 (2020-04-06)
|
6
|
+
|
7
|
+
### Bug fixes
|
8
|
+
|
9
|
+
* [#72](https://github.com/rubocop-hq/rubocop-minitest/pull/72): Fix some false negatives for `Minitest/GlobalExpectations`. ([@andrykonchin][])
|
10
|
+
|
5
11
|
## 0.8.0 (2020-03-24)
|
6
12
|
|
7
13
|
### New features
|
@@ -119,3 +125,4 @@
|
|
119
125
|
[@abhaynikam]: https://github.com/abhaynikam
|
120
126
|
[@herwinw]: https://github.com/herwinw
|
121
127
|
[@fsateler]: https://github.com/fsateler
|
128
|
+
[@andrykonchin]: https://github.com/andrykonchin
|
@@ -30,27 +30,43 @@ module RuboCop
|
|
30
30
|
|
31
31
|
BLOCK_MATCHERS = %i[must_output must_raise must_be_silent must_throw].freeze
|
32
32
|
|
33
|
-
|
33
|
+
VALUE_MATCHERS_STR = VALUE_MATCHERS.map do |m|
|
34
34
|
":#{m}"
|
35
35
|
end.join(' ').freeze
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
BLOCK_MATCHERS_STR = BLOCK_MATCHERS.map do |m|
|
38
|
+
":#{m}"
|
39
|
+
end.join(' ').freeze
|
40
|
+
|
41
|
+
# There are aliases for the `_` method - `expect` and `value`
|
42
|
+
DSL_METHODS_LIST = %w[_ value expect].map do |n|
|
43
|
+
":#{n}"
|
44
|
+
end.join(' ').freeze
|
45
|
+
|
46
|
+
def_node_matcher :value_global_expectation?, <<~PATTERN
|
47
|
+
(send !(send nil? {#{DSL_METHODS_LIST}} _) {#{VALUE_MATCHERS_STR}} _)
|
48
|
+
PATTERN
|
49
|
+
|
50
|
+
def_node_matcher :block_global_expectation?, <<~PATTERN
|
51
|
+
(send
|
52
|
+
[
|
53
|
+
!(send nil? {#{DSL_METHODS_LIST}} _)
|
54
|
+
!(block (send nil? {#{DSL_METHODS_LIST}}) _ _)
|
55
|
+
]
|
56
|
+
{#{BLOCK_MATCHERS_STR}}
|
57
|
+
_
|
58
|
+
)
|
43
59
|
PATTERN
|
44
60
|
|
45
61
|
def on_send(node)
|
46
|
-
return unless
|
62
|
+
return unless value_global_expectation?(node) || block_global_expectation?(node)
|
47
63
|
|
48
64
|
message = format(MSG, preferred: preferred_receiver(node))
|
49
65
|
add_offense(node, location: node.receiver.source_range, message: message)
|
50
66
|
end
|
51
67
|
|
52
68
|
def autocorrect(node)
|
53
|
-
return unless
|
69
|
+
return unless value_global_expectation?(node) || block_global_expectation?(node)
|
54
70
|
|
55
71
|
lambda do |corrector|
|
56
72
|
receiver = node.receiver.source_range
|
@@ -22,9 +22,7 @@ module RuboCop
|
|
22
22
|
# @param inverse [Boolean] An optional param. Order of arguments replaced by auto-correction.
|
23
23
|
#
|
24
24
|
def define_rule(assertion_method, target_method:, preferred_method: nil, inverse: false)
|
25
|
-
if preferred_method.nil?
|
26
|
-
preferred_method = "#{assertion_method}_#{target_method.to_s.delete('?')}"
|
27
|
-
end
|
25
|
+
preferred_method = "#{assertion_method}_#{target_method.to_s.delete('?')}" if preferred_method.nil?
|
28
26
|
|
29
27
|
class_eval(<<~RUBY, __FILE__, __LINE__ + 1)
|
30
28
|
include ArgumentRangeHelper
|
data/relnotes/v0.8.1.md
ADDED
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.8.
|
4
|
+
version: 0.8.1
|
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-04-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- relnotes/v0.6.2.md
|
112
112
|
- relnotes/v0.7.0.md
|
113
113
|
- relnotes/v0.8.0.md
|
114
|
+
- relnotes/v0.8.1.md
|
114
115
|
- rubocop-minitest.gemspec
|
115
116
|
- tasks/cops_documentation.rake
|
116
117
|
- tasks/cut_release.rake
|