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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 711fd8590c32360212eb79475aed75fa3c9005be72bd22c2a65c4499ed0a9eb5
4
- data.tar.gz: 8dedaaccd58cdffb7943dbbcf32e6454bcb77d99a95f2428066ebcdb8008ea32
2
+ SHA1:
3
+ metadata.gz: fe137e6b63dff943d47b4dffb004f798b024d6f6
4
+ data.tar.gz: f1c9ba164a84db16c846a24a7e77e0deafb0c190
5
5
  SHA512:
6
- metadata.gz: c471766fc309ae3115177dce42b057c5fa18a6bffd1f0f47dc88b5b4cdb906d8ecac815873d4c6a9f6a204cfa898585db3588cff32b71d1340b7ac8714169c78
7
- data.tar.gz: 1ef6635f33167b36b2e0b72995939a9e31f0c97dba606290eac0c76c0eb195a599a6870b3226d9551a98d87a7d5a43252ca1fd14b8571747fcf640092d743629
6
+ metadata.gz: 61d30cf5598f2475fd00ab2766e7a64ad715a43b9ce16840e9dfa93c85bd379bf3e411383e458df224a8f0afbc3f6bbc5cb95767e0dd7642556ae447b2401662
7
+ data.tar.gz: b1ea791fcc890e69fd2980956674b86182d187e6d8b8d80639bdbd87c93a17808c8fb4601908ac23993cfba0a13da2f46002007fa9d4c2f49eb2764f36037c8b
@@ -1,6 +1,9 @@
1
1
  inherit_from:
2
2
  - conf/rubocop.yml
3
3
 
4
+ AllCops:
5
+ TargetRubyVersion: 2.3
6
+
4
7
  Metrics/LineLength:
5
8
  Exclude:
6
9
  - '*.gemspec'
@@ -1,12 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.5.0
4
- - 2.4.3
5
- - 2.3.6
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
@@ -1,5 +1,8 @@
1
1
  # salsify_rubocop
2
2
 
3
+ ## v0.52.1.1
4
+ - Fix `Salsify/StyleDig` false positive in assignments (see [#20](https://github.com/salsify/salsify_rubocop/issues/20)).
5
+
3
6
  ## v0.52.1
4
7
  - Update to `rubocop` v0.52.1 and `rubocop-rspec` v1.21.0.
5
8
 
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
- if nested_access_match(node) && !conditional_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)
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 conditional_assignment?(node)
59
- node.parent && node.parent.or_asgn_type? && (node.parent.children.first == node)
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 && node.send_type? && node.method_name == :[]
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
@@ -1,3 +1,3 @@
1
1
  module SalsifyRubocop
2
- VERSION = '0.52.1'.freeze
2
+ VERSION = '0.52.1.1'.freeze
3
3
  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-01-04 00:00:00.000000000 Z
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.7.3
137
+ rubygems_version: 2.6.14
138
138
  signing_key:
139
139
  specification_version: 4
140
140
  summary: Shared shared RuboCop configuration