rubocop 0.21.0 → 0.22.0

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.

Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/{rubocop-todo.yml → .rubocop_todo.yml} +5 -5
  4. data/CHANGELOG.md +41 -0
  5. data/README.md +21 -11
  6. data/config/default.yml +33 -10
  7. data/config/disabled.yml +0 -4
  8. data/config/enabled.yml +27 -1
  9. data/lib/rubocop.rb +17 -1
  10. data/lib/rubocop/config.rb +32 -27
  11. data/lib/rubocop/config_loader.rb +21 -8
  12. data/lib/rubocop/cop/cop.rb +8 -8
  13. data/lib/rubocop/cop/lint/block_alignment.rb +22 -22
  14. data/lib/rubocop/cop/lint/condition_position.rb +3 -5
  15. data/lib/rubocop/cop/lint/debugger.rb +4 -5
  16. data/lib/rubocop/cop/lint/end_alignment.rb +11 -10
  17. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +10 -11
  18. data/lib/rubocop/cop/lint/require_parentheses.rb +7 -7
  19. data/lib/rubocop/cop/lint/rescue_exception.rb +3 -3
  20. data/lib/rubocop/cop/lint/string_conversion_in_interpolation.rb +6 -7
  21. data/lib/rubocop/cop/lint/unreachable_code.rb +2 -3
  22. data/lib/rubocop/cop/lint/unused_block_argument.rb +2 -15
  23. data/lib/rubocop/cop/lint/unused_method_argument.rb +2 -14
  24. data/lib/rubocop/cop/lint/useless_comparison.rb +4 -5
  25. data/lib/rubocop/cop/lint/void.rb +6 -8
  26. data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +4 -2
  27. data/lib/rubocop/cop/mixin/autocorrect_unless_changing_ast.rb +1 -3
  28. data/lib/rubocop/cop/mixin/code_length.rb +5 -5
  29. data/lib/rubocop/cop/mixin/negative_conditional.rb +6 -6
  30. data/lib/rubocop/cop/mixin/percent_literal.rb +2 -3
  31. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +5 -5
  32. data/lib/rubocop/cop/mixin/space_inside.rb +10 -11
  33. data/lib/rubocop/cop/mixin/unused_argument.rb +35 -0
  34. data/lib/rubocop/cop/offense.rb +1 -1
  35. data/lib/rubocop/cop/rails/action_filter.rb +6 -8
  36. data/lib/rubocop/cop/rails/default_scope.rb +2 -4
  37. data/lib/rubocop/cop/rails/delegate.rb +2 -0
  38. data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +2 -3
  39. data/lib/rubocop/cop/rails/output.rb +2 -3
  40. data/lib/rubocop/cop/rails/read_write_attribute.rb +3 -4
  41. data/lib/rubocop/cop/rails/validation.rb +2 -3
  42. data/lib/rubocop/cop/style/alias.rb +3 -3
  43. data/lib/rubocop/cop/style/align_hash.rb +4 -4
  44. data/lib/rubocop/cop/style/align_parameters.rb +13 -1
  45. data/lib/rubocop/cop/style/and_or.rb +2 -5
  46. data/lib/rubocop/cop/style/array_join.rb +3 -4
  47. data/lib/rubocop/cop/style/ascii_identifiers.rb +2 -3
  48. data/lib/rubocop/cop/style/block_comments.rb +2 -3
  49. data/lib/rubocop/cop/style/block_nesting.rb +2 -3
  50. data/lib/rubocop/cop/style/blocks.rb +9 -9
  51. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +5 -5
  52. data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
  53. data/lib/rubocop/cop/style/class_methods.rb +3 -5
  54. data/lib/rubocop/cop/style/collection_methods.rb +8 -11
  55. data/lib/rubocop/cop/style/comment_annotation.rb +9 -9
  56. data/lib/rubocop/cop/style/comment_indentation.rb +66 -0
  57. data/lib/rubocop/cop/style/constant_name.rb +3 -3
  58. data/lib/rubocop/cop/style/cyclomatic_complexity.rb +5 -5
  59. data/lib/rubocop/cop/style/deprecated_hash_methods.rb +6 -6
  60. data/lib/rubocop/cop/style/each_with_object.rb +38 -0
  61. data/lib/rubocop/cop/style/empty_lines.rb +8 -8
  62. data/lib/rubocop/cop/style/empty_lines_around_body.rb +7 -7
  63. data/lib/rubocop/cop/style/encoding.rb +6 -7
  64. data/lib/rubocop/cop/style/end_of_line.rb +10 -10
  65. data/lib/rubocop/cop/style/file_name.rb +11 -7
  66. data/lib/rubocop/cop/style/guard_clause.rb +32 -22
  67. data/lib/rubocop/cop/style/indentation_width.rb +25 -26
  68. data/lib/rubocop/cop/style/lambda.rb +8 -9
  69. data/lib/rubocop/cop/style/leading_comment_space.rb +4 -5
  70. data/lib/rubocop/cop/style/line_end_concatenation.rb +29 -6
  71. data/lib/rubocop/cop/style/line_length.rb +9 -9
  72. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +7 -6
  73. data/lib/rubocop/cop/style/module_function.rb +3 -4
  74. data/lib/rubocop/cop/style/multiline_if_then.rb +3 -3
  75. data/lib/rubocop/cop/style/negated_if.rb +2 -0
  76. data/lib/rubocop/cop/style/next.rb +80 -0
  77. data/lib/rubocop/cop/style/nil_comparison.rb +2 -3
  78. data/lib/rubocop/cop/style/non_nil_check.rb +15 -3
  79. data/lib/rubocop/cop/style/not.rb +4 -4
  80. data/lib/rubocop/cop/style/numeric_literals.rb +7 -8
  81. data/lib/rubocop/cop/style/op_method.rb +3 -5
  82. data/lib/rubocop/cop/style/parameter_lists.rb +4 -4
  83. data/lib/rubocop/cop/style/parentheses_around_condition.rb +5 -6
  84. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +5 -5
  85. data/lib/rubocop/cop/style/predicate_name.rb +2 -4
  86. data/lib/rubocop/cop/style/redundant_self.rb +11 -12
  87. data/lib/rubocop/cop/style/self_assignment.rb +8 -13
  88. data/lib/rubocop/cop/style/semicolon.rb +16 -19
  89. data/lib/rubocop/cop/style/signal_exception.rb +10 -11
  90. data/lib/rubocop/cop/style/single_line_block_params.rb +2 -3
  91. data/lib/rubocop/cop/style/single_line_methods.rb +3 -4
  92. data/lib/rubocop/cop/style/space_after_colon.rb +9 -9
  93. data/lib/rubocop/cop/style/space_after_control_keyword.rb +3 -3
  94. data/lib/rubocop/cop/style/space_after_method_name.rb +3 -3
  95. data/lib/rubocop/cop/style/space_after_not.rb +3 -4
  96. data/lib/rubocop/cop/style/space_around_operators.rb +5 -4
  97. data/lib/rubocop/cop/style/space_before_comment.rb +29 -0
  98. data/lib/rubocop/cop/style/space_before_modifier_keyword.rb +6 -7
  99. data/lib/rubocop/cop/style/symbol_array.rb +2 -3
  100. data/lib/rubocop/cop/style/tab.rb +8 -8
  101. data/lib/rubocop/cop/style/trailing_blank_lines.rb +10 -10
  102. data/lib/rubocop/cop/style/trailing_whitespace.rb +6 -7
  103. data/lib/rubocop/cop/style/trivial_accessors.rb +3 -4
  104. data/lib/rubocop/cop/style/unless_else.rb +2 -3
  105. data/lib/rubocop/cop/style/unneeded_capital_w.rb +3 -3
  106. data/lib/rubocop/cop/style/unneeded_percent_x.rb +26 -0
  107. data/lib/rubocop/cop/style/when_then.rb +3 -3
  108. data/lib/rubocop/cop/style/while_until_do.rb +3 -6
  109. data/lib/rubocop/cop/style/word_array.rb +8 -7
  110. data/lib/rubocop/cop/team.rb +9 -11
  111. data/lib/rubocop/cop/util.rb +2 -3
  112. data/lib/rubocop/cop/variable_force.rb +2 -3
  113. data/lib/rubocop/cop/variable_force/variable_table.rb +1 -2
  114. data/lib/rubocop/file_inspector.rb +5 -0
  115. data/lib/rubocop/formatter/clang_style_formatter.rb +3 -4
  116. data/lib/rubocop/formatter/disabled_config_formatter.rb +6 -6
  117. data/lib/rubocop/options.rb +14 -11
  118. data/lib/rubocop/target_finder.rb +12 -1
  119. data/lib/rubocop/version.rb +1 -1
  120. data/relnotes/v0.21.0.md +11 -0
  121. data/relnotes/v0.22.0.md +77 -0
  122. data/spec/rubocop/cli_spec.rb +86 -40
  123. data/spec/rubocop/comment_config_spec.rb +1 -1
  124. data/spec/rubocop/config_loader_spec.rb +3 -3
  125. data/spec/rubocop/config_spec.rb +14 -3
  126. data/spec/rubocop/cop/force_spec.rb +1 -1
  127. data/spec/rubocop/cop/lint/unused_block_argument_spec.rb +164 -99
  128. data/spec/rubocop/cop/lint/unused_method_argument_spec.rb +195 -85
  129. data/spec/rubocop/cop/lint/void_spec.rb +8 -0
  130. data/spec/rubocop/cop/rails/delegate_spec.rb +17 -0
  131. data/spec/rubocop/cop/rails/output_spec.rb +3 -3
  132. data/spec/rubocop/cop/severity_spec.rb +5 -5
  133. data/spec/rubocop/cop/style/align_parameters_spec.rb +108 -0
  134. data/spec/rubocop/cop/style/block_nesting_spec.rb +3 -3
  135. data/spec/rubocop/cop/style/class_and_module_children_spec.rb +12 -10
  136. data/spec/rubocop/cop/style/comment_indentation_spec.rb +174 -0
  137. data/spec/rubocop/cop/style/each_with_object_spec.rb +44 -0
  138. data/spec/rubocop/cop/style/end_of_line_spec.rb +3 -5
  139. data/spec/rubocop/cop/style/guard_clause_spec.rb +135 -57
  140. data/spec/rubocop/cop/style/if_unless_modifier_spec.rb +7 -7
  141. data/spec/rubocop/cop/style/line_end_concatenation_spec.rb +75 -1
  142. data/spec/rubocop/cop/style/line_length_spec.rb +7 -7
  143. data/spec/rubocop/cop/style/negated_if_spec.rb +5 -1
  144. data/spec/rubocop/cop/style/next_spec.rb +210 -0
  145. data/spec/rubocop/cop/style/non_nil_check_spec.rb +44 -13
  146. data/spec/rubocop/cop/style/self_assignment_spec.rb +1 -1
  147. data/spec/rubocop/cop/style/space_around_operators_spec.rb +1 -0
  148. data/spec/rubocop/cop/style/space_before_comment_spec.rb +34 -0
  149. data/spec/rubocop/cop/style/unneeded_percent_x_spec.rb +34 -0
  150. data/spec/rubocop/cop/style/while_until_modifier_spec.rb +2 -2
  151. data/spec/rubocop/cop/util_spec.rb +2 -2
  152. data/spec/rubocop/cop/variable_force_spec.rb +1 -1
  153. data/spec/rubocop/formatter/disabled_config_formatter_spec.rb +4 -4
  154. data/spec/rubocop/formatter/disabled_lines_formatter_spec.rb +2 -2
  155. data/spec/rubocop/formatter/offense_count_formatter_spec.rb +2 -2
  156. data/spec/rubocop/options_spec.rb +3 -0
  157. data/spec/support/shared_context.rb +1 -3
  158. data/spec/support/statement_modifier_helper.rb +2 -2
  159. metadata +20 -3
