rubocop-minitest 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/config/default.yml +5 -0
- data/lib/rubocop/cop/minitest/assert_empty_literal.rb +36 -0
- data/lib/rubocop/cop/minitest_cops.rb +1 -0
- data/lib/rubocop/minitest/version.rb +1 -1
- data/manual/cops.md +1 -0
- data/manual/cops_minitest.md +20 -0
- data/relnotes/v0.5.0.md +5 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fb2a1153e8f5e4eb37a349fcdfff211a421369606facb6d866fbc4701a60d6c
|
4
|
+
data.tar.gz: 2e258868d43eddc169e142e408e01d52e7d6e63ac5e9f1f53643feca8ff8968e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 466706a3aa3020369c7b855c20ad0619cfd8d2e4c94a6f260287908ce2d5ecefdc8190bc88a60d7cb59d0cdd39a276dc87ebdea91c240a5d820e167d984424c9
|
7
|
+
data.tar.gz: 6aede577f029efa7fb8a2cf89151261c16dfe57f980100b568c8e11252b7652e45cac051f404212411e2cac2a0232d0c4c752322f6781fa3c37297e6a10eae11
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/config/default.yml
CHANGED
@@ -9,6 +9,11 @@ Minitest/AssertEmpty:
|
|
9
9
|
Enabled: true
|
10
10
|
VersionAdded: '0.2'
|
11
11
|
|
12
|
+
Minitest/AssertEmptyLiteral:
|
13
|
+
Description: 'This cop enforces the test to use `assert_empty` instead of using `assert([], object)` or `assert({}, object)`.'
|
14
|
+
Enabled: true
|
15
|
+
VersionAdded: '0.5'
|
16
|
+
|
12
17
|
Minitest/AssertEqual:
|
13
18
|
Description: 'This cop enforces the test to use `assert_equal` instead of using `assert(expected == actual)`.'
|
14
19
|
StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#assert-equal-arguments-order'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Minitest
|
6
|
+
# This cop enforces the test to use `assert_empty`
|
7
|
+
# instead of using `assert([], object)`.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# # bad
|
11
|
+
# assert([], object)
|
12
|
+
# assert({}, object)
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# assert_empty(object)
|
16
|
+
#
|
17
|
+
class AssertEmptyLiteral < Cop
|
18
|
+
MSG = 'Prefer using `assert_empty(%<arguments>s)` over ' \
|
19
|
+
'`assert(%<literal>s, %<arguments>s)`.'
|
20
|
+
|
21
|
+
def_node_matcher :assert_with_empty_literal, <<~PATTERN
|
22
|
+
(send nil? :assert ${hash array} $...)
|
23
|
+
PATTERN
|
24
|
+
|
25
|
+
def on_send(node)
|
26
|
+
assert_with_empty_literal(node) do |literal, matchers|
|
27
|
+
args = matchers.map(&:source).join(', ')
|
28
|
+
|
29
|
+
message = format(MSG, literal: literal.source, arguments: args)
|
30
|
+
add_offense(node, message: message)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/manual/cops.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
#### Department [Minitest](cops_minitest.md)
|
3
3
|
|
4
4
|
* [Minitest/AssertEmpty](cops_minitest.md#minitestassertempty)
|
5
|
+
* [Minitest/AssertEmptyLiteral](cops_minitest.md#minitestassertemptyliteral)
|
5
6
|
* [Minitest/AssertEqual](cops_minitest.md#minitestassertequal)
|
6
7
|
* [Minitest/AssertIncludes](cops_minitest.md#minitestassertincludes)
|
7
8
|
* [Minitest/AssertInstanceOf](cops_minitest.md#minitestassertinstanceof)
|
data/manual/cops_minitest.md
CHANGED
@@ -25,6 +25,26 @@ assert_empty(object, 'the message')
|
|
25
25
|
|
26
26
|
* [https://github.com/rubocop-hq/minitest-style-guide#assert-empty](https://github.com/rubocop-hq/minitest-style-guide#assert-empty)
|
27
27
|
|
28
|
+
## Minitest/AssertEmptyLiteral
|
29
|
+
|
30
|
+
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
31
|
+
--- | --- | --- | --- | ---
|
32
|
+
Enabled | Yes | No | 0.5 | -
|
33
|
+
|
34
|
+
This cop enforces the test to use `assert_empty`
|
35
|
+
instead of using `assert([], object)`.
|
36
|
+
|
37
|
+
### Examples
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
# bad
|
41
|
+
assert([], object)
|
42
|
+
assert({}, object)
|
43
|
+
|
44
|
+
# good
|
45
|
+
assert_empty(object)
|
46
|
+
```
|
47
|
+
|
28
48
|
## Minitest/AssertEqual
|
29
49
|
|
30
50
|
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
data/relnotes/v0.5.0.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.
|
4
|
+
version: 0.5.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: 2019-11-
|
13
|
+
date: 2019-11-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- config/default.yml
|
68
68
|
- lib/rubocop-minitest.rb
|
69
69
|
- lib/rubocop/cop/minitest/assert_empty.rb
|
70
|
+
- lib/rubocop/cop/minitest/assert_empty_literal.rb
|
70
71
|
- lib/rubocop/cop/minitest/assert_equal.rb
|
71
72
|
- lib/rubocop/cop/minitest/assert_includes.rb
|
72
73
|
- lib/rubocop/cop/minitest/assert_instance_of.rb
|
@@ -97,6 +98,7 @@ files:
|
|
97
98
|
- relnotes/v0.3.0.md
|
98
99
|
- relnotes/v0.4.0.md
|
99
100
|
- relnotes/v0.4.1.md
|
101
|
+
- relnotes/v0.5.0.md
|
100
102
|
- rubocop-minitest.gemspec
|
101
103
|
- tasks/cops_documentation.rake
|
102
104
|
- tasks/cut_release.rake
|