salsify_rubocop 0.52.1 → 0.52.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +3 -0
- data/.travis.yml +3 -7
- data/CHANGELOG.md +3 -0
- data/README.md +1 -2
- data/lib/rubocop/cop/salsify/style_dig.rb +13 -10
- data/lib/salsify_rubocop/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fe137e6b63dff943d47b4dffb004f798b024d6f6
|
4
|
+
data.tar.gz: f1c9ba164a84db16c846a24a7e77e0deafb0c190
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61d30cf5598f2475fd00ab2766e7a64ad715a43b9ce16840e9dfa93c85bd379bf3e411383e458df224a8f0afbc3f6bbc5cb95767e0dd7642556ae447b2401662
|
7
|
+
data.tar.gz: b1ea791fcc890e69fd2980956674b86182d187e6d8b8d80639bdbd87c93a17808c8fb4601908ac23993cfba0a13da2f46002007fa9d4c2f49eb2764f36037c8b
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.5.
|
4
|
-
- 2.4.
|
5
|
-
- 2.3.
|
6
|
-
- 2.2.9
|
7
|
-
before_install:
|
8
|
-
# Workaround for https://github.com/sickill/rainbow/issues/48
|
9
|
-
- gem update --system
|
3
|
+
- 2.5.1
|
4
|
+
- 2.4.4
|
5
|
+
- 2.3.7
|
10
6
|
script:
|
11
7
|
- bundle exec rubocop
|
12
8
|
- bundle exec rspec
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# salsify_rubocop
|
2
2
|
|
3
|
-
This gem provides shared configuration for RuboCop for Salsify applications
|
4
|
-
and gems.
|
3
|
+
This gem provides shared configuration for RuboCop for Salsify applications/gems and some experimental cops.
|
5
4
|
|
6
5
|
[RuboCop](https://github.com/bbatsov/rubocop) is a static code analyzer that
|
7
6
|
can enforce style conventions as well as identify common problems.
|
@@ -24,16 +24,15 @@ module RuboCop
|
|
24
24
|
MSG = 'Use `dig` for nested access.'.freeze
|
25
25
|
|
26
26
|
def_node_matcher :nested_access_match, <<-PATTERN
|
27
|
-
(send (send (send _receiver !:[]) :[]
|
27
|
+
(send (send (send _receiver !:[]) :[] !{irange erange}) :[] !{irange erange})
|
28
28
|
PATTERN
|
29
29
|
|
30
30
|
def on_send(node)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
31
|
+
return unless nested_access_match(node) && !assignment?(node)
|
32
|
+
match_node = node
|
33
|
+
# walk to outermost access node
|
34
|
+
match_node = match_node.parent while access_node?(match_node.parent)
|
35
|
+
add_offense(match_node, location: :expression, message: MSG)
|
37
36
|
end
|
38
37
|
|
39
38
|
def autocorrect(node)
|
@@ -55,12 +54,16 @@ module RuboCop
|
|
55
54
|
|
56
55
|
private
|
57
56
|
|
58
|
-
def
|
59
|
-
node.parent
|
57
|
+
def assignment?(node)
|
58
|
+
node.parent&.assignment? && (node.parent.children.first == node)
|
60
59
|
end
|
61
60
|
|
62
61
|
def access_node?(node)
|
63
|
-
node
|
62
|
+
node&.send_type? && node.method_name == :[] && !range?(node.first_argument)
|
63
|
+
end
|
64
|
+
|
65
|
+
def range?(node)
|
66
|
+
node.irange_type? || node.erange_type?
|
64
67
|
end
|
65
68
|
end
|
66
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salsify_rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.52.1
|
4
|
+
version: 0.52.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Salsify, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.6.14
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Shared shared RuboCop configuration
|