@@ -18,10 +18,9 @@ module Rubocop
18
18
  elsif trivial_writer?(method_name, args, body)
19
19
  'writer'
20
20
  end
21
- if kind
22
- add_offense(node, :keyword,
23
- format(MSG, kind, kind))
24
- end
21
+ return unless kind
22
+
23
+ add_offense(node, :keyword, format(MSG, kind, kind))
25
24
  end
26
25
 
27
26
  def exact_name_match?
@@ -13,10 +13,9 @@ module Rubocop
13
13
 
14
14
  # discard ternary ops and modifier if/unless nodes
15
15
  return unless loc.respond_to?(:keyword) && loc.respond_to?(:else)
16
+ return unless loc.keyword.is?('unless') && loc.else
16
17
 
17
- if loc.keyword.is?('unless') && loc.else
18
- add_offense(node, :expression)
19
- end
18
+ add_offense(node, :expression)
20
19
  end
21
20
  end
22
21
  end
@@ -18,10 +18,10 @@ module Rubocop
18
18
 
19
19
  def on_percent_literal(node, types)
20
20
  type = type(node)
21
- if types.include?(type) &&
21
+ return unless types.include?(type) &&
22
22
  node.children.none? { |x| x.type == :dstr }
23
- add_offense(node, :expression)
24
- end
23
+
24
+ add_offense(node, :expression)
25
25
  end
