rubocop-minitest 0.36.0 → 0.37.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +7 -4
- data/lib/rubocop/cop/minitest/assert_with_expected_argument.rb +1 -1
- data/lib/rubocop/cop/minitest/return_in_test_method.rb +1 -1
- data/lib/rubocop/cop/minitest/skip_ensure.rb +3 -3
- data/lib/rubocop/cop/minitest/skip_without_reason.rb +1 -1
- data/lib/rubocop/cop/minitest/useless_assertion.rb +1 -1
- data/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb +1 -3
- data/lib/rubocop/cop/mixin/predicate_assertion_handleable.rb +1 -2
- data/lib/rubocop/minitest/assert_offense.rb +1 -0
- data/lib/rubocop/minitest/plugin.rb +31 -0
- data/lib/rubocop/minitest/support.rb +1 -2
- data/lib/rubocop/minitest/version.rb +1 -1
- data/lib/rubocop/minitest.rb +1 -6
- data/lib/rubocop-minitest.rb +1 -4
- metadata +22 -7
- data/lib/rubocop/minitest/inject.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7cd0b62383397e127644d25217d63ee7b75994c9f958b13566171dffa11187d
|
4
|
+
data.tar.gz: 324d95c21421436a3e85db8dfea22b6791fd4b6da8e21fe5bd953dca42ce7b8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 641e3d8f3fcae787fbd276ade1f1c3f9f91a112f8492a518b1f024c1a8ae8efe72433344e060cf8889092c82beb800d06d5930d7cd3cb3d0fb2f404d1e56fb85
|
7
|
+
data.tar.gz: b015edc5808d62eb24b4c3c65548bdeab59b998290fbb596fb3f6fb6cac425ae42cccdbc8d42b5cba0ee461c55a3df6be5657272ff6051a450cd4c8e5170ae0f
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2019-
|
3
|
+
Copyright (c) 2019-2025 Bozhidar Batsov, Jonas Arvidsson, Koichi ITO
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -30,13 +30,13 @@ ways to do this:
|
|
30
30
|
Put this into your `.rubocop.yml`.
|
31
31
|
|
32
32
|
```yaml
|
33
|
-
|
33
|
+
plugins: rubocop-minitest
|
34
34
|
```
|
35
35
|
|
36
36
|
Alternatively, use the following array notation when specifying multiple extensions.
|
37
37
|
|
38
38
|
```yaml
|
39
|
-
|
39
|
+
plugins:
|
40
40
|
- rubocop-other-extension
|
41
41
|
- rubocop-minitest
|
42
42
|
```
|
@@ -44,10 +44,13 @@ require:
|
|
44
44
|
Now you can run `rubocop` and it will automatically load the RuboCop Minitest
|
45
45
|
cops together with the standard cops.
|
46
46
|
|
47
|
+
> [!NOTE]
|
48
|
+
> The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.
|
49
|
+
|
47
50
|
### Command line
|
48
51
|
|
49
52
|
```sh
|
50
|
-
$ rubocop --
|
53
|
+
$ rubocop --plugin rubocop-minitest
|
51
54
|
```
|
52
55
|
|
53
56
|
### Rake task
|
@@ -56,7 +59,7 @@ $ rubocop --require rubocop-minitest
|
|
56
59
|
require 'rubocop/rake_task'
|
57
60
|
|
58
61
|
RuboCop::RakeTask.new do |task|
|
59
|
-
task.
|
62
|
+
task.plugins << 'rubocop-minitest'
|
60
63
|
end
|
61
64
|
```
|
62
65
|
|
@@ -36,7 +36,7 @@ module RuboCop
|
|
36
36
|
|
37
37
|
def on_send(node)
|
38
38
|
assert_with_two_arguments?(node) do |_expected, message|
|
39
|
-
return if message.
|
39
|
+
return if message.type?(:str, :dstr) || MESSAGE_VARIABLES.include?(message.source)
|
40
40
|
|
41
41
|
arguments = node.arguments.map(&:source).join(', ')
|
42
42
|
add_offense(node, message: format(MSG, arguments: arguments))
|
@@ -86,10 +86,10 @@ module RuboCop
|
|
86
86
|
|
87
87
|
def valid_conditional_skip?(skip_method, ensure_node)
|
88
88
|
if_node = skip_method.ancestors.detect(&:if_type?)
|
89
|
-
return false unless ensure_node.
|
89
|
+
return false unless ensure_node.branch.if_type?
|
90
90
|
|
91
|
-
match_keyword = ensure_node.
|
92
|
-
match_keyword && ensure_node.
|
91
|
+
match_keyword = ensure_node.branch.if? ? if_node.if? : if_node.unless?
|
92
|
+
match_keyword && ensure_node.branch.condition == if_node.condition
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
@@ -99,11 +99,10 @@ module RuboCop
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
103
102
|
def assertion_method?(node)
|
104
103
|
return false unless node
|
105
104
|
return assertion_method?(node.expression) if node.assignment? && node.respond_to?(:expression)
|
106
|
-
return false
|
105
|
+
return false unless node.type?(:send, :any_block)
|
107
106
|
|
108
107
|
ASSERTION_PREFIXES.any? do |prefix|
|
109
108
|
method_name = node.method_name
|
@@ -111,7 +110,6 @@ module RuboCop
|
|
111
110
|
method_name.start_with?(prefix) || node.method?(:flunk)
|
112
111
|
end
|
113
112
|
end
|
114
|
-
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
115
113
|
|
116
114
|
def lifecycle_hook_method?(node)
|
117
115
|
node.def_type? && LIFECYCLE_HOOK_METHODS.include?(node.method_name)
|
@@ -9,8 +9,7 @@ module RuboCop
|
|
9
9
|
MSG = 'Prefer using `%<assertion_type>s_predicate(%<new_arguments>s)`.'
|
10
10
|
|
11
11
|
def on_send(node)
|
12
|
-
return
|
13
|
-
return if node.first_argument.block_type? || node.first_argument.numblock_type?
|
12
|
+
return if node.first_argument&.any_block_type?
|
14
13
|
return unless predicate_method?(node.first_argument)
|
15
14
|
return unless node.first_argument.arguments.count.zero?
|
16
15
|
|
@@ -167,6 +167,7 @@ module RuboCop
|
|
167
167
|
|
168
168
|
# This is just here for a pretty diff if the source actually got changed
|
169
169
|
new_source = @last_corrector.rewrite
|
170
|
+
|
170
171
|
assert_equal(@processed_source.buffer.source, new_source)
|
171
172
|
|
172
173
|
# There is an infinite loop if a corrector is present that did not make
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lint_roller'
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Minitest
|
7
|
+
# A plugin that integrates RuboCop Minitest with RuboCop's plugin system.
|
8
|
+
class Plugin < LintRoller::Plugin
|
9
|
+
def about
|
10
|
+
LintRoller::About.new(
|
11
|
+
name: 'rubocop-minitest',
|
12
|
+
version: Version::STRING,
|
13
|
+
homepage: 'https://github.com/rubocop/rubocop-minitest',
|
14
|
+
description: 'Automatic Minitest code style checking tool.'
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def supported?(context)
|
19
|
+
context.engine == :rubocop
|
20
|
+
end
|
21
|
+
|
22
|
+
def rules(_context)
|
23
|
+
LintRoller::Rules.new(
|
24
|
+
type: :path,
|
25
|
+
config_format: :rubocop,
|
26
|
+
value: Pathname.new(__dir__).join('../../../config/default.yml')
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -3,8 +3,7 @@
|
|
3
3
|
# Require this file to load code that supports testing using Minitest.
|
4
4
|
|
5
5
|
require 'rubocop'
|
6
|
-
require 'minitest
|
7
|
-
require 'minitest/pride'
|
6
|
+
require 'minitest'
|
8
7
|
require_relative 'assert_offense'
|
9
8
|
|
10
9
|
Minitest::Test.include RuboCop::Minitest::AssertOffense
|
data/lib/rubocop/minitest.rb
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module RuboCop
|
4
|
-
# RuboCop minitest project namespace
|
4
|
+
# RuboCop minitest project namespace.
|
5
5
|
module Minitest
|
6
|
-
PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
|
7
|
-
CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
|
8
|
-
CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
|
9
|
-
|
10
|
-
private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
|
11
6
|
end
|
12
7
|
end
|
data/lib/rubocop-minitest.rb
CHANGED
@@ -4,8 +4,5 @@ require 'rubocop'
|
|
4
4
|
|
5
5
|
require_relative 'rubocop/minitest'
|
6
6
|
require_relative 'rubocop/minitest/version'
|
7
|
-
require_relative 'rubocop/minitest/
|
8
|
-
|
9
|
-
RuboCop::Minitest::Inject.defaults!
|
10
|
-
|
7
|
+
require_relative 'rubocop/minitest/plugin'
|
11
8
|
require_relative 'rubocop/cop/minitest_cops'
|
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.37.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,8 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2025-02-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: lint_roller
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.1'
|
15
29
|
- !ruby/object:Gem::Dependency
|
16
30
|
name: rubocop
|
17
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,7 +52,7 @@ dependencies:
|
|
38
52
|
requirements:
|
39
53
|
- - ">="
|
40
54
|
- !ruby/object:Gem::Version
|
41
|
-
version: 1.
|
55
|
+
version: 1.38.0
|
42
56
|
- - "<"
|
43
57
|
- !ruby/object:Gem::Version
|
44
58
|
version: '2.0'
|
@@ -48,7 +62,7 @@ dependencies:
|
|
48
62
|
requirements:
|
49
63
|
- - ">="
|
50
64
|
- !ruby/object:Gem::Version
|
51
|
-
version: 1.
|
65
|
+
version: 1.38.0
|
52
66
|
- - "<"
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '2.0'
|
@@ -130,7 +144,7 @@ files:
|
|
130
144
|
- lib/rubocop/cop/mixin/predicate_assertion_handleable.rb
|
131
145
|
- lib/rubocop/minitest.rb
|
132
146
|
- lib/rubocop/minitest/assert_offense.rb
|
133
|
-
- lib/rubocop/minitest/
|
147
|
+
- lib/rubocop/minitest/plugin.rb
|
134
148
|
- lib/rubocop/minitest/support.rb
|
135
149
|
- lib/rubocop/minitest/version.rb
|
136
150
|
homepage:
|
@@ -140,9 +154,10 @@ metadata:
|
|
140
154
|
homepage_uri: https://docs.rubocop.org/rubocop-minitest/
|
141
155
|
changelog_uri: https://github.com/rubocop/rubocop-minitest/blob/master/CHANGELOG.md
|
142
156
|
source_code_uri: https://github.com/rubocop/rubocop-minitest
|
143
|
-
documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.
|
157
|
+
documentation_uri: https://docs.rubocop.org/rubocop-minitest/0.37
|
144
158
|
bug_tracker_uri: https://github.com/rubocop/rubocop-minitest/issues
|
145
159
|
rubygems_mfa_required: 'true'
|
160
|
+
default_lint_roller_plugin: RuboCop::Minitest::Plugin
|
146
161
|
post_install_message:
|
147
162
|
rdoc_options: []
|
148
163
|
require_paths:
|
@@ -158,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
173
|
- !ruby/object:Gem::Version
|
159
174
|
version: '0'
|
160
175
|
requirements: []
|
161
|
-
rubygems_version: 3.
|
176
|
+
rubygems_version: 3.1.6
|
162
177
|
signing_key:
|
163
178
|
specification_version: 4
|
164
179
|
summary: Automatic Minitest code style checking tool.
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Minitest
|
5
|
-
# Because RuboCop doesn't yet support plugins, we have to monkey patch in a
|
6
|
-
# bit of our configuration.
|
7
|
-
module Inject
|
8
|
-
def self.defaults!
|
9
|
-
path = CONFIG_DEFAULT.to_s
|
10
|
-
hash = ConfigLoader.send(:load_yaml_configuration, path)
|
11
|
-
config = Config.new(hash, path).tap(&:make_excludes_absolute)
|
12
|
-
puts "configuration from #{path}" if ConfigLoader.debug?
|
13
|
-
config = ConfigLoader.merge_with_default(config, path)
|
14
|
-
ConfigLoader.instance_variable_set(:@default_configuration, config)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|