rubocop 0.41.1 → 0.41.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86879d377fb20fd602a7bd74846127dabff3eaff
4
- data.tar.gz: 667de06f4b8796dcdc48bd8c84da7687df8c7503
3
+ metadata.gz: 1a7d6fcd2f40430ad14bde72540681109b1e9f5b
4
+ data.tar.gz: af9a00491131661fdd1866f9b6b774c7ed92763c
5
5
  SHA512:
6
- metadata.gz: 9286cdc9b1842a27df0a884ab5c7e33b6e7162fa29507d810ba7c27b1f4fadc960c3502a64b0855726e0ab664fb5d36a4c685eac11c9286bd597e9aac9aaebca
7
- data.tar.gz: cb042872468b5309744a002bc052d2601c344efd1773265d0b463a00c7b5e3931aa4ac85daf974104b81ac8e9877bf436cf08fd554bae331f25b82b308241a96
6
+ metadata.gz: 3eb3c0f92e9455c4225a7eb7c571227db0b6cb3563ab746029c3d108d0146ce68762e5a4f8193acc8e0f92172ade66f102a3bcb24488c06cc749ef82826e7e26
7
+ data.tar.gz: 152966c8fc530fad493837af8e58a5d8128d17b0fbe2514f9b8f14db104b68ef31e3275f8036abd5b41dec4fbdb5184eee44b79e836c305f80ae90df7e9a329d
data/README.md CHANGED
@@ -51,7 +51,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
51
51
  might want to use a conservative version locking in your `Gemfile`:
52
52
 
53
53
  ```rb
54
- gem 'rubocop', '~> 0.41.1', require: false
54
+ gem 'rubocop', '~> 0.41.2', require: false
55
55
  ```
56
56
 
57
57
  ## Quickstart
@@ -73,9 +73,12 @@ AllCops:
73
73
  # cache location is secure from this kind of attack, and wish to use a
74
74
  # symlinked cache location, set this value to "true".
75
75
  AllowSymlinksInCacheRootDirectory: false
76
- # What version of the Ruby interpreter is the inspected code intended to
76
+ # What MRI version of the Ruby interpreter is the inspected code intended to
77
77
  # run on? (If there is more than one, set this to the lowest version.)
78
- TargetRubyVersion: 2.0
78
+ # If a value is specified for TargetRubyVersion then it is used.
79
+ # Else if .ruby-version exists and it contains an MRI version it is used.
80
+ # Otherwise we fallback to the oldest officially supported Ruby version (2.0).
81
+ TargetRubyVersion: ~
79
82
 
80
83
  # Indent private/protected/public as deep as method definitions
81
84
  Style/AccessModifierIndentation:
@@ -7,7 +7,7 @@ module RuboCop
7
7
  class CommentConfig
8
8
  UNNEEDED_DISABLE = 'Lint/UnneededDisable'.freeze
9
9
 
10
- COP_NAME_PATTERN = '([A-Z][a-z]+/)?(?:[A-Z][a-z]+)+'.freeze
10
+ COP_NAME_PATTERN = '([A-Z]\w+/)?(?:[A-Z]\w+)'.freeze
11
11
  COP_NAMES_PATTERN = "(?:#{COP_NAME_PATTERN} , )*#{COP_NAME_PATTERN}".freeze
12
12
  COPS_PATTERN = "(all|#{COP_NAMES_PATTERN})".freeze
13
13
 
@@ -16,6 +16,8 @@ module RuboCop
16
16
 
17
17
  COMMON_PARAMS = %w(Exclude Include Severity
18
18
  AutoCorrect StyleGuide Details).freeze
19
+ # 2.0 is the oldest officially supported Ruby version.
20
+ DEFAULT_RUBY_VERSION = 2.0
19
21
  KNOWN_RUBIES = [1.9, 2.0, 2.1, 2.2, 2.3].freeze