26
26
  end
27
27
  end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ module Rubocop
4
+ module Cop
5
+ module Style
6
+ # This cop checks for usage of the %x() syntax when `` would do.
7
+ class UnneededPercentX < Cop
8
+ MSG = 'Do not use `%x` unless the command string contains backquotes.'
9
+
10
+ def on_xstr(node)
11
+ add_offense(node, :expression) if node.loc.expression.source !~ /`/
12
+ end
13
+
14
+ private
15
+
16
+ def autocorrect(node)
17
+ string, = *node
18
+ @corrections << lambda do |corrector|
19
+ corrector.replace(node.loc.expression,
20
+ "`#{string.loc.expression.source}`")
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -8,9 +8,9 @@ module Rubocop
8
8
  MSG = 'Never use `when x;`. Use `when x then` instead.'
9
9
 
10
10
  def on_when(node)
11
- if node.loc.begin && node.loc.begin.is?(';')
12
- add_offense(node, :begin)
13
- end
11
+ return unless node.loc.begin && node.loc.begin.is?(';')
12
+
13
+ add_offense(node, :begin)
14
14
  end
15
15
 
16
16
  def autocorrect(node)
@@ -15,13 +15,10 @@ module Rubocop
15
15
 
16
16
  def handle(node)
17
17
  length = node.loc.expression.source.lines.to_a.size
18
+ return unless length > 1
19
+ return unless node.loc.begin && node.loc.begin.is?('do')
18
20
 
19
- if length > 1
20
- if node.loc.begin && node.loc.begin.is?('do')
21
- add_offense(node, :begin,
22
- error_message(node.type))
23
- end
24
- end
21
+ add_offense(node, :begin, error_message(node.type))
25
22
  end
26
23
 
27
24
  private
@@ -16,10 +16,11 @@ module Rubocop
16
16
 
17
17
  def on_array(node)
18
18
  array_elems = node.children
19
- if array_of?(:str, node) && !complex_content?(array_elems) &&
19
+ return unless array_of?(:str, node) &&
20
+ !complex_content?(array_elems) &&
20
21
  array_elems.size > min_size && !comments_in_array?(node)
21
- add_offense(node, :expression) { self.max = array_elems.size }
22
- end
22
+
23
+ add_offense(node, :expression) { self.max = array_elems.size }
23
24
  end
24
25
 
25
26
  private
@@ -41,10 +42,10 @@ module Rubocop
41
42
  def complex_content?(arr_sexp)
42
43
  arr_sexp.each do |s|
43
44
  source = s.loc.expression.source
44
- unless source.start_with?('?') # %W(\r \n) can replace [?\r, ?\n]
45
- str_content = Util.strip_quotes(source)
46
- return true unless str_content =~ /\A[\w-]+\z/
47
- end
45
+ next if source.start_with?('?') # %W(\r \n) can replace [?\r, ?\n]
46
+
47
+ str_content = Util.strip_quotes(source)
48
+ return true unless str_content =~ /\A[\w-]+\z/
48
49
  end
49
50
 
50
51
  false
@@ -43,9 +43,8 @@ module Rubocop
43
43
  def cops
