rubocop 0.37.1 → 0.37.2
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/assets/logo.png +0 -0
- data/assets/output.html.erb +247 -0
- data/config/enabled.yml +1 -1
- data/lib/rubocop/ast_node.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +3 -1
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
- data/lib/rubocop/cop/mixin/parentheses.rb +4 -3
- data/lib/rubocop/cop/mixin/surrounding_space.rb +8 -11
- data/lib/rubocop/cop/performance/casecmp.rb +0 -2
- data/lib/rubocop/cop/performance/detect.rb +9 -10
- data/lib/rubocop/cop/performance/redundant_merge.rb +13 -7
- data/lib/rubocop/cop/style/align_hash.rb +0 -2
- data/lib/rubocop/cop/style/redundant_parentheses.rb +23 -16
- data/lib/rubocop/cop/style/rescue_modifier.rb +4 -7
- data/lib/rubocop/cop/style/space_around_operators.rb +1 -1
- data/lib/rubocop/result_cache.rb +8 -5
- data/lib/rubocop/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b548479b22a3d4b42dd0cf160e59a5dac37ed348
|
4
|
+
data.tar.gz: 8dffc754b643dd17217ba127b5fcaac29d9eaf7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6c841494e223ffe783fa455cda9de2fe53068cbf1e1f2477219b83c7f7e404289f211d0481b495991dc94d34c3c9c61cd9cba1e3214f262dc9ba4b57835da98
|
7
|
+
data.tar.gz: 3a06b603d732922bee4ffd5ec8c24d9c3c4b36eb5f26cd9c0bf7cf4d85a281e88afab9dfbed907adf04f56f7cded0b0184b71531e6bfc9980b86534968465efa
|
data/README.md
CHANGED
@@ -115,7 +115,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
|
|
115
115
|
might want to use a conservative version locking in your `Gemfile`:
|
116
116
|
|
117
117
|
```rb
|
118
|
-
gem 'rubocop', '~> 0.37.
|
118
|
+
gem 'rubocop', '~> 0.37.2', require: false
|
119
119
|
```
|
120
120
|
|
121
121
|
## Basic Usage
|
data/assets/logo.png
ADDED
Binary file
|
@@ -0,0 +1,247 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset='UTF-8' />
|
5
|
+
<title>RuboCop Inspection Report</title>
|
6
|
+
<%# TODO: Clean up the messy markup and style definitions. %>
|
7
|
+
<style>
|
8
|
+
* {
|
9
|
+
-webkit-box-sizing: border-box;
|
10
|
+
-moz-box-sizing: border-box;
|
11
|
+
box-sizing: border-box;
|
12
|
+
}
|
13
|
+
|
14
|
+
body, html {
|
15
|
+
font-size: 62.5%;
|
16
|
+
}
|
17
|
+
body {
|
18
|
+
background-color: #ecedf0;
|
19
|
+
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
20
|
+
margin: 0;
|
21
|
+
}
|
22
|
+
code {
|
23
|
+
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
24
|
+
font-size: 85%;
|
25
|
+
}
|
26
|
+
#header {
|
27
|
+
background: #f9f9f9;
|
28
|
+
color: #333;
|
29
|
+
border-bottom: 3px solid #ccc;
|
30
|
+
height: 50px;
|
31
|
+
padding: 0;
|
32
|
+
}
|
33
|
+
#header .logo {
|
34
|
+
float: left;
|
35
|
+
margin: 5px 12px 7px 20px;
|
36
|
+
width: 38px;
|
37
|
+
height: 38px;
|
38
|
+
}
|
39
|
+
#header .title {
|
40
|
+
display: inline-block;
|
41
|
+
float: left;
|
42
|
+
height: 50px;
|
43
|
+
font-size: 2.4rem;
|
44
|
+
letter-spacing: normal;
|
45
|
+
line-height: 50px;
|
46
|
+
margin: 0;
|
47
|
+
}
|
48
|
+
|
49
|
+
.information, #offenses {
|
50
|
+
width: 100%;
|
51
|
+
padding: 20px;
|
52
|
+
color: #333;
|
53
|
+
}
|
54
|
+
#offenses {
|
55
|
+
padding: 0 20px;
|
56
|
+
}
|
57
|
+
|
58
|
+
.information .infobox {
|
59
|
+
border-left: 3px solid;
|
60
|
+
border-radius: 4px;
|
61
|
+
background-color: #fff;
|
62
|
+
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
|
63
|
+
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
|
64
|
+
padding: 15px;
|
65
|
+
border-color: #0088cc;
|
66
|
+
font-size: 1.4rem;
|
67
|
+
}
|
68
|
+
.information .infobox .info-title {
|
69
|
+
font-size: 1.8rem;
|
70
|
+
line-height: 2.2rem;
|
71
|
+
margin: 0 0 0.5em;
|
72
|
+
}
|
73
|
+
.information .infobox ul {
|
74
|
+
list-style: none;
|
75
|
+
margin: 0;
|
76
|
+
padding: 0;
|
77
|
+
}
|
78
|
+
.information .infobox ul li {
|
79
|
+
line-height: 1.8rem
|
80
|
+
}
|
81
|
+
|
82
|
+
#offenses .offense-box {
|
83
|
+
border-radius: 4px;
|
84
|
+
margin-bottom: 20px;
|
85
|
+
background-color: #fff;
|
86
|
+
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
|
87
|
+
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
|
88
|
+
}
|
89
|
+
.fixed .box-title {
|
90
|
+
position: fixed;
|
91
|
+
top: 0;
|
92
|
+
z-index: 10;
|
93
|
+
width: 100%;
|
94
|
+
}
|
95
|
+
.box-title-placeholder {
|
96
|
+
display: none;
|
97
|
+
}
|
98
|
+
.fixed .box-title-placeholder {
|
99
|
+
display: block;
|
100
|
+
}
|
101
|
+
#offenses .offense-box .box-title h3, #offenses .offense-box .box-title-placeholder h3 {
|
102
|
+
color: #33353f;
|
103
|
+
background-color: #f6f6f6;
|
104
|
+
font-size: 2rem;
|
105
|
+
line-height: 2rem;
|
106
|
+
display: block;
|
107
|
+
padding: 15px;
|
108
|
+
border-radius: 5px;
|
109
|
+
margin: 0;
|
110
|
+
}
|
111
|
+
#offenses .offense-box .offense-reports {
|
112
|
+
padding: 0 15px;
|
113
|
+
}
|
114
|
+
#offenses .offense-box .offense-reports .report {
|
115
|
+
border-bottom: 1px dotted #ddd;
|
116
|
+
padding: 15px 0px;
|
117
|
+
position: relative;
|
118
|
+
font-size: 1.3rem;
|
119
|
+
}
|
120
|
+
#offenses .offense-box .offense-reports .report:last-child {
|
121
|
+
border-bottom: none;
|
122
|
+
}
|
123
|
+
#offenses .offense-box .offense-reports .report pre code {
|
124
|
+
display: block;
|
125
|
+
background: #000;
|
126
|
+
color: #fff;
|
127
|
+
padding: 10px 15px;
|
128
|
+
border-radius: 5px;
|
129
|
+
line-height: 1.6rem;
|
130
|
+
}
|
131
|
+
#offenses .offense-box .offense-reports .report .location {
|
132
|
+
font-weight: bold;
|
133
|
+
}
|
134
|
+
#offenses .offense-box .offense-reports .report .message code {
|
135
|
+
padding: 0.3em;
|
136
|
+
background-color: rgba(0,0,0,0.07);
|
137
|
+
border-radius: 3px;
|
138
|
+
}
|
139
|
+
.severity {
|
140
|
+
text-transform: capitalize;
|
141
|
+
font-weight: bold;
|
142
|
+
}
|
143
|
+
.highlight {
|
144
|
+
padding: 2px;
|
145
|
+
border-radius: 2px;
|
146
|
+
font-weight: bold;
|
147
|
+
}
|
148
|
+
<%- SEVERITY_COLORS.each do |severity, color| %>
|
149
|
+
.severity.<%= severity %> {
|
150
|
+
color: <%= color %>;
|
151
|
+
}
|
152
|
+
.highlight.<%= severity %> {
|
153
|
+
background-color: <%= color.fade_out(0.4) %>;
|
154
|
+
border: 1px solid <%= color.fade_out(0.6) %>;
|
155
|
+
}
|
156
|
+
<%- end %>
|
157
|
+
footer {
|
158
|
+
margin-bottom: 20px;
|
159
|
+
margin-right: 20px;
|
160
|
+
font-size: 1.3rem;
|
161
|
+
color: #777;
|
162
|
+
text-align: right;
|
163
|
+
}
|
164
|
+
</style>
|
165
|
+
|
166
|
+
<script>
|
167
|
+
(function() {
|
168
|
+
// floating headers. requires classList support.
|
169
|
+
if (!('classList' in document.createElement("_"))) return;
|
170
|
+
|
171
|
+
var loaded = false,
|
172
|
+
boxes,
|
173
|
+
boxPositions;
|
174
|
+
|
175
|
+
window.onload = function() {
|
176
|
+
var scrollY = window.scrollY;
|
177
|
+
boxes = document.querySelectorAll('.offense-box');
|
178
|
+
boxPositions = [];
|
179
|
+
for (var i = 0; i < boxes.length; i++)
|
180
|
+
// need to add scrollY because the page might be somewhere other than the top when loaded.
|
181
|
+
boxPositions[i] = boxes[i].getBoundingClientRect().top + scrollY;
|
182
|
+
loaded = true;
|
183
|
+
};
|
184
|
+
|
185
|
+
window.onscroll = function() {
|
186
|
+
if (!loaded) return;
|
187
|
+
var i,
|
188
|
+
idx,
|
189
|
+
scrollY = window.scrollY;
|
190
|
+
for (i = 0; i < boxPositions.length; i++) {
|
191
|
+
if (scrollY <= boxPositions[i]) {
|
192
|
+
idx = i;
|
193
|
+
break;
|
194
|
+
}
|
195
|
+
}
|
196
|
+
if (typeof idx == 'undefined') idx = boxes.length;
|
197
|
+
if (idx > 0)
|
198
|
+
boxes[idx - 1].classList.add('fixed');
|
199
|
+
for (i = 0; i < boxes.length; i++) {
|
200
|
+
if (i < idx) continue;
|
201
|
+
boxes[i].classList.remove('fixed');
|
202
|
+
}
|
203
|
+
};
|
204
|
+
})();
|
205
|
+
</script>
|
206
|
+
</head>
|
207
|
+
<body>
|
208
|
+
<div id="header">
|
209
|
+
<img class="logo" src="data:image/png;base64,<%= base64_encoded_logo_image %>" alt="">
|
210
|
+
<h1 class="title">RuboCop Inspection Report</h1>
|
211
|
+
</div>
|
212
|
+
<div class="information">
|
213
|
+
<div class="infobox">
|
214
|
+
<%= pluralize(files.count, 'file') %> inspected,
|
215
|
+
<%= pluralize(summary.offense_count, 'offense', no_for_zero: true) %> detected
|
216
|
+
</div>
|
217
|
+
</div>
|
218
|
+
<div id="offenses">
|
219
|
+
<% files.each do |file| %>
|
220
|
+
<% if file.offenses.any? %>
|
221
|
+
<div class="offense-box">
|
222
|
+
<div class="box-title-placeholder"><h3> </h3></div>
|
223
|
+
<div class="box-title"><h3><%= relative_path(file.path) %> - <%= pluralize(file.offenses.count, 'offense') %></h3></div>
|
224
|
+
<div class="offense-reports">
|
225
|
+
<% file.offenses.each do |offense| %>
|
226
|
+
<div class="report">
|
227
|
+
<div class="meta">
|
228
|
+
<span class="location">Line #<%= offense.location.line %></span> –
|
229
|
+
<span class="severity <%= offense.severity %>"><%= offense.severity %>:</span>
|
230
|
+
<span class="message"><%= decorated_message(offense) %></span>
|
231
|
+
</div>
|
232
|
+
<% unless offense.location.source_line.strip.empty? %>
|
233
|
+
<pre><code><%= highlighted_source_line(offense) %></code></pre>
|
234
|
+
<% end %>
|
235
|
+
</div>
|
236
|
+
<% end %>
|
237
|
+
</div>
|
238
|
+
</div>
|
239
|
+
<% end %>
|
240
|
+
<% end %>
|
241
|
+
</div>
|
242
|
+
<footer>
|
243
|
+
Generated by <a href="https://github.com/bbatsov/rubocop">RuboCop</a>
|
244
|
+
<span class="version"><%= RuboCop::Version::STRING %></span>
|
245
|
+
</footer>
|
246
|
+
</body>
|
247
|
+
</html>
|
data/config/enabled.yml
CHANGED
@@ -10,7 +10,7 @@ Style/AccessorMethodName:
|
|
10
10
|
Enabled: true
|
11
11
|
|
12
12
|
Style/Alias:
|
13
|
-
Description: 'Use
|
13
|
+
Description: 'Use alias instead of alias_method.'
|
14
14
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method'
|
15
15
|
Enabled: true
|
16
16
|
|
data/lib/rubocop/ast_node.rb
CHANGED
@@ -500,7 +500,7 @@ module RuboCop
|
|
500
500
|
index = parent.children.index { |child| child.equal?(self) }
|
501
501
|
|
502
502
|
case parent.type
|
503
|
-
when :array, :
|
503
|
+
when :array, :defined?, :dstr, :dsym, :eflipflop, :erange, :float,
|
504
504
|
:hash, :iflipflop, :irange, :not, :pair, :regexp, :str, :sym, :when,
|
505
505
|
:xstr
|
506
506
|
parent.value_used?
|
@@ -25,6 +25,8 @@ module RuboCop
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def autocorrect(node)
|
28
|
+
return if node.dstr_type? # nested, fixed in next iteration
|
29
|
+
|
28
30
|
value = autocorrected_value(node)
|
29
31
|
->(corrector) { corrector.replace(node.parent.source_range, value) }
|
30
32
|
end
|
@@ -44,7 +46,7 @@ module RuboCop
|
|
44
46
|
when :sym
|
45
47
|
autocorrected_value_for_symbol(node)
|
46
48
|
else
|
47
|
-
node.source
|
49
|
+
node.source.gsub('"', '\"')
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
@@ -15,9 +15,9 @@ module RuboCop
|
|
15
15
|
|
16
16
|
def on_send(node)
|
17
17
|
_receiver, method_name, *args = *node
|
18
|
+
return if args.size > 1
|
18
19
|
return if operator?(method_name) || node.asgn_method_call?
|
19
20
|
return unless args.first && args.first.source.start_with?('(')
|
20
|
-
return if args.size > 1
|
21
21
|
|
22
22
|
space_length = spaces_before_left_parenthesis(node)
|
23
23
|
return unless space_length > 0
|
@@ -6,9 +6,10 @@ module RuboCop
|
|
6
6
|
# Common functionality for handling parentheses.
|
7
7
|
module Parentheses
|
8
8
|
def parens_required?(node)
|
9
|
-
|
10
|
-
source_buffer.source
|
11
|
-
|
9
|
+
range = node.source_range
|
10
|
+
source = range.source_buffer.source
|
11
|
+
source[range.begin_pos - 1] =~ /[a-z]/ ||
|
12
|
+
source[range.end_pos] =~ /[a-z]/
|
12
13
|
end
|
13
14
|
|
14
15
|
def autocorrect(node)
|
@@ -5,26 +5,23 @@ module RuboCop
|
|
5
5
|
module Cop
|
6
6
|
# Common functionality for checking surrounding space.
|
7
7
|
module SurroundingSpace
|
8
|
-
def space_between?(t1,
|
9
|
-
between = Parser::Source::Range.new(t1.pos.source_buffer,
|
10
|
-
t1.pos.end_pos,
|
11
|
-
t2.pos.begin_pos).source
|
12
|
-
|
8
|
+
def space_between?(t1, _t2)
|
13
9
|
# Check if the range between the tokens starts with a space. It can
|
14
10
|
# contain other characters, e.g. a unary plus, but it must start with
|
15
11
|
# space.
|
16
|
-
|
12
|
+
t1.pos.source_buffer.source.match(/\G\s/, t1.pos.end_pos)
|
17
13
|
end
|
18
14
|
|
19
15
|
def index_of_first_token(node)
|
20
|
-
|
21
|
-
token_table[
|
16
|
+
range = node.source_range
|
17
|
+
token_table[range.line][range.column]
|
22
18
|
end
|
23
19
|
|
24
20
|
def index_of_last_token(node)
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
range = node.source_range
|
22
|
+
table_row = token_table[range.last_line]
|
23
|
+
(0...range.last_column).reverse_each do |c|
|
24
|
+
ix = table_row[c]
|
28
25
|
return ix if ix
|
29
26
|
end
|
30
27
|
end
|
@@ -26,19 +26,15 @@ module RuboCop
|
|
26
26
|
DANGEROUS_METHODS = [:first, :last].freeze
|
27
27
|
|
28
28
|
def on_send(node)
|
29
|
-
receiver, second_method = *node
|
30
|
-
return
|
31
|
-
return unless DANGEROUS_METHODS.include?(second_method)
|
29
|
+
receiver, second_method, *args = *node
|
30
|
+
return unless check_second_call(receiver, second_method, args)
|
32
31
|
|
33
32
|
receiver, _args, body = *receiver if receiver.block_type?
|
34
|
-
|
35
33
|
caller, first_method, args = *receiver
|
36
34
|
|
37
35
|
# check that we have usual block or block pass
|
38
36
|
return if body.nil? && (args.nil? || !args.block_pass_type?)
|
39
|
-
|
40
37
|
return unless SELECT_METHODS.include?(first_method)
|
41
|
-
|
42
38
|
return if lazy?(caller)
|
43
39
|
|
44
40
|
range = receiver.loc.selector.join(node.loc.selector)
|
@@ -59,10 +55,7 @@ module RuboCop
|
|
59
55
|
preferred_method
|
60
56
|
end
|
61
57
|
|
62
|
-
first_range =
|
63
|
-
receiver.source,
|
64
|
-
receiver.loc.end.end_pos,
|
65
|
-
receiver.loc.end.end_pos).join(node.loc.selector)
|
58
|
+
first_range = receiver.source_range.end.join(node.loc.selector)
|
66
59
|
|
67
60
|
receiver, _args, _body = *receiver if receiver.block_type?
|
68
61
|
|
@@ -74,6 +67,12 @@ module RuboCop
|
|
74
67
|
|
75
68
|
private
|
76
69
|
|
70
|
+
def check_second_call(receiver, method, args)
|
71
|
+
receiver &&
|
72
|
+
DANGEROUS_METHODS.include?(method) &&
|
73
|
+
args.empty?
|
74
|
+
end
|
75
|
+
|
77
76
|
def preferred_method
|
78
77
|
config.for_cop('Style/CollectionMethods') \
|
79
78
|
['PreferredMethods']['detect'] || 'detect'
|
@@ -38,14 +38,11 @@ module RuboCop
|
|
38
38
|
parent = node.parent
|
39
39
|
if parent && pairs.size > 1
|
40
40
|
if modifier_flow_control(parent)
|
41
|
-
|
42
|
-
padding = "\n#{' ' * indent_width}"
|
43
|
-
new_source.gsub!(/\n/, padding)
|
44
|
-
new_source = parent.loc.keyword.source << ' ' <<
|
45
|
-
cond.source << padding << leading_spaces(node) <<
|
46
|
-
new_source << "\n" << leading_spaces(node) <<
|
47
|
-
'end'
|
41
|
+
new_source = rewrite_with_modifier(node, parent, new_source)
|
48
42
|
node = parent
|
43
|
+
else
|
44
|
+
padding = "\n#{leading_spaces(node)}"
|
45
|
+
new_source.gsub!(/\n/, padding)
|
49
46
|
end
|
50
47
|
end
|
51
48
|
|
@@ -69,6 +66,15 @@ module RuboCop
|
|
69
66
|
end
|
70
67
|
end
|
71
68
|
|
69
|
+
def rewrite_with_modifier(node, parent, new_source)
|
70
|
+
cond, = *parent
|
71
|
+
padding = "\n#{(' ' * indent_width) + leading_spaces(node)}"
|
72
|
+
new_source.gsub!(/\n/, padding)
|
73
|
+
|
74
|
+
parent.loc.keyword.source << ' ' << cond.source << padding <<
|
75
|
+
new_source << "\n" << leading_spaces(node) << 'end'
|
76
|
+
end
|
77
|
+
|
72
78
|
def leading_spaces(node)
|
73
79
|
node.source_range.source_line[/\A\s*/]
|
74
80
|
end
|
@@ -7,8 +7,6 @@ module RuboCop
|
|
7
7
|
# Here we check if the keys, separators, and values of a multi-line hash
|
8
8
|
# literal are aligned.
|
9
9
|
class AlignHash < Cop
|
10
|
-
include IgnoredNode
|
11
|
-
|
12
10
|
# Handles calculation of deltas (deviations from correct alignment)
|
13
11
|
# when the enforced style is 'key'.
|
14
12
|
class KeyAlignment
|
@@ -22,20 +22,31 @@ module RuboCop
|
|
22
22
|
def_node_matcher :square_brackets?, '(send (send _recv _msg) :[] ...)'
|
23
23
|
def_node_matcher :range_end?, '^^{irange erange}'
|
24
24
|
def_node_matcher :method_node_and_args, '$(send _recv _msg $...)'
|
25
|
+
def_node_matcher :rescue?, '{^resbody ^^resbody}'
|
26
|
+
def_node_matcher :arg_in_call_with_block?,
|
27
|
+
'^^(block (send _ _ equal?(%0) ...) ...)'
|
25
28
|
|
26
29
|
def on_begin(node)
|
27
|
-
return
|
28
|
-
|
29
|
-
|
30
|
-
return if keyword_ancestor?(node) && parens_required?(node)
|
31
|
-
return if child_node.hash_type? && first_argument?(node) &&
|
32
|
-
!parentheses?(node.parent)
|
30
|
+
return if !parentheses?(node) || parens_allowed?(node)
|
31
|
+
check(node)
|
32
|
+
end
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
def parens_allowed?(node)
|
35
|
+
child = node.children.first
|
36
|
+
parent = node.parent
|
37
|
+
|
38
|
+
# don't flag `break(1)`, etc
|
39
|
+
(keyword_ancestor?(node) && parens_required?(node)) ||
|
40
|
+
# don't flag `method ({key: value})`
|
41
|
+
(child.hash_type? && first_arg?(node) && !parentheses?(parent)) ||
|
42
|
+
# don't flag `rescue(ExceptionClass)`
|
43
|
+
rescue?(node) ||
|
44
|
+
# don't flag `method (arg) { }`
|
45
|
+
(arg_in_call_with_block?(node) && !parentheses?(parent))
|
36
46
|
end
|
37
47
|
|
38
|
-
def check(begin_node
|
48
|
+
def check(begin_node)
|
49
|
+
node = begin_node.children.first
|
39
50
|
if keyword_with_redundant_parentheses?(node)
|
40
51
|
return offense(begin_node, 'a keyword')
|
41
52
|
end
|
@@ -59,7 +70,7 @@ module RuboCop
|
|
59
70
|
end
|
60
71
|
|
61
72
|
def keyword_ancestor?(node)
|
62
|
-
node.
|
73
|
+
node.parent && node.parent.keyword?
|
63
74
|
end
|
64
75
|
|
65
76
|
def disallowed_literal?(node)
|
@@ -89,16 +100,12 @@ module RuboCop
|
|
89
100
|
args.empty? || parentheses?(send_node) || square_brackets?(send_node)
|
90
101
|
end
|
91
102
|
|
92
|
-
def
|
103
|
+
def first_arg?(node)
|
93
104
|
send_node = node.parent
|
94
105
|
return false unless send_node && send_node.send_type?
|
95
106
|
|
96
107
|
_receiver, _method_name, *args = *send_node
|
97
|
-
node
|
98
|
-
end
|
99
|
-
|
100
|
-
def rescue?(node)
|
101
|
-
node.parent && node.parent.array_type?
|
108
|
+
node.equal?(args.first)
|
102
109
|
end
|
103
110
|
end
|
104
111
|
end
|
@@ -26,25 +26,22 @@ module RuboCop
|
|
26
26
|
operation, rescue_modifier, = *node
|
27
27
|
*_, rescue_args = *rescue_modifier
|
28
28
|
|
29
|
+
indent = indentation(node)
|
29
30
|
correction =
|
30
31
|
"begin\n" \
|
31
|
-
"#{
|
32
|
+
"#{operation.source.gsub(/^/, indent)}" \
|
32
33
|
"\n#{offset(node)}rescue\n" \
|
33
|
-
"#{
|
34
|
+
"#{rescue_args.source.gsub(/^/, indent)}" \
|
34
35
|
"\n#{offset(node)}end"
|
35
|
-
range = Parser::Source::Range.new(node.source_range.source_buffer,
|
36
|
-
node.source_range.begin_pos,
|
37
|
-
node.source_range.end_pos)
|
38
36
|
|
39
37
|
lambda do |corrector|
|
40
|
-
corrector.replace(
|
38
|
+
corrector.replace(node.source_range, correction)
|
41
39
|
end
|
42
40
|
end
|
43
41
|
|
44
42
|
private
|
45
43
|
|
46
44
|
def modifier?(node)
|
47
|
-
return false unless @modifier_locations.respond_to?(:include?)
|
48
45
|
@modifier_locations.include?(node.loc.keyword)
|
49
46
|
end
|
50
47
|
end
|
@@ -41,7 +41,7 @@ module RuboCop
|
|
41
41
|
on_special_asgn(node)
|
42
42
|
elsif !node.unary_operation? && !called_with_dot?(node)
|
43
43
|
op = node.method_name
|
44
|
-
if op != :[] && op != :! && operator?(op)
|
44
|
+
if op != :[] && op != :! && op != :[]= && operator?(op)
|
45
45
|
_, _, right, = *node
|
46
46
|
check_operator(node.loc.selector, right.source_range)
|
47
47
|
end
|
data/lib/rubocop/result_cache.rb
CHANGED
@@ -57,7 +57,7 @@ module RuboCop
|
|
57
57
|
def initialize(file, options, config_store, cache_root = nil)
|
58
58
|
cache_root ||= ResultCache.cache_root(config_store)
|
59
59
|
@path = File.join(cache_root, rubocop_checksum,
|
60
|
-
|
60
|
+
relevant_options_digest(options),
|
61
61
|
file_checksum(file, config_store))
|
62
62
|
@cached_data = CachedData.new(file)
|
63
63
|
end
|
@@ -129,12 +129,15 @@ module RuboCop
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
# Return the options given at invocation, minus the ones that have
|
133
|
-
# effect on which offenses and disabled line ranges are found, and thus
|
132
|
+
# Return a hash of the options given at invocation, minus the ones that have
|
133
|
+
# no effect on which offenses and disabled line ranges are found, and thus
|
134
134
|
# don't affect caching.
|
135
|
-
def
|
135
|
+
def relevant_options_digest(options)
|
136
136
|
options = options.reject { |key, _| NON_CHANGING.include?(key) }
|
137
|
-
options.to_s.gsub(/[^a-z]+/i, '_')
|
137
|
+
options = options.to_s.gsub(/[^a-z]+/i, '_')
|
138
|
+
# We must avoid making file names too long for some filesystems to handle
|
139
|
+
# If they are short, we can leave them human-readable
|
140
|
+
options.length <= 32 ? options : Digest::MD5.hexdigest(options)
|
138
141
|
end
|
139
142
|
end
|
140
143
|
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.37.
|
4
|
+
version: 0.37.2
|
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: 2016-02-
|
13
|
+
date: 2016-02-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rainbow
|
@@ -121,6 +121,8 @@ extra_rdoc_files:
|
|
121
121
|
files:
|
122
122
|
- LICENSE.txt
|
123
123
|
- README.md
|
124
|
+
- assets/logo.png
|
125
|
+
- assets/output.html.erb
|
124
126
|
- bin/rubocop
|
125
127
|
- config/default.yml
|
126
128
|
- config/disabled.yml
|