rubocop-rails_config 0.1.0 → 0.1.1

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: 5c47b7e5d6390a81fa212b6baad0d3f59ba4106277ccaa34a984a64be53a833b
4
- data.tar.gz: a51629a1d8be14625b3612aa32d28c640b201fc7706eeebda7f5d716140f59ac
3
+ metadata.gz: 3fb2e3c7b85c6d88432fb39e1a7d088ed08fdcda87bc7cf819ec322546059115
4
+ data.tar.gz: 1c41e92ac1f9c4a4138d7d105e19bc20948ae2630fe64391887c53d868c859dc
5
5
  SHA512:
6
- metadata.gz: e4d02cb8fbc8dcac9c7ef0eabd2ee6d35507e33d421ae4a081083dd525a2c7d1e29ee269482887fc68a09a0723c4ca02986862038fb0deb971e97f8cb93f4995
7
- data.tar.gz: e21d18073cb51e2d1eb718a8aefa6116bb6d82933a692f03f1bf0d5b8a51af04a350481800fa7b51cb853219320a063b35c1135fa3e0f96f2981dbf8c0974bd3
6
+ metadata.gz: a8ca96ee80de6ade28917654338cfae1b58a814c99b31feb91ee985a201bef5726305ef547a1be5ed3f8a9a5c7fc1e1f354519c1a0c8a6eba4a7452624669498
7
+ data.tar.gz: 0ca0b6f8774733ed0f26171e48e396ded1d77828f01b803ac11f60780a27d1e8d63330f017eeadfa2da27691c134bae0fdcad9a20a8c0ab81c00e78aee8a6bfc
data/README.md CHANGED
@@ -17,7 +17,7 @@ gem "rubocop-rails_config"
17
17
 
18
18
  ## Usage
19
19
 
20
- Add this line to your application's `.rubocop.yml`, or just run `rails generate rubocop_rails:install`:
20
+ Add this line to your application's `.rubocop.yml`, or just run `rails generate rubocop_rails_config:install`:
21
21
 
22
22
  ```yml
23
23
  inherit_gem:
data/config/rails.yml CHANGED
@@ -17,6 +17,11 @@ CustomCops/RefuteNot:
17
17
  Include:
18
18
  - '**/test/**/*'
19
19
 
20
+ # Prefer assert_not over assert !
21
+ CustomCops/AssertNot:
22
+ Include:
23
+ - '**/test/**/*'
24
+
20
25
  # Prefer &&/|| over and/or.
21
26
  Style/AndOr:
22
27
  Enabled: true
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CustomCops
4
+ # Enforces the use of `assert_not` over `assert !`.
5
+ #
6
+ # @example
7
+ # # bad
8
+ # assert !x
9
+ # assert ! x
10
+ #
11
+ # # good
12
+ # assert_not x
13
+ #
14
+ class AssertNot < RuboCop::Cop::Cop
15
+ MSG = "Prefer `assert_not` over `assert !`"
16
+
17
+ def_node_matcher :offensive?, "(send nil? :assert (send ... :!) ...)"
18
+
19
+ def on_send(node)
20
+ add_offense(node) if offensive?(node)
21
+ end
22
+
23
+ def autocorrect(node)
24
+ expression = node.loc.expression
25
+
26
+ ->(corrector) do
27
+ corrector.replace(
28
+ expression,
29
+ corrected_source(expression.source)
30
+ )
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def corrected_source(source)
37
+ source.gsub(/^assert(\(| ) *! */, "assert_not\\1")
38
+ end
39
+ end
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rails_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshimaru
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-27 00:00:00.000000000 Z
11
+ date: 2018-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -91,6 +91,7 @@ files:
91
91
  - README.md
92
92
  - config/rails.yml
93
93
  - lib/custom_cops.rb
94
+ - lib/custom_cops/assert_not.rb
94
95
  - lib/custom_cops/refute_not.rb
95
96
  - lib/generators/rubocop_rails_config/install_generator.rb
96
97
  - lib/generators/rubocop_rails_config/update_generator.rb