44
44
  @cops ||= begin
45
45
  @cop_classes.each_with_object([]) do |cop_class, instances|
46
- if cop_enabled?(cop_class)
47
- instances << cop_class.new(@config, @options)
48
- end
46
+ next unless cop_enabled?(cop_class)
47
+ instances << cop_class.new(@config, @options)
49
48
  end
50
49
  end
51
50
  end
@@ -69,9 +68,8 @@ module Rubocop
69
68
  @updated_source_file = false
70
69
  return unless autocorrect?
71
70
 
72
- corrections = cops.reduce([]) do |array, cop|
73
- array.concat(cop.corrections)
74
- array
71
+ corrections = cops.each_with_object([]) do |cop, array|
72
+ array.concat(cop.corrections) if cop.relevant_file?(buffer.name)
75
73
  end
76
74
 
77
75
  corrector = Corrector.new(buffer, corrections)
@@ -81,11 +79,11 @@ module Rubocop
81
79
  autocorrect_one_cop(buffer, cops)
82
80
  end
83
81
 
84
- unless new_source == buffer.source
85
- filename = buffer.name
86
- File.open(filename, 'w') { |f| f.write(new_source) }
87
- @updated_source_file = true
88
- end
82
+ return if new_source == buffer.source
83
+
84
+ filename = buffer.name
85
+ File.open(filename, 'w') { |f| f.write(new_source) }
86
+ @updated_source_file = true
89
87
  end
90
88
 
91
89
  # Does a slower but safer auto-correction run by correcting for just one
@@ -116,9 +116,8 @@ module Rubocop
116
116
  return if Array(excludes).include?(sexp.type)
117
117
 
118
118
  sexp.children.each do |elem|
119
- if elem.is_a?(Parser::AST::Node)
120
- on_node(syms, elem, excludes) { |s| yield s }
121
- end
119
+ next unless elem.is_a?(Parser::AST::Node)
120
+ on_node(syms, elem, excludes) { |s| yield s }
122
121
  end
123
122
  end
124
123
 
@@ -168,9 +168,8 @@ module Rubocop
168
168
  variable_names = regexp.named_captures.keys
169
169
 
170
170
  variable_names.each do |name|
171
- unless variable_table.variable_exist?(name)
172
- variable_table.declare_variable(name, node)
173
- end
171
+ next if variable_table.variable_exist?(name)
172
+ variable_table.declare_variable(name, node)
174
173
  end
175
174
 
176
175
  process_node(rhs_node)
@@ -109,10 +109,9 @@ module Rubocop
109
109
  end
110
110
 
111
111
  def accessible_variables
112
- scope_stack.reverse_each.reduce([]) do |variables, scope|
112
+ scope_stack.reverse_each.each_with_object([]) do |scope, variables|
113
113
  variables.concat(scope.variables.values)
114
114
  break variables unless scope.node.type == :block
115
- variables
116
115
  end
117
116
  end
118
117
 
@@ -26,6 +26,7 @@ module Rubocop
26
26
  o.severity >= fail_level
27
27
  end
28
28
  inspected_files << file
29
+ break if @options[:fail_fast] && any_failed
29
30
  end
30
31
 
31
32
  formatter_set.finished(inspected_files.freeze)
@@ -65,6 +66,10 @@ module Rubocop
65
66
  # are made. This is because automatic corrections can introduce new
66
67
  # offenses. In the normal case the loop is only executed once.
67
68
  loop do
69
+ # The offenses that couldn't be corrected will be found again so we
70
+ # only keep the corrected ones in order to avoid duplicate reporting.
71
+ offenses.select!(&:corrected?)
72
+
68
73
  new_offenses, updated_source_file =
69
74
  inspect_file(processed_source, config_store)
70
75
  offenses += new_offenses.reject { |n| offenses.include?(n) }
@@ -13,11 +13,10 @@ module Rubocop
13
13
  colored_severity_code(o), message(o))
14
14
 
15
15
  source_line = o.location.source_line
16
+ next if source_line.blank?
16
17
 
