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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e766db856d11b13a5c3fbbf11a17a0e0fdbdda162195f11fbbc898c08670102
4
- data.tar.gz: 5c223aa1303c61e17766a3c1be7e2641da280446450cbe8d93786b4542c624aa
3
+ metadata.gz: 7583581a57a2d02e2794742beda02c84256b1b61e1139095e28d7f95832afa26
4
+ data.tar.gz: 724e5254b30b3862ecf1101ca7d33dacb67880abd4d1d84f6dff9b4ab21d433c
5
5
  SHA512:
6
- metadata.gz: d7e1ef3c91cc1b9b55a6c26c9737fe6207cada7f48a3f78c40288650fa17b3efaeb4e740ab60ff12a532a4506f78e5c7fa823a840f6618791d0454f7071ddd29
7
- data.tar.gz: c6eb92763493631a30e3bbf35efd62d3141a9ad0fa8365975cb96825f31454c0892ca249df6421b724e589b95c9098302c56572d55514f6b77b1b58d6feb3838
6
+ metadata.gz: 3095ba19f3e22c2d8219d1ef6fc87de197d9c27f74e2d62e4ee2336c3bbe47642606a5c406fa4f8f14134fe160cbde7b31e975f982cbddf1dd02c6706c409adc
7
+ data.tar.gz: f1d4837b08291f388ea6ec949949d186f59da810ebb05014c6c6375977fe2bcaa545759cd04a1d19d4e48446a5261a31ddd7a8f3ab41fea9fd3586c3cdb8810e
data/.rubocop.yml CHANGED
@@ -47,6 +47,9 @@ Layout/ClassStructure:
47
47
  - protected_methods
48
48
  - private_methods
49
49
 
50
+ Layout/LineLength:
51
+ Max: 120
52
+
50
53
  # Trailing white space is meaningful in code examples
51
54
  Layout/TrailingWhitespace:
52
55
  AllowInHeredoc: true
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
- MATCHERS_STR = (VALUE_MATCHERS + BLOCK_MATCHERS).map do |m|
33
+ VALUE_MATCHERS_STR = VALUE_MATCHERS.map do |m|
34
34
  ":#{m}"
35
35
  end.join(' ').freeze
36
36
 
37
- def_node_matcher :global_expectation?, <<~PATTERN
38
- (send {
39
- (send _ _)
40
- ({lvar ivar cvar gvar} _)
41
- (send {(send _ _) ({lvar ivar cvar gvar} _)} _ _)
42
- } {#{MATCHERS_STR}} ...)
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 global_expectation?(node)
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 global_expectation?(node)
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Minitest
5
- VERSION = '0.8.0'
5
+ VERSION = '0.8.1'
6
6
  end
7
7
  end
@@ -0,0 +1,5 @@
1
+ ### Bug fixes
2
+
3
+ * [#72](https://github.com/rubocop-hq/rubocop-minitest/pull/72): Fix some false negatives for `Minitest/GlobalExpectations`. ([@andrykonchin][])
4
+
5
+ [@andrykonchin]: https://github.com/andrykonchin
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.0
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-03-23 00:00:00.000000000 Z
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