rubocop-minitest 0.34.4 → 0.35.0

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: 1e4b8d1f63d66f8d5c75e7df19dba8c07f62d7da0ac637a9b92014d865fe0314
4
- data.tar.gz: 1bf5ef6960646dd7b2e84b947bde08fe5b6fabbdd40a4c78c41cc59112a9181b
3
+ metadata.gz: b38207770e46d47923f0558a40d051717d6909d540875bdb72cd63594e7b172b
4
+ data.tar.gz: b0b493b7e7ae9bf171379bf8a9c5ac6b02d44e2edbe29246928a71d9e5c6e81f
5
5
  SHA512:
6
- metadata.gz: a5bf6ff7d580d5223a90735e7f4f81a528ef14ce943689b24fad9561070bb02f2bbd569bd4dd5c79466781b1e5292e5008be428b1b5694b6c501c91d567fc933
7
- data.tar.gz: 37f1a56983839444e99921b3f8c664e4b7d3388e6dff081e17b899a3281e44ec45fe9bca3fcd06aef6791d955a88053010efddaa5ffd9d30e2b875a54aff3118
6
+ metadata.gz: df6202e016d32b4ffc3fe066ca3785ecf8bc30dd2e0b76f858be48fe9399439b779762eed9f49d812ffeb47c4389926611f58ae06027832b331e89b7390407db
7
+ data.tar.gz: 6b2d444f5b2bd62fb31fe5e6808628eb03b5f3843f69b3e91d677abf57351d12140ba52ba06f6dab49bbffaf12ac5255df4553efa258a069d1cf5bb39a16f719
data/config/default.yml CHANGED
@@ -46,6 +46,7 @@ Minitest/AssertKindOf:
46
46
  StyleGuide: 'https://github.com/rubocop/minitest-style-guide#assert-kind-of'
47
47
  Enabled: 'pending'
48
48
  VersionAdded: '0.10'
49
+ VersionChanged: '0.34'
49
50
 
50
51
  Minitest/AssertMatch:
51
52
  Description: 'This cop enforces the test to use `assert_match` instead of using `assert(matcher.match(object))`.'
@@ -145,6 +146,12 @@ Minitest/EmptyLineBeforeAssertionMethods:
145
146
  Enabled: pending
146
147
  VersionAdded: '0.23'
147
148
 
149
+ Minitest/Focus:
150
+ Description: 'Checks for focused tests.'
151
+ Enabled: pending
152
+ AutoCorrect: contextual
153
+ VersionAdded: '0.35'
154
+
148
155
  Minitest/GlobalExpectations:
149
156
  Description: 'This cop checks for deprecated global expectations.'
150
157
  StyleGuide: 'https://minitest.rubystyle.guide#global-expectations'
@@ -252,6 +259,7 @@ Minitest/RefuteKindOf:
252
259
  StyleGuide: 'https://github.com/rubocop/minitest-style-guide#refute-kind-of'
253
260
  Enabled: 'pending'
254
261
  VersionAdded: '0.10'
262
+ VersionChanged: '0.34'
255
263
 
256
264
  Minitest/RefuteMatch:
257
265
  Description: 'This cop enforces the test to use `refute_match` instead of using `refute(matcher.match(object))`.'
@@ -22,7 +22,7 @@ module RuboCop
22
22
  RESTRICT_ON_SEND = %i[assert_equal].freeze
23
23
 
24
24
  def_node_matcher :assert_equal_with_empty_literal, <<~PATTERN
25
- (send nil? :assert_equal ${hash array} $...)
25
+ (send nil? :assert_equal ${hash array} $_+)
26
26
  PATTERN
27
27
 
28
28
  def on_send(node)
@@ -11,6 +11,11 @@ module RuboCop
11
11
  # assert(object.kind_of?(Class))
12
12
  # assert(object.kind_of?(Class), 'message')
13
13
  #
14
+ # # bad
15
+ # # `is_a?` is an alias for `kind_of?`
16
+ # assert(object.is_a?(Class))
17
+ # assert(object.is_a?(Class), 'message')
18
+ #
14
19
  # # good
15
20
  # assert_kind_of(Class, object)
16
21
  # assert_kind_of(Class, object, 'message')
@@ -18,7 +23,7 @@ module RuboCop
18
23
  class AssertKindOf < Base
19
24
  extend MinitestCopRule
20
25
 
21
- define_rule :assert, target_method: :kind_of?, inverse: true
26
+ define_rule :assert, target_method: %i[kind_of? is_a?], preferred_method: :assert_kind_of, inverse: true
22
27
  end
23
28
  end
24
29
  end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Minitest
6
+ # Enforces tests are not focused.
7
+ #
8
+ # @example
9
+ # # bad
10
+ # focus test 'foo' do
11
+ # end
12
+ #
13
+ # # bad
14
+ # focus
15
+ # test 'foo' do
16
+ # end
17
+ #
18
+ # # good
19
+ # test 'foo' do
20
+ # end
21
+ #
22
+ class Focus < Base
23
+ extend AutoCorrector
24
+ include RangeHelp
25
+
26
+ MSG = 'Remove `focus` from tests.'
27
+ RESTRICT_ON_SEND = [:focus].freeze
28
+
29
+ def_node_matcher :focused?, <<~PATTERN
30
+ (send nil? :focus ...)
31
+ PATTERN
32
+
33
+ def on_send(node)
34
+ return if node.receiver
35
+
36
+ add_offense(node.loc.selector) do |corrector|
37
+ range = if node.arguments.none?
38
+ range_by_whole_lines(node.source_range, include_final_newline: true)
39
+ else
40
+ node.loc.selector.join(node.first_argument.source_range.begin)
41
+ end
42
+
43
+ corrector.remove(range)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -11,6 +11,11 @@ module RuboCop
11
11
  # refute(object.kind_of?(Class))