17
- unless source_line.blank?
18
- output.puts(source_line)
19
- output.puts(highlight_line(o.location))
20
- end
18
+ output.puts(source_line)
19
+ output.puts(highlight_line(o.location))
21
20
  end
22
21
  end
23
22
 
@@ -53,12 +53,12 @@ module Rubocop
53
53
  end
54
54
 
55
55
  default_cfg = Rubocop::ConfigLoader.default_configuration[cop_name]
56
- if default_cfg
57
- params = default_cfg.keys - %w(Description Enabled) - cfg.keys
58
- unless params.empty?
59
- output.puts "# Configuration parameters: #{params.join(', ')}."
60
- end
61
- end
56
+ return unless default_cfg
57
+
58
+ params = default_cfg.keys - %w(Description Enabled) - cfg.keys
59
+ return if params.empty?
60
+
61
+ output.puts "# Configuration parameters: #{params.join(', ')}."
62
62
  end
63
63
  end
64
64
  end
@@ -35,6 +35,9 @@ module Rubocop
35
35
  show_cops: ['Shows the given cops, or all cops by',
36
36
  'default, and their configurations for the',
37
37
  'current directory.'],
38
+ fail_fast: ['Inspect files in order of modification',
39
+ 'time and stop after the first file',
40
+ 'containing offenses.'],
38
41
  debug: 'Display debug info.',
39
42
  display_cop_names: 'Display cop names in offense messages.',
40
43
  rails: 'Run extra Rails cops.',
@@ -126,6 +129,7 @@ module Rubocop
126
129
  end
127
130
 
128
131
  def add_boolean_flags(opts)
132
+ option(opts, '-F', '--fail-fast')
129
133
  option(opts, '-d', '--debug')
130
134
  option(opts, '-D', '--display-cop-names')
131
135
  option(opts, '-R', '--rails')
@@ -161,10 +165,10 @@ module Rubocop
161
165
  # Currently we don't make -s/--silent option raise error
162
166
  # since those are mostly used by external tools.
163
167
  rejected = args.reject! { |a| %w(-s --silent).include?(a) }
164
- if rejected
165
- warn '-s/--silent options is dropped. ' \
166
- '`emacs` and `files` formatters no longer display summary.'
167
- end
168
+ return unless rejected
169
+
170
+ warn '-s/--silent options is dropped. ' \
171
+ '`emacs` and `files` formatters no longer display summary.'
168
172
  end
169
173
 
170
174
  def convert_deprecated_options(args)
@@ -189,17 +193,16 @@ module Rubocop
189
193
 
190
194
  def validate_only_option
191
195
  @options[:only].each do |cop_to_run|
192
- if Cop::Cop.all.none? { |c| c.cop_name == cop_to_run }
193
- fail ArgumentError, "Unrecognized cop name: #{cop_to_run}."
194
- end
196
+ next unless Cop::Cop.all.none? { |c| c.cop_name == cop_to_run }
197
+ fail ArgumentError, "Unrecognized cop name: #{cop_to_run}."
195
198
  end
196
199
  end
197
200
 
198
201
  def validate_auto_gen_config_option(args)
199
- if args.any?
200
- warn '--auto-gen-config can not be combined with any other arguments.'
201
- exit(1)
202
- end
202
+ return unless args.any?
203
+
204
+ warn '--auto-gen-config can not be combined with any other arguments.'
205
+ exit(1)
203
206
  end
204
207
  end
205
208
  end
@@ -6,7 +6,11 @@ module Rubocop
6
6
  class TargetFinder
7
7
  def initialize(config_store, options = {})
8
8
  @config_store = config_store
9
- @options = { force_exclusion: false, debug: false }.merge(options)
9
+ @options = {
10
+ force_exclusion: false,
11
+ debug: false,
12
+ fail_level: false
13
+ }.merge(options)
10
14
  end
11
15
 
12
16
  def force_exclusion?
@@ -17,6 +21,10 @@ module Rubocop
17
21
  @options[:debug]
18
22
  end
19
23
 
24
+ def fail_fast?
25
+ @options[:fail_fast]
26
+ end
27
+
20
28
  # Generate a list of target files by expanding globbing patterns
21
29
  # (if any). If args is empty, recursively find all Ruby source
