rubocop 0.47.0 → 0.47.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubocop might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/default.yml +1 -1
- data/lib/rubocop/config_loader.rb +3 -1
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +1 -1
- data/lib/rubocop/cop/mixin/hash_alignment.rb +5 -3
- data/lib/rubocop/cop/performance/regexp_match.rb +8 -1
- data/lib/rubocop/cop/rails/enum_uniqueness.rb +1 -1
- data/lib/rubocop/cop/style/negated_if.rb +1 -1
- data/lib/rubocop/node_pattern.rb +5 -4
- data/lib/rubocop/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48613fc7243fce70d23fbe5d0041753273006808
|
4
|
+
data.tar.gz: d3ec7b011e070b4a8c60f85abb6dc4fd406d99e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0f233291feb68a508b380875b3bde017e546003fb6e9839d91c1d205c5be2753af21c8e4f250c1723f9b5ea9190cbf07e59726d3e41e100e6e17d6f9d8b94a1
|
7
|
+
data.tar.gz: 72cd29331eca9b7f356da651681a6a0e91cbb38c6c4c185a6ba2e417c218164304d853728f95e583a2438978f6218d853453ee4f682af50dfaa9ca3fb108331e
|
data/README.md
CHANGED
@@ -54,7 +54,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
|
|
54
54
|
might want to use a conservative version locking in your `Gemfile`:
|
55
55
|
|
56
56
|
```rb
|
57
|
-
gem 'rubocop', '~> 0.47.
|
57
|
+
gem 'rubocop', '~> 0.47.1', require: false
|
58
58
|
```
|
59
59
|
|
60
60
|
## Quickstart
|
data/config/default.yml
CHANGED
@@ -57,7 +57,7 @@ AllCops:
|
|
57
57
|
# opt-out. Note that when `DisabledByDefault` is `true`, cops in user
|
58
58
|
# configuration will be enabled even if they don't set the Enabled parameter.
|
59
59
|
DisabledByDefault: false
|
60
|
-
# Enables the result cache if `true`. Can be overridden by the `--cache command
|
60
|
+
# Enables the result cache if `true`. Can be overridden by the `--cache` command
|
61
61
|
# line option.
|
62
62
|
UseCache: true
|
63
63
|
# Threshold for how many files can be stored in the result cache before some
|
@@ -33,11 +33,13 @@ module RuboCop
|
|
33
33
|
path = File.absolute_path(path)
|
34
34
|
hash = load_yaml_configuration(path)
|
35
35
|
|
36
|
+
# Resolve requires first in case they define additional cops
|
37
|
+
resolve_requires(path, hash)
|
38
|
+
|
36
39
|
add_missing_namespaces(path, hash)
|
37
40
|
|
38
41
|
resolve_inheritance_from_gems(hash, hash.delete('inherit_gem'))
|
39
42
|
resolve_inheritance(path, hash)
|
40
|
-
resolve_requires(path, hash)
|
41
43
|
|
42
44
|
hash.delete('inherit_from')
|
43
45
|
config = Config.new(hash, path)
|
@@ -29,7 +29,7 @@ module RuboCop
|
|
29
29
|
MSG = 'Do not chain ordinary method call' \
|
30
30
|
' after safe navigation operator.'.freeze
|
31
31
|
|
32
|
-
ADDITIONAL_NIL_METHODS = %i(present? blank?).freeze
|
32
|
+
ADDITIONAL_NIL_METHODS = %i(present? blank? try).freeze
|
33
33
|
|
34
34
|
def_node_matcher :bad_method?, <<-PATTERN
|
35
35
|
(send (csend ...) $_ ...)
|
@@ -42,10 +42,10 @@ module RuboCop
|
|
42
42
|
private
|
43
43
|
|
44
44
|
def separator_delta(first_pair, current_pair, key_delta)
|
45
|
-
if current_pair.
|
46
|
-
0
|
47
|
-
else
|
45
|
+
if current_pair.hash_rocket?
|
48
46
|
hash_rocket_delta(first_pair, current_pair) - key_delta
|
47
|
+
else
|
48
|
+
0
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -80,6 +80,8 @@ module RuboCop
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def value_delta(first_pair, current_pair)
|
83
|
+
return 0 if current_pair.kwsplat_type?
|
84
|
+
|
83
85
|
correct_value_column = first_pair.key.loc.column +
|
84
86
|
current_pair.delimiter(true).length +
|
85
87
|
max_key_width
|
@@ -172,12 +172,19 @@ module RuboCop
|
|
172
172
|
end
|
173
173
|
|
174
174
|
def scope_body(node)
|
175
|
-
node.children
|
175
|
+
children = node.children
|
176
|
+
case node.type
|
177
|
+
when :module
|
178
|
+
children[1]
|
179
|
+
else
|
180
|
+
children[2]
|
181
|
+
end
|
176
182
|
end
|
177
183
|
|
178
184
|
def scope_root(node)
|
179
185
|
node.each_ancestor.find do |ancestor|
|
180
186
|
ancestor.def_type? ||
|
187
|
+
ancestor.defs_type? ||
|
181
188
|
ancestor.class_type? ||
|
182
189
|
ancestor.module_type?
|
183
190
|
end
|
@@ -23,7 +23,7 @@ module RuboCop
|
|
23
23
|
MSG = 'Duplicate value `%s` found in `%s` enum declaration.'.freeze
|
24
24
|
|
25
25
|
def_node_matcher :enum_declaration, <<-END
|
26
|
-
(send nil :enum (hash (pair (_ $_) $
|
26
|
+
(send nil :enum (hash (pair (_ $_) ${array hash})))
|
27
27
|
END
|
28
28
|
|
29
29
|
def on_send(node)
|
data/lib/rubocop/node_pattern.rb
CHANGED
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
# value of the block through.
|
20
20
|
# - With no block, but one capture: the capture is returned.
|
21
21
|
# - With no block, but multiple captures: captures are returned as an array.
|
22
|
-
# - With no captures: #match returns `true`.
|
22
|
+
# - With no block and no captures: #match returns `true`.
|
23
23
|
#
|
24
24
|
# ## Pattern string format examples
|
25
25
|
#
|
@@ -29,6 +29,7 @@ module RuboCop
|
|
29
29
|
# 'send' # matches (send ...)
|
30
30
|
# '(send)' # matches (send)
|
31
31
|
# '(send ...)' # matches (send ...)
|
32
|
+
# '(op-asgn)' # node types with hyphenated names also work
|
32
33
|
# '{send class}' # matches (send ...) or (class ...)
|
33
34
|
# '({send class})' # matches (send) or (class)
|
34
35
|
# '(send const)' # matches (send (const ...))
|
@@ -98,11 +99,11 @@ module RuboCop
|
|
98
99
|
# Builds Ruby code which implements a pattern
|
99
100
|
class Compiler
|
100
101
|
RSYM = %r{:(?:[\w+@*/?!<>=~|%^-]+|\[\]=?)}
|
101
|
-
ID_CHAR = /[a-zA-Z_]/
|
102
|
+
ID_CHAR = /[a-zA-Z_-]/
|
102
103
|
META = /\(|\)|\{|\}|\[|\]|\$\.\.\.|\$|!|\^|\.\.\./
|
103
104
|
NUMBER = /-?\d+(?:\.\d+)?/
|
104
105
|
TOKEN =
|
105
|
-
/\G(?:[\s,]+|#{META}|\#?#{ID_CHAR}+[\!\?]?\(
|
106
|
+
/\G(?:[\s,]+|#{META}|%\d*|#{NUMBER}|\#?#{ID_CHAR}+[\!\?]?\(?|#{RSYM}|.)/
|
106
107
|
|
107
108
|
NODE = /\A#{ID_CHAR}+\Z/
|
108
109
|
PREDICATE = /\A#{ID_CHAR}+\?\(?\Z/
|
@@ -367,7 +368,7 @@ module RuboCop
|
|
367
368
|
end
|
368
369
|
|
369
370
|
def compile_nodetype(cur_node, type)
|
370
|
-
"(#{cur_node} && #{cur_node}.#{type}_type?)"
|
371
|
+
"(#{cur_node} && #{cur_node}.#{type.tr('-', '_')}_type?)"
|
371
372
|
end
|
372
373
|
|
373
374
|
def compile_param(cur_node, number, seq_head)
|
data/lib/rubocop/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.47.
|
4
|
+
version: 0.47.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-01-
|
13
|
+
date: 2017-01-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rainbow
|