12
12
  # refute(object.kind_of?(Class), 'message')
13
13
  #
14
+ # # bad
15
+ # # `is_a?` is an alias for `kind_of?`
16
+ # refute(object.is_of?(Class))
17
+ # refute(object.is_of?(Class), 'message')
18
+ #
14
19
  # # good
15
20
  # refute_kind_of(Class, object)
16
21
  # refute_kind_of(Class, object, 'message')
@@ -18,7 +23,7 @@ module RuboCop
18
23
  class RefuteKindOf < Base
19
24
  extend MinitestCopRule
20
25
 
21
- define_rule :refute, target_method: :kind_of?, inverse: true
26
+ define_rule :refute, target_method: %i[kind_of? is_a?], preferred_method: :refute_kind_of, inverse: true
22
27
  end
23
28
  end
24
29
  end
@@ -48,7 +48,7 @@ module RuboCop
48
48
  when *SINGLE_ASSERTION_ARGUMENT_METHODS
49
49
  actual.nil? && expected&.literal? && !expected.xstr_type?
50
50
  when *TWO_ASSERTION_ARGUMENTS_METHODS
51
- return false unless expected || actual
51
+ return false unless expected && actual
52
52
  return false if expected.source != actual.source
53
53
 
54
54
  (expected.variable? && actual.variable?) ||
@@ -30,6 +30,7 @@ require_relative 'minitest/assert_silent'
30
30
  require_relative 'minitest/assert_truthy'
31
31
  require_relative 'minitest/duplicate_test_run'
32
32
  require_relative 'minitest/empty_line_before_assertion_methods'
33
+ require_relative 'minitest/focus'
33
34
  require_relative 'minitest/non_executable_test_method'
34
35
  require_relative 'minitest/redundant_message_argument'
35
36
  require_relative 'minitest/return_in_test_method'
@@ -186,15 +186,9 @@ module RuboCop
186
186
  file = file.path
187
187
  end
188
188
 
189
- processed_source = RuboCop::ProcessedSource.new(source, ruby_version, file)
190
-
191
- # Follow up https://github.com/rubocop/rubocop/pull/10987.
192
- # When support for RuboCop 1.37.1 ends, this condition can be removed.
193
- if processed_source.respond_to?(:config) && processed_source.respond_to?(:registry)
194
- processed_source.config = configuration
195
- processed_source.registry = registry
196
- end
197
-
189
+ processed_source = RuboCop::ProcessedSource.new(source, ruby_version, file, parser_engine: parser_engine)
190
+ processed_source.config = configuration
191
+ processed_source.registry = registry
198
192
  processed_source
199
193
  end
200
194
 
@@ -216,7 +210,12 @@ module RuboCop
216
210
  end
217
211
 
218
212
  def ruby_version
219
- RuboCop::TargetRuby::DEFAULT_VERSION
213
+ # Prism supports parsing Ruby 3.3+.
214
+ ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : RuboCop::TargetRuby::DEFAULT_VERSION
215
+ end
216
+
217
+ def parser_engine
218
+ ENV.fetch('PARSER_ENGINE', :parser_whitequark).to_sym
220
219
  end
221
220
  end
222
221
  # rubocop:enable Metrics/ModuleLength
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Minitest
5
5
  # This module holds the RuboCop Minitest version information.
6
6
  module Version
7
- STRING = '0.34.4'
7
+ STRING = '0.35.0'
8
8
 
9
9
  def self.document_version
10
10
  STRING.match('\d+\.\d+').to_s
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.34.4
4
+ version: 0.35.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: 2024-01-09 00:00:00.000000000 Z
13
+ date: 2024-03-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '1.39'
21
+ version: '1.61'
22
22
  - - "<"
23
23
  - !ruby/object:Gem::Version
24
24
  version: '2.0'
@@ -28,7 +28,7 @@ dependencies:
28
28
  requirements:
29
29
  - - ">="
30
30
  - !ruby/object:Gem::Version
31
- version: '1.39'
31
+ version: '1.61'
32
32
  - - "<"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '2.0'
@@ -38,7 +38,7 @@ dependencies:
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 1.30.0
41
+ version: 1.31.1
42
42
  - - "<"
43
43
  - !ruby/object:Gem::Version
44
44
  version: '2.0'
@@ -48,7 +48,7 @@ dependencies:
48
48
  requirements:
49
49
  - - ">="
50
50
  - !ruby/object:Gem::Version
51
- version: 1.30.0
51
+ version: 1.31.1
52
52
  - - "<"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
@@ -88,6 +88,7 @@ files:
88
88
  - lib/rubocop/cop/minitest/assertion_in_lifecycle_hook.rb
89
89
  - lib/rubocop/cop/minitest/duplicate_test_run.rb
90
90
  - lib/rubocop/cop/minitest/empty_line_before_assertion_methods.rb
91
+ - lib/rubocop/cop/minitest/focus.rb
91
92
  - lib/rubocop/cop/minitest/global_expectations.rb
92
93
  - lib/rubocop/cop/minitest/lifecycle_hooks_order.rb
93
94
  - lib/rubocop/cop/minitest/literal_as_actual_argument.rb
@@ -139,7 +140,7 @@ metadata:
139
140
  homepage_uri: https://docs.rubocop.org/rubocop-minitest/
140
141
  changelog_uri: https://github.com/rubocop/rubocop-minitest/blob/master/CHANGELOG.md
141
142
  source_code_uri: https://github.com/rubocop/rubocop-minitest
142
- documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.34
143
+ documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.35
143
144
  bug_tracker_uri: https://github.com/rubocop/rubocop-minitest/issues
144
145
  rubygems_mfa_required: 'true'
145
146
  post_install_message: