rubocop-minitest 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 930866a6157741e50512335bb341add3271a010ce7297d47a2ea439494b48bd1
4
- data.tar.gz: 6e3583932fa0d49db8ca8a77f4f8c47b36d4e13bd978f4ee91075190f0e646ed
3
+ metadata.gz: 4fb2a1153e8f5e4eb37a349fcdfff211a421369606facb6d866fbc4701a60d6c
4
+ data.tar.gz: 2e258868d43eddc169e142e408e01d52e7d6e63ac5e9f1f53643feca8ff8968e
5
5
  SHA512:
6
- metadata.gz: 1a84adc4ef08e2c434ef214ac0351f5943ef2fc55b24e7e8d16be6a423d5e2a19e189ec1e23f6bad5ae8f1a23595332949f6f318295680d0ec854efb084d2ff0
7
- data.tar.gz: 45725285a52705d75dc544ecc13d644e38cae8338c8fe070599def10ce272357bbc89cd26f9188300cf4b0f8a1d1a82818406242a36ff6f9102066fb052a3ca4
6
+ metadata.gz: 466706a3aa3020369c7b855c20ad0619cfd8d2e4c94a6f260287908ce2d5ecefdc8190bc88a60d7cb59d0cdd39a276dc87ebdea91c240a5d820e167d984424c9
7
+ data.tar.gz: 6aede577f029efa7fb8a2cf89151261c16dfe57f980100b568c8e11252b7652e45cac051f404212411e2cac2a0232d0c4c752322f6781fa3c37297e6a10eae11
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.5.0 (2019-11-24)
6
+
7
+ ### New features
8
+
9
+ * [#32](https://github.com/rubocop-hq/rubocop-minitest/issues/32): Add new `Minitest/AssertEmptyLiteral` cop. ([@tejasbubane][])
10
+
5
11
  ## 0.4.1 (2019-11-10)
6
12
 
7
13
  ### Bug fixes
data/Gemfile CHANGED
@@ -9,5 +9,5 @@ gemspec
9
9
  gem 'bump', require: false
10
10
  gem 'rake'
11
11
  gem 'rubocop', github: 'rubocop-hq/rubocop'
12
- gem 'rubocop-performance', '~> 1.4.0'
12
+ gem 'rubocop-performance', '~> 1.5.0'
13
13
  gem 'yard', '~> 0.9'
@@ -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
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'minitest/assert_empty'
4
+ require_relative 'minitest/assert_empty_literal'
4
5
  require_relative 'minitest/assert_equal'
5
6
  require_relative 'minitest/assert_nil'
6
7
  require_relative 'minitest/assert_includes'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Minitest
5
- VERSION = '0.4.1'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
@@ -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)
@@ -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
@@ -0,0 +1,5 @@
1
+ ### New features
2
+
3
+ * [#32](https://github.com/rubocop-hq/rubocop-minitest/issues/32): Add new `Minitest/AssertEmptyLiteral` cop. ([@tejasbubane][])
4
+
5
+ [@tejasbubane]: https://github.com/tejasbubane
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.1
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-09 00:00:00.000000000 Z
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