20
22
  OBSOLETE_COPS = {
21
23
  'Style/TrailingComma' =>
@@ -196,14 +198,18 @@ module RuboCop
196
198
 
197
199
  def target_ruby_version
198
200
  @target_ruby_version ||=
199
- if File.file?('.ruby-version')
200
- @target_ruby_version_source = :dot_ruby_version
201
-
202
- File.read('.ruby-version').to_f
203
- else
201
+ if for_all_cops['TargetRubyVersion']
204
202
  @target_ruby_version_source = :rubocop_yml
205
203
 
206
204
  for_all_cops['TargetRubyVersion']
205
+ elsif File.file?('.ruby-version') &&
206
+ /\A(ruby-)?(?<version>\d+\.\d+)/ =~ File.read('.ruby-version')
207
+
208
+ @target_ruby_version_source = :dot_ruby_version
209
+
210
+ version.to_f
211
+ else
212
+ DEFAULT_RUBY_VERSION
207
213
  end
208
214
  end
209
215
 
@@ -39,17 +39,26 @@ module RuboCop
39
39
  end
40
40
 
41
41
  rescue_group_rescues_multiple_levels = rescued_groups.any? do |group|
42
- !contains_multiple_levels_of_exceptions?(group)
42
+ contains_multiple_levels_of_exceptions?(group)
43
43
  end
44
44
 
45
- return if rescue_group_rescues_multiple_levels &&
45
+ return if !rescue_group_rescues_multiple_levels &&
46
46
  rescued_groups == sort_rescued_groups(rescued_groups)
47
47
 
48
- add_offense(node, :expression)
48
+ add_offense(node, offense_range(node, rescues))
49
49
  end
50
50
 
51
51
  private
52
52
 
53
+ def offense_range(node, rescues)
54
+ first_rescue = rescues.first
55
+ last_rescue = rescues.last
56
+ last_exceptions, = *last_rescue
57
+ Parser::Source::Range.new(node.loc.expression.source_buffer,
58
+ first_rescue.loc.expression.begin_pos,
59
+ last_exceptions.loc.expression.end_pos)
60
+ end
61
+
53
62
  def rescue_modifier?(node)
54
63
  node && node.rescue_type? &&
55
64
  (node.parent.nil? || !(node.parent.kwbegin_type? ||
@@ -69,8 +78,7 @@ module RuboCop
69
78
 
70
79
  def evaluate_exceptions(rescue_group)
71
80
  if rescue_group
72
- rescued_exceptions = rescue_group.source.delete(' ').split(',')
73
-
81
+ rescued_exceptions = rescued_exceptions(rescue_group)
74
82
  rescued_exceptions.each_with_object([]) do |exception, converted|
75
83
  begin
76
84
  converted << instance_eval(exception, __FILE__, __LINE__)
@@ -89,6 +97,21 @@ module RuboCop
89
97
  x <=> y || 0
90
98
  end
91
99
  end
100
+
101
+ # @param [RuboCop::Node] rescue_group is a node of array_type
102
+ def rescued_exceptions(rescue_group)
103
+ klasses = *rescue_group
104
+ klasses.map do |klass|
105
+ # `rescue nil` is valid syntax in all versions of Ruby. In Ruby
106
+ # 1.9.3, it effectively disables the `rescue`. In versions
107
+ # after 1.9.3, a `TypeError` is thrown when the statement is
108
+ # rescued. In order to account for this, we convert `nil` to
109
+ # `NilClass`.
110
+ next 'NilClass' if klass.nil_type?
111
+ next unless klass.const_type?
112
+ klass.source
113
+ end.compact
114
+ end
92
115
  end
93
116
  end
94
117
  end
@@ -31,27 +31,34 @@ module RuboCop
31
31
 
32
32
  def autocorrect(args)
33
33
  lambda do |corrector|
34
- ranges, range = *args # ranges are sorted by position
34
+ ranges, range = *args # Ranges are sorted by position.
35
35
 
36
36
  if range.source.start_with?('#')
37
- # eat the entire comment and following newline
38
- corrector.remove(range_with_surrounding_space(range, :right))
37
+ # Eat the entire comment, the preceding space, and the preceding
38
+ # newline if there is one.
39
+ original_begin = range.begin_pos
40
+ range = range_with_surrounding_space(range, :left, true)
41
+ range = range_with_surrounding_space(range, :right,
42
+ # Special for a comment that
43
+ # begins the file: remove
44
+ # the newline at the end.
45
+ original_begin == 0)
39
46
  else
40
- # is there any cop between this one and the end of the line, which
47
+ # Is there any cop between this one and the end of the line, which
41
48
  # is NOT being removed?
42
49
 
43
50
  if ends_its_line?(ranges.last) && trailing_range?(ranges, range)
44
- # eat the comma on the left
51
+ # Eat the comma on the left.
45
52
  range = range_with_surrounding_space(range, :left)
46
53
  range = range_with_surrounding_comma(range, :left)
47
54
  end
48
55
 
49
56
  range = range_with_surrounding_comma(range, :right)
50
- # eat following spaces up to EOL, but not the newline itself
57
+ # Eat following spaces up to EOL, but not the newline itself.
51
58
  range = range_with_surrounding_space(range, :right, false)
52
-
53
- corrector.remove(range)
54
59
  end
60
+
61
+ corrector.remove(range)
55
62
  end
56
63
  end
57
64
 
@@ -36,8 +36,9 @@ module RuboCop
36
36
  line_nos.each do |lineno|
37
37
  next if comment_lines.include?(lineno + 1)
38
38
  line = processed_source.lines[lineno]
39
- next if line =~ /\A\s*\Z/
40
- next if indent && indent != (line =~ /\S/)
39
+ index = line =~ /\S/
40
+ next unless index
41
+ next if indent && indent != index
41
42
  return yield(range, line)
42
43
  end
43
44
  false
@@ -85,7 +85,7 @@ module RuboCop
85
85
  new_source << args.map(&:source).join(', ')
86
86
  end
87
87
 
88
- new_source << CLOSE_PAREN if parentheses?(node)
88
+ new_source << CLOSE_PAREN if parentheses?(node) && !args.empty?
89
89
  ->(corrector) { corrector.replace(node.source_range, new_source) }
90
90
  end
91
91
  end
@@ -49,18 +49,22 @@ module RuboCop
49
49
  first_source = interpret_string_escapes(first_source)
50
50
  end
51
51
 
52
- replacement_method = replacement_method(method,
53
- first_source,
54
- second_source)
52
+ replacement_method =
53
+ replacement_method(method, first_source, second_source)
54
+
55
+ replace_method(node, first_source, second_source, first_param,
56
+ replacement_method)
57
+ end
55
58
 
59
+ def replace_method(node, first, second, first_param, replacement)
56
60
  lambda do |corrector|
57
- corrector.replace(node.loc.selector, replacement_method)
61
+ corrector.replace(node.loc.selector, replacement)
58
62
  unless first_param.str_type?
59
63
  corrector.replace(first_param.source_range,
60
- to_string_literal(first_source))
64
+ to_string_literal(first))
61
65
  end
62
66
 
63
- if second_source.empty? && first_source.length == 1
67
+ if second.empty? && first.length == 1
64
68
  remove_second_param(corrector, node, first_param)
65
69
  end
66
70
  end
@@ -27,8 +27,8 @@ module RuboCop
27
27
  # safe_join(out)
28
28
  #
29
29
  class OutputSafety < Cop
30
- MSG = 'Tagging a string as html safe may be a security risk, \
31
- prefer `safe_join` or other Rails tag helpers instead'.freeze
30
+ MSG = 'Tagging a string as html safe may be a security risk, ' \
31
+ 'prefer `safe_join` or other Rails tag helpers instead'.freeze
32
32
 
33
33
  def on_send(node)
34
34
  receiver, method_name, *_args = *node
@@ -151,7 +151,11 @@ module RuboCop
151
151
  end
152
152
 
153
153
  def good_methods
154
- style == :strict ? [:zone] : [:zone, :current] + ACCEPTED_METHODS
154
+ if style == :strict
155
+ [:zone, :zone_default]
156
+ else
157
+ [:zone, :zone_default, :current] + ACCEPTED_METHODS
158
+ end
155
159
  end
156
160
 
157
161
  def acceptable_methods(klass, method_name, node)
@@ -11,9 +11,29 @@ module RuboCop
11
11
 
12
12
  def investigate(processed_source)
13
13
  processed_source.comments.each do |comment|
14
- add_offense(comment, :expression) unless comment.text.ascii_only?
14
+ unless comment.text.ascii_only?
15
+ add_offense(comment, first_offense_range(comment))
16
+ end
15
17
  end
16
18
  end
19
+
20
+ private
21
+
22
+ def first_offense_range(comment)
23
+ expression = comment.loc.expression
24
+ first_offense = first_non_ascii_chars(comment.text)
25
+
26
+ start_position = expression.begin_pos +
27
+ comment.text.index(first_offense)
28
+ end_position = start_position + first_offense.length
29
+
30
+ Parser::Source::Range.new(comment.loc.expression.source_buffer,
31
+ start_position, end_position)
32
+ end
33
+
34
+ def first_non_ascii_chars(string)
35
+ string.match(/[^[:ascii:]]+/).to_s
36
+ end
17
37
  end
18
38
  end
19
39
  end
@@ -9,11 +9,29 @@ module RuboCop
9
9
  MSG = 'Use only ascii symbols in identifiers.'.freeze
10
10
 
11
11
  def investigate(processed_source)
12
- processed_source.tokens.each do |t|
13
- next unless t.type == :tIDENTIFIER && !t.text.ascii_only?
14
- add_offense(nil, t.pos)
12
+ processed_source.tokens.each do |token|
13
+ next unless token.type == :tIDENTIFIER && !token.text.ascii_only?
14
+ add_offense(token, first_offense_range(token))
15
15
  end
16
16
  end
17
+
18
+ private
19
+
20
+ def first_offense_range(identifier)
21
+ expression = identifier.pos
22
+ first_offense = first_non_ascii_chars(identifier.text)
23
+
24
+ start_position = expression.begin_pos +
25
+ identifier.text.index(first_offense)
26
+ end_position = start_position + first_offense.length
27
+
28
+ Parser::Source::Range.new(identifier.pos.source_buffer,
29
+ start_position, end_position)
30
+ end
31
+
32
+ def first_non_ascii_chars(string)
33
+ string.match(/[^[:ascii:]]+/).to_s
34
+ end
17
35
  end
18
36
  end
19
37
  end
@@ -6,7 +6,7 @@ module RuboCop
6
6
  module Style
7
7
  # Check for uses of braces or do/end around single line or
8
8
  # multi-line blocks.
9
- class BlockDelimiters < Cop
9
+ class BlockDelimiters < Cop # rubocop:disable Metrics/ClassLength
10
10
  include ConfigurableEnforcedStyle
11
11
 
12
12
  def on_send(node)
@@ -79,9 +79,11 @@ module RuboCop
79
79
  if b.is?('{')
80
80
  corrector.insert_before(b, ' ') unless whitespace_before?(b)
81
81
  corrector.insert_before(e, ' ') unless whitespace_before?(e)
82
+ corrector.insert_after(b, ' ') unless whitespace_after?(b)
82
83
  corrector.replace(b, 'do')
83
84
  corrector.replace(e, 'end')
84
85
  else
86
+ corrector.insert_after(b, ' ') unless whitespace_after?(b, 2)
85
87
  corrector.replace(b, '{')
86
88
  corrector.replace(e, '}')
87
89
  end
@@ -92,6 +94,10 @@ module RuboCop
92
94
  node.source_buffer.source[node.begin_pos - 1, 1] =~ /\s/
93
95
  end
94
96
 
97
+ def whitespace_after?(node, length = 1)
98
+ node.source_buffer.source[node.begin_pos + length, 1] =~ /\s/
99
+ end
100
+
95
101
  def get_blocks(node, &block)
96
102
  case node.type
97
103
  when :block
@@ -37,10 +37,6 @@ module RuboCop
37
37
  _receiver, method_name, *_args = *node
38
38
 
39
39
  node.each_ancestor(*ASGN_NODES).any? do |asgn_node|
40
- if asgn_node.masgn_type?
41
- mlhs_node, _mrhs_node = *asgn_node
42
- asgn_node = mlhs_node.children[node.sibling_index]
43
- end
44
40
  # `obj.method = value` parses as (send ... :method= ...), and will
45
41
  # not be returned as an `asgn_node` here
46
42
  # however, `obj.method ||= value` parses as (or-asgn (send ...) ...)
@@ -50,6 +46,14 @@ module RuboCop
50
46
  return false if asgn_node.send_type?
51
47
  end
52
48
 
49
+ if asgn_node.masgn_type?
50
+ mlhs_node, _mrhs_node = *asgn_node
51
+ var_nodes = *mlhs_node
52
+ vars = var_nodes.map { |n| (_b = *n).first }
53
+
54
+ return vars.include?(method_name)
55
+ end
56
+
53
57
  asgn_node.loc.name.source == method_name.to_s
54
58
  end
55
59
  end
@@ -75,7 +75,12 @@ module RuboCop
75
75
  def correction_compact_to_exploded(node)
76
76
  exception_node, _new, message_node = *node.first
77
77
 
78
- "#{exception_node.const_name}, #{message_node.source}"
78
+ message = message_node && message_node.source
79
+
80
+ correction = exception_node.const_name.to_s
81
+ correction = "#{correction}, #{message}" if message
82
+
83
+ correction
79
84
  end
80
85
 
81
86
  def correction_exploded_to_compact(node)
@@ -76,23 +76,7 @@ module RuboCop
76
76
  global_var, = *node
77
77
 
78
78
  if style == :use_english_names
79
- regular, english = ENGLISH_VARS[global_var].partition do |var|
80
- NON_ENGLISH_VARS.include? var
81
- end
82
-
83
- # For now, we assume that lists are 2 items or less. Easy grammar!
84
- regular_msg = regular.join('` or `')
85
- english_msg = english.join('` or `')
86
-
87
- if !regular.empty? && !english.empty?
88
- format(MSG_BOTH, english_msg, regular_msg, global_var)
89
- elsif !regular.empty?
90
- format(MSG_REGULAR, regular_msg, global_var)
91
- elsif !english.empty?
92
- format(MSG_ENGLISH, english_msg, global_var)
93
- else
94
- raise 'Bug in SpecialGlobalVars - global var w/o preferred vars!'
95
- end
79
+ format_english_message(global_var)
96
80
  else
97
81
  format(MSG_REGULAR, preferred_names(global_var).first, global_var)
98
82
  end
@@ -113,6 +97,32 @@ module RuboCop
113
97
 
114
98
  private
115
99
 
100
+ def format_english_message(global_var)
101
+ regular, english = ENGLISH_VARS[global_var].partition do |var|
102
+ NON_ENGLISH_VARS.include? var
103
+ end
104
+
105
+ format_message(english, regular, global_var)
106
+ end
107
+
108
+ def format_message(english, regular, global_var)
109
+ if !regular.empty? && !english.empty?
110
+ format(MSG_BOTH, format_list(english), format_list(regular),
111
+ global_var)
112
+ elsif !regular.empty?
113
+ format(MSG_REGULAR, format_list(regular), global_var)
114
+ elsif !english.empty?
115
+ format(MSG_ENGLISH, format_list(english), global_var)
116
+ else
117
+ raise 'Bug in SpecialGlobalVars - global var w/o preferred vars!'
118
+ end
119
+ end
120
+
121
+ # For now, we assume that lists are 2 items or less. Easy grammar!
122
+ def format_list(items)
123
+ items.join('` or `')
124
+ end
125
+
116
126
  def replacement(node, global_var)
117
127
  parent_type = node.parent && node.parent.type
118
128
  preferred_name = preferred_names(global_var).first
@@ -14,7 +14,7 @@ module RuboCop
14
14
 
15
15
  # discard ternary ops and modifier if/unless nodes
16
16
  return unless loc.respond_to?(:keyword) && loc.respond_to?(:else)
17
- return unless loc.keyword.is?('unless') && loc.else
17
+ return unless loc.keyword.is?('unless'.freeze) && loc.else
18
18
 
19
19
  add_offense(node, :expression)
20
20
  end
@@ -70,6 +70,24 @@ module RuboCop
70
70
  end
71
71
  end
72
72
 
73
+ def autocorrect(buffer, cops)
74
+ @updated_source_file = false
75
+ return unless autocorrect?
76
+
77
+ new_source = autocorrect_all_cops(buffer, cops)
78
+
79
+ return if new_source == buffer.source
80
+
81
+ if @options[:stdin]
82
+ # holds source read in from stdin, when --stdin option is used
83
+ @options[:stdin] = new_source
84
+ else
85
+ filename = buffer.name
86
+ File.open(filename, 'wb') { |f| f.write(new_source) }
87
+ end
88
+ @updated_source_file = true
89
+ end
90
+
73
91
  private
74
92
 
75
93
  def offenses(processed_source)
@@ -111,24 +129,6 @@ module RuboCop
111
129
  (@options[:only] || []).include?(cop_class.cop_name)
112
130
  end
113
131
 
114
- def autocorrect(buffer, cops)
115
- @updated_source_file = false
116
- return unless autocorrect?
117
-
118
- new_source = autocorrect_all_cops(buffer, cops)
119
-
120
- return if new_source == buffer.source
121
-
122
- if @options[:stdin]
123
- # holds source read in from stdin, when --stdin option is used
124
- @options[:stdin] = new_source
125
- else
126
- filename = buffer.name
127
- File.open(filename, 'wb') { |f| f.write(new_source) }
128
- end
129
- @updated_source_file = true
130
- end
131
-
132
132
  def autocorrect_all_cops(buffer, cops)
133
133
  corrector = Corrector.new(buffer)
134
134
  skip = Set.new
@@ -25,7 +25,7 @@ module RuboCop
25
25
 
26
26
  # Match literal regex characters, not including anchors, character
27
27
  # classes, alternatives, groups, repetitions, references, etc
28
- LITERAL_REGEX = /[\w\s\-,"'!#%&<>=;:`~]|\\[^AbBdDgGkwWszZS0-9]/
28
+ LITERAL_REGEX = /[\w\s\-,"'!#%&<>=;:`~]|\\[^AbBdDgGhHkpPRwWXsSzZS0-9]/
29
29
 
30
30
  module_function
31
31
 
@@ -151,7 +151,7 @@ module RuboCop
151
151
  def move_pos(src, pos, step, condition, regexp)
152
152
  offset = step == -1 ? -1 : 0
153
153
  pos += step while condition && src[pos + offset] =~ regexp
154
- pos
154
+ pos < 0 ? 0 : pos
155
155
  end
156
156
 
157
157
  def directions(side)
@@ -177,28 +177,42 @@ module RuboCop
177
177
  end
178
178
 
179
179
  def compile_seq_terms(tokens, cur_node)
180
- terms = []
180
+ terms, size =
181
+ compile_seq_terms_with_size(tokens, cur_node) do |token, terms, index|
182
+ case token
183
+ when '...'.freeze
184
+ return compile_ellipsis(tokens, cur_node, terms, index)
185
+ when '$...'.freeze
186
+ return compile_capt_ellip(tokens, cur_node, terms, index)
187
+ end
188
+ end
189
+
190
+ terms << "(#{cur_node}.children.size == #{size})"
191
+ end
192
+
193
+ def compile_seq_terms_with_size(tokens, cur_node)
181
194
  index = nil
195
+ terms = []
182
196
  until tokens.first == ')'
183
- if tokens.first == '...'
184
- return compile_ellipsis(tokens, cur_node, terms, index || 0)
185
- elsif tokens.first == '$...'
186
- return compile_capt_ellip(tokens, cur_node, terms, index || 0)
187
- elsif index.nil?
188
- # in 'sequence head' position; some expressions are compiled
189
- # differently at 'sequence head' (notably 'node type' expressions)
190
- # grep for seq_head to see where it makes a difference
191
- terms << compile_expr(tokens, cur_node, true)
192
- index = 0
193
- else
194
- child_node = "#{cur_node}.children[#{index}]"
195
- terms << compile_expr(tokens, child_node, false)
196
- index += 1
197
- end
197
+ yield tokens.first, terms, index || 0
198
+ term, index = compile_expr_with_index(tokens, cur_node, index)
199
+ terms << term
198
200
  end
199
- terms << "(#{cur_node}.children.size == #{index})"
201
+
200
202
  tokens.shift # drop concluding )
201
- terms
203
+ [terms, index]
204
+ end
205
+
206
+ def compile_expr_with_index(tokens, cur_node, index)
207
+ if index.nil?
208
+ # in 'sequence head' position; some expressions are compiled
209
+ # differently at 'sequence head' (notably 'node type' expressions)
210
+ # grep for seq_head to see where it makes a difference
211
+ [compile_expr(tokens, cur_node, true), 0]
212
+ else
213
+ child_node = "#{cur_node}.children[#{index}]"
214
+ [compile_expr(tokens, child_node, false), index + 1]
215
+ end
202
216
  end
203
217
 
204
218
  def compile_ellipsis(tokens, cur_node, terms, index)
@@ -103,7 +103,7 @@ module RuboCop
103
103
  @tokens = tokens.map { |t| Token.from_parser_token(t) } if tokens
104
104
  end
105
105
 
106
- def parser_class(ruby_version)
106
+ def parser_class(ruby_version) # rubocop:disable Metrics/MethodLength
107
107
  case ruby_version
108
108
  when 1.9
109
109
  require 'parser/ruby19'
@@ -107,13 +107,20 @@ module RuboCop
107
107
  if cop.relevant_file?(file)
108
108
  cop.check(offenses, source.disabled_line_ranges, source.comments)
109
109
  offenses += cop.offenses
110
+ autocorrect_unneeded_disables(source, cop)
110
111
  end
111
112
  end
113
+ offenses
112
114
  end
113
115
 
114
116
  offenses.sort.reject(&:disabled?).freeze
115
117
  end
116
118
 
119
+ def autocorrect_unneeded_disables(source, cop)
120
+ cop.processed_source = source
121
+ Cop::Team.new([], nil, @options).autocorrect(source.buffer, [cop])
122
+ end
123
+
117
124
  def file_started(file)
118
125
  formatter_set.file_started(file,
119
126
  cli_options: @options,
@@ -4,7 +4,7 @@
4
4
  module RuboCop
5
5
  # This module holds the RuboCop version information.
6
6
  module Version
7
- STRING = '0.41.1'.freeze
7
+ STRING = '0.41.2'.freeze
8
8
 
9
9
  MSG = '%s (using Parser %s, running on %s %s %s)'.freeze
10
10
 
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.41.1
4
+ version: 0.41.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-06-26 00:00:00.000000000 Z
13
+ date: 2016-07-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rainbow
@@ -555,7 +555,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
555
555
  version: '0'
556
556
  requirements: []
557
557
  rubyforge_project:
558
- rubygems_version: 2.2.2
558
+ rubygems_version: 2.4.5
559
559
  signing_key:
560
560
  specification_version: 4
561
561
  summary: Automatic Ruby code style checking tool.