rubocop 0.80.0 → 0.80.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/default.yml +2 -0
- data/lib/rubocop/config.rb +27 -9
- data/lib/rubocop/config_loader.rb +8 -8
- data/lib/rubocop/cop/layout/line_length.rb +1 -1
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +0 -1
- data/lib/rubocop/cop/style/inverse_methods.rb +8 -4
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +2 -2
- data/lib/rubocop/cop/style/redundant_condition.rb +17 -4
- data/lib/rubocop/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4837832a6eb4686ba49145b2668aea7b94d85f3b23d24eb49c05ff9b456393b4
|
4
|
+
data.tar.gz: 1d72140d3461ddf8f64eb1218a78f76603b400e09cb902f1bed6e036650c0d86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4637362ae937c8e659c62d5d4e305342f9580652551356a5178ae3861fa680ac3a7ba27a8eaf0869c73de5c66c16a3ed53d1377aba4d1ad9616dd3e69ce2f761
|
7
|
+
data.tar.gz: aada4e63308932e7847e94de67565942cbc4b12ae41663a1cb1984228988580e7322612c8c3a73337ae54baa0af9dc0b133f627c44c54a39994f86c0c588b976
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
|
|
53
53
|
might want to use a conservative version lock in your `Gemfile`:
|
54
54
|
|
55
55
|
```rb
|
56
|
-
gem 'rubocop', '~> 0.80.
|
56
|
+
gem 'rubocop', '~> 0.80.1', require: false
|
57
57
|
```
|
58
58
|
|
59
59
|
## Quickstart
|
data/config/default.yml
CHANGED
@@ -2820,11 +2820,13 @@ Style/HashSyntax:
|
|
2820
2820
|
Style/HashTransformKeys:
|
2821
2821
|
Description: 'Prefer `transform_keys` over `each_with_object` and `map`.'
|
2822
2822
|
Enabled: 'pending'
|
2823
|
+
VersionAdded: '0.80'
|
2823
2824
|
Safe: false
|
2824
2825
|
|
2825
2826
|
Style/HashTransformValues:
|
2826
2827
|
Description: 'Prefer `transform_values` over `each_with_object` and `map`.'
|
2827
2828
|
Enabled: 'pending'
|
2829
|
+
VersionAdded: '0.80'
|
2828
2830
|
Safe: false
|
2829
2831
|
|
2830
2832
|
Style/IdenticalConditionalBranches:
|
data/lib/rubocop/config.rb
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'pathname'
|
4
4
|
|
5
|
+
# FIXME: Moving Rails department code to RuboCop Rails will remove
|
6
|
+
# the following rubocop:disable comment.
|
7
|
+
# rubocop:disable Metrics/ClassLength
|
5
8
|
module RuboCop
|
6
9
|
# This class represents the configuration of the RuboCop application
|
7
10
|
# and all its cops. A Config is associated with a YAML configuration
|
@@ -13,6 +16,8 @@ module RuboCop
|
|
13
16
|
include FileFinder
|
14
17
|
extend Forwardable
|
15
18
|
|
19
|
+
CopConfig = Struct.new(:name, :metadata)
|
20
|
+
|
16
21
|
DEFAULT_RAILS_VERSION = 5.0
|
17
22
|
attr_reader :loaded_path
|
18
23
|
|
@@ -215,6 +220,18 @@ module RuboCop
|
|
215
220
|
nil
|
216
221
|
end
|
217
222
|
|
223
|
+
def pending_cops
|
224
|
+
keys.each_with_object([]) do |qualified_cop_name, pending_cops|
|
225
|
+
department = department_of(qualified_cop_name)
|
226
|
+
next if department && department['Enabled'] == false
|
227
|
+
|
228
|
+
cop_metadata = self[qualified_cop_name]
|
229
|
+
next unless cop_metadata['Enabled'] == 'pending'
|
230
|
+
|
231
|
+
pending_cops << CopConfig.new(qualified_cop_name, cop_metadata)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
218
235
|
private
|
219
236
|
|
220
237
|
def target_rails_version_from_bundler_lock_file
|
@@ -235,17 +252,18 @@ module RuboCop
|
|
235
252
|
end
|
236
253
|
|
237
254
|
def enable_cop?(qualified_cop_name, cop_options)
|
238
|
-
|
239
|
-
department
|
240
|
-
|
241
|
-
unless department
|
242
|
-
department_options = self[cop_department]
|
243
|
-
if department_options && department_options['Enabled'] == false
|
244
|
-
return false
|
245
|
-
end
|
246
|
-
end
|
255
|
+
department = department_of(qualified_cop_name)
|
256
|
+
return false if department && department['Enabled'] == false
|
247
257
|
|
248
258
|
cop_options.fetch('Enabled') { !for_all_cops['DisabledByDefault'] }
|
249
259
|
end
|
260
|
+
|
261
|
+
def department_of(qualified_cop_name)
|
262
|
+
cop_department, cop_name = qualified_cop_name.split('/')
|
263
|
+
return nil if cop_name.nil?
|
264
|
+
|
265
|
+
self[cop_department]
|
266
|
+
end
|
250
267
|
end
|
251
268
|
end
|
269
|
+
# rubocop:enable Metrics/ClassLength
|
@@ -92,7 +92,7 @@ module RuboCop
|
|
92
92
|
add_excludes_from_files(config, config_file)
|
93
93
|
end
|
94
94
|
merge_with_default(config, config_file).tap do |merged_config|
|
95
|
-
warn_on_pending_cops(merged_config)
|
95
|
+
warn_on_pending_cops(merged_config.pending_cops)
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -116,20 +116,20 @@ module RuboCop
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
-
def warn_on_pending_cops(
|
120
|
-
|
121
|
-
config[key]['Enabled'] == 'pending'
|
122
|
-
end
|
123
|
-
|
124
|
-
return if pending_cops.none?
|
119
|
+
def warn_on_pending_cops(pending_cops)
|
120
|
+
return if pending_cops.empty?
|
125
121
|
|
126
122
|
warn Rainbow('The following cops were added to RuboCop, but are not ' \
|
127
123
|
'configured. Please set Enabled to either `true` or ' \
|
128
124
|
'`false` in your `.rubocop.yml` file:').yellow
|
129
125
|
|
130
126
|
pending_cops.each do |cop|
|
131
|
-
warn Rainbow(
|
127
|
+
warn Rainbow(
|
128
|
+
" - #{cop.name} (#{cop.metadata['VersionAdded']})"
|
129
|
+
).yellow
|
132
130
|
end
|
131
|
+
|
132
|
+
warn Rainbow('For more information: https://docs.rubocop.org/en/latest/versioning/').yellow
|
133
133
|
end
|
134
134
|
|
135
135
|
# Merges the given configuration with the default one. If
|
@@ -109,10 +109,7 @@ module RuboCop
|
|
109
109
|
corrector.remove(not_to_receiver(node, method_call))
|
110
110
|
corrector.replace(method_call.loc.selector,
|
111
111
|
inverse_methods[method].to_s)
|
112
|
-
|
113
|
-
if EQUALITY_METHODS.include?(method)
|
114
|
-
corrector.remove(end_parentheses(node, method_call))
|
115
|
-
end
|
112
|
+
remove_end_parenthesis(corrector, node, method, method_call)
|
116
113
|
end
|
117
114
|
end
|
118
115
|
|
@@ -187,6 +184,13 @@ module RuboCop
|
|
187
184
|
def dot_range(loc)
|
188
185
|
range_between(loc.dot.begin_pos, loc.expression.end_pos)
|
189
186
|
end
|
187
|
+
|
188
|
+
def remove_end_parenthesis(corrector, node, method, method_call)
|
189
|
+
return unless EQUALITY_METHODS.include?(method) ||
|
190
|
+
method_call.parent.begin_type?
|
191
|
+
|
192
|
+
corrector.remove(end_parentheses(node, method_call))
|
193
|
+
end
|
190
194
|
end
|
191
195
|
end
|
192
196
|
end
|
@@ -35,8 +35,8 @@ module RuboCop
|
|
35
35
|
last_arg = nested.last_argument.source_range
|
36
36
|
|
37
37
|
leading_space =
|
38
|
-
range_with_surrounding_space(range: first_arg,
|
39
|
-
side: :left)
|
38
|
+
range_with_surrounding_space(range: first_arg.begin,
|
39
|
+
side: :left)
|
40
40
|
|
41
41
|
lambda do |corrector|
|
42
42
|
corrector.replace(leading_space, '(')
|
@@ -46,7 +46,7 @@ module RuboCop
|
|
46
46
|
def autocorrect(node)
|
47
47
|
lambda do |corrector|
|
48
48
|
if node.ternary?
|
49
|
-
corrector
|
49
|
+
correct_ternary(corrector, node)
|
50
50
|
elsif node.modifier_form? || !node.else_branch
|
51
51
|
corrector.replace(node.source_range, node.if_branch.source)
|
52
52
|
else
|
@@ -90,9 +90,13 @@ module RuboCop
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def else_source(else_branch)
|
93
|
-
|
94
|
-
|
95
|
-
|
93
|
+
if else_branch.basic_conditional? &&
|
94
|
+
else_branch.modifier_form? ||
|
95
|
+
else_branch.range_type?
|
96
|
+
"(#{else_branch.source})"
|
97
|
+
else
|
98
|
+
else_branch.source
|
99
|
+
end
|
96
100
|
end
|
97
101
|
|
98
102
|
def make_ternary_form(node)
|
@@ -106,6 +110,15 @@ module RuboCop
|
|
106
110
|
ternary_form
|
107
111
|
end
|
108
112
|
end
|
113
|
+
|
114
|
+
def correct_ternary(corrector, node)
|
115
|
+
corrector.replace(range_of_offense(node), '||')
|
116
|
+
|
117
|
+
return unless node.else_branch.range_type?
|
118
|
+
|
119
|
+
corrector.insert_before(node.else_branch.loc.expression, '(')
|
120
|
+
corrector.insert_after(node.else_branch.loc.expression, ')')
|
121
|
+
end
|
109
122
|
end
|
110
123
|
end
|
111
124
|
end
|
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.80.
|
4
|
+
version: 0.80.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-02-
|
13
|
+
date: 2020-02-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: jaro_winkler
|
@@ -797,7 +797,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
797
797
|
- !ruby/object:Gem::Version
|
798
798
|
version: '0'
|
799
799
|
requirements: []
|
800
|
-
rubygems_version: 3.
|
800
|
+
rubygems_version: 3.1.2
|
801
801
|
signing_key:
|
802
802
|
specification_version: 4
|
803
803
|
summary: Automatic Ruby code style checking tool.
|