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 +4 -4
- data/README.md +1 -1
- data/config/rails.yml +5 -0
- data/lib/custom_cops/assert_not.rb +40 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fb2e3c7b85c6d88432fb39e1a7d088ed08fdcda87bc7cf819ec322546059115
|
4
|
+
data.tar.gz: 1c41e92ac1f9c4a4138d7d105e19bc20948ae2630fe64391887c53d868c859dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
@@ -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.
|
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-
|
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
|