22
30
  # files under the current directory
@@ -61,6 +69,9 @@ module Rubocop
61
69
  @config_store.for(file).file_to_include?(file)
62
70
  end
63
71
 
72
+ # Most recently modified file first.
73
+ target_files.sort_by! { |path| -File.mtime(path).to_i } if fail_fast?
74
+
64
75
  target_files
65
76
  end
66
77
 
@@ -3,7 +3,7 @@
3
3
  module Rubocop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.21.0'
6
+ STRING = '0.22.0'
7
7
 
8
8
  MSG = '%s (using Parser %s, running on %s %s %s)'
9
9
 
data/relnotes/v0.21.0.md CHANGED
@@ -43,3 +43,14 @@ Below is the list of all the gory details. Enjoy!
43
43
  * [#993](https://github.com/bbatsov/rubocop/issues/993): Do not report any offenses for the contents of an empty file. ([@jonas054][])
44
44
  * [#1016](https://github.com/bbatsov/rubocop/issues/1016): Fix a false positive in `ConditionPosition` regarding statement modifiers. ([@bbatsov][])
45
45
  * [#1014](https://github.com/bbatsov/rubocop/issues/1014): Fix handling of strings nested in `dstr` nodes. ([@bbatsov][])
46
+
47
+ [@bbatsov]: https://github.com/bbatsov
48
+ [@jonas054]: https://github.com/jonas054
49
+ [@yujinakayama]: https://github.com/yujinakayama
50
+ [@geniou]: https://github.com/geniou
51
+ [@mockdeep]: https://github.com/mockdeep
52
+ [@tamird]: https://github.com/tamird
53
+ [@bquorning]: https://github.com/bquorning
54
+ [@bcobb]: https://github.com/bcobb
55
+ [@irrationalfab]: https://github.com/irrationalfab
56
+ [@sfeldon]: https://github.com/sfeldon
@@ -0,0 +1,77 @@
1
+ This release brings a few new cops, extended auto-correction support and plenty of bug fixes.
2
+
3
+ Below is the list of all the gory details. Enjoy!
4
+
5
+ ### New features
6
+
7
+ * [#974](https://github.com/bbatsov/rubocop/pull/974): New cop `CommentIndentation` checks indentation of comments. ([@jonas054][])
8
+ * Add new cop `EachWithObject` to prefer `each_with_object` over `inject` or `reduce`. ([@geniou][])
9
+ * [#1010](https://github.com/bbatsov/rubocop/issues/1010): New Cop `Next` check for conditions at the end of an interation and propose to use `next` instead. ([@geniou][])
10
+ * The `GuardClause` cop now also looks for unless and it is configurable how many lines the body of an if / unless needs to have to not be ignored. ([@geniou][])
11
+ * [#835](https://github.com/bbatsov/rubocop/issues/835): New cop `UnneededPercentX` checks for `%x` when backquotes would do. ([@jonas054][])
12
+ * Add auto-correct to `UnusedBlockArgument` and `UnusedMethodArgument` cops. ([@hannestyden][])
13
+ * [#1074](https://github.com/bbatsov/rubocop/issues/1074): New cop `SpaceBeforeComment` checks for missing space between code and a comment on the same line. ([@jonas054][])
14
+ * [#1089](https://github.com/bbatsov/rubocop/pull/1089): New option `-F`/`--fail-fast` inspects files in modification time order and stop after the first file with offenses. ([@jonas054][])
15
+
16
+ ### Changes
17
+
18
+ * `NonNilCheck` offense reporting and autocorrect are configurable to include semantic changes. ([@hannestyden][])
19
+ * The parameters `AllCops/Excludes` and `AllCops/Includes` with final `s` only give a warning and don't halt `rubocop` execution. ([@jonas054][])
20
+ * The `GuardClause` cop is no longer irgnoring a one-line body by default - see configuration. ([@geniou][])
21
+ * [#1050](https://github.com/bbatsov/rubocop/issues/1050): Rename `rubocop-todo.yml` file to `.rubocop_todo.yml`. ([@geniou][])
22
+ * [#1064](https://github.com/bbatsov/rubocop/issues/1064): Adjust default max line length to 80. ([@bbatsov][])
23
+
24
+ ### Bugs fixed
25
+
26
+ * Allow assignment in `AlignParameters` cop. ([@tommeier][])
27
+ * Fix `Void` and `SpaceAroundOperators` for short call syntax `lambda.()`. ([@biinari][])
28
+ * Fix `Delegate` for delegation with assignment or constant. ([@geniou][])
29
+ * [#1032](https://github.com/bbatsov/rubocop/issues/1032): Avoid duplicate reporting when code moves around due to `--auto-correct`. ([@jonas054][])
30
+ * [#1036](https://github.com/bbatsov/rubocop/issues/1036): Handle strings like `__FILE__` in `LineEndConcatenation`. ([@bbatsov][])
31
+ * [#1006](https://github.com/bbatsov/rubocop/issues/1006): Fix LineEndConcatenation to handle chained concatenations. ([@barunio][])
32
+ * [#1066](https://github.com/bbatsov/rubocop/issues/1066): Fix auto-correct for `NegatedIf` when the condition has parentheses around it. ([@jonas054][])
33
+ * Fix `AlignParameters` `with_fixed_indentation` for multi-line method calls. ([@molawson][])
34
+ * Fix problem that appears in some installations when reading empty YAML files. ([@jonas054][])
35
+ * [#1022](https://github.com/bbatsov/rubocop/issues/1022): A Cop will no longer auto-correct a file that's excluded through an `Exclude` setting in the cop's configuration. ([@jonas054][])
36
+ * Fix paths in `Exclude` config section not being recognized on Windows. ([@wndhydrnt][])
37
+ * [#1094](https://github.com/bbatsov/rubocop/issues/1094): Fix ClassAndModuleChildren for classes with a single method. ([@geniou][])
38
+
39
+ [@bbatsov]: https://github.com/bbatsov
40
+ [@jonas054]: https://github.com/jonas054
41
+ [@yujinakayama]: https://github.com/yujinakayama
42
+ [@dblock]: https://github.com/dblock
43
+ [@nevir]: https://github.com/nevir
44
+ [@daviddavis]: https://github.com/daviddavis
45
+ [@sds]: https://github.com/sds
46
+ [@fancyremarker]: https://github.com/fancyremarker
47
+ [@sinisterchipmunk]: https://github.com/sinisterchipmunk
48
+ [@vonTronje]: https://github.com/vonTronje
49
+ [@agrimm]: https://github.com/agrimm
50
+ [@pmenglund]: https://github.com/pmenglund
51
+ [@chulkilee]: https://github.com/chulkilee
52
+ [@codez]: https://github.com/codez
53
+ [@emou]: https://github.com/emou
54
+ [@skanev]: http://github.com/skanev
55
+ [@claco]: http://github.com/claco
56
+ [@rifraf]: http://github.com/rifraf
57
+ [@scottmatthewman]: https://github.com/scottmatthewman
58
+ [@ma2gedev]: http://github.com/ma2gedev
59
+ [@jeremyolliver]: https://github.com/jeremyolliver
60
+ [@hannestyden]: https://github.com/hannestyden
61
+ [@geniou]: https://github.com/geniou
62
+ [@jkogara]: https://github.com/jkogara
63
+ [@tmorris-fiksu]: https://github.com/tmorris-fiksu
64
+ [@mockdeep]: https://github.com/mockdeep
65
+ [@hiroponz]: https://github.com/hiroponz
66
+ [@tamird]: https://github.com/tamird
67
+ [@fshowalter]: https://github.com/fshowalter
68
+ [@cschramm]: https://github.com/cschramm
69
+ [@bquorning]: https://github.com/bquorning
70
+ [@bcobb]: https://github.com/bcobb
71
+ [@irrationalfab]: https://github.com/irrationalfab
72
+ [@tommeier]: https://github.com/tommeier
73
+ [@sfeldon]: https://github.com/sfeldon
74
+ [@biinari]: https://github.com/biinari
75
+ [@barunio]: https://github.com/barunio
76
+ [@molawson]: https://github.com/molawson
77
+ [@wndhydrnt]: https://github.com/wndhydrnt