Skip to content

Commit efaf1b0

Browse files
jonas054bbatsov
authored andcommitted
Auto-correct previously undiscovered offenses
The bug fix in the previous commit makes the Layout/RedundantLineBreak cop discover more offenses.
1 parent f94cd24 commit efaf1b0

36 files changed

+81
-185
lines changed

lib/rubocop/cop/bundler/duplicated_gem.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ def on_new_investigation
4646

4747
duplicated_gem_nodes.each do |nodes|
4848
nodes[1..-1].each do |node|
49-
register_offense(
50-
node,
51-
node.first_argument.to_a.first,
52-
nodes.first.first_line
53-
)
49+
register_offense(node, node.first_argument.to_a.first, nodes.first.first_line)
5450
end
5551
end
5652
end

lib/rubocop/cop/gemspec/duplicated_assignment.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ def on_new_investigation
5252

5353
duplicated_assignment_method_nodes.each do |nodes|
5454
nodes[1..-1].each do |node|
55-
register_offense(
56-
node,
57-
node.method_name,
58-
nodes.first.first_line
59-
)
55+
register_offense(node, node.method_name, nodes.first.first_line)
6056
end
6157
end
6258
end

lib/rubocop/cop/layout/indentation_width.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,7 @@ def select_check_member(member)
185185

186186
def check_members_for_indented_internal_methods_style(members)
187187
each_member(members) do |member, previous_modifier|
188-
check_indentation(previous_modifier, member,
189-
indentation_consistency_style)
188+
check_indentation(previous_modifier, member, indentation_consistency_style)
190189
end
191190
end
192191

lib/rubocop/cop/lint/syntax.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ class Syntax < Base
99
def on_other_file
1010
add_offense_from_error(processed_source.parser_error) if processed_source.parser_error
1111
processed_source.diagnostics.each do |diagnostic|
12-
add_offense_from_diagnostic(diagnostic,
13-
processed_source.ruby_version)
12+
add_offense_from_diagnostic(diagnostic, processed_source.ruby_version)
1413
end
1514
super
1615
end

lib/rubocop/cop/metrics/utils/abc_size_calculator.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ def compound_assignment(node)
101101
children = node.masgn_type? ? node.children[0].children : node.children
102102

103103
will_be_miscounted = children.count do |child|
104-
child.respond_to?(:setter_method?) &&
105-
!child.setter_method?
104+
child.respond_to?(:setter_method?) && !child.setter_method?
106105
end
107106
@assignment += will_be_miscounted
108107

lib/rubocop/cop/mixin/multiline_expression_indentation.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ def assignment_rhs(node)
196196

197197
def not_for_this_cop?(node)
198198
node.ancestors.any? do |ancestor|
199-
grouped_expression?(ancestor) ||
200-
inside_arg_list_parentheses?(node, ancestor)
199+
grouped_expression?(ancestor) || inside_arg_list_parentheses?(node, ancestor)
201200
end
202201
end
203202

lib/rubocop/cop/style/empty_case_condition.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ def on_case(case_node)
4747
branch_bodies = [*case_node.when_branches.map(&:body), case_node.else_branch].compact
4848

4949
return if branch_bodies.any? do |body|
50-
body.return_type? ||
51-
body.each_descendant.any?(&:return_type?)
50+
body.return_type? || body.each_descendant.any?(&:return_type?)
5251
end
5352

5453
add_offense(case_node.loc.keyword) { |corrector| autocorrect(corrector, case_node) }

lib/rubocop/cop/style/redundant_capital_w.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ def on_percent_literal(node)
3737

3838
def requires_interpolation?(node)
3939
node.child_nodes.any? do |string|
40-
string.dstr_type? ||
41-
double_quotes_required?(string.source)
40+
string.dstr_type? || double_quotes_required?(string.source)
4241
end
4342
end
4443
end

lib/rubocop/cop/style/ternary_parentheses.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ def infinite_loop?
184184

185185
def unsafe_autocorrect?(condition)
186186
condition.children.any? do |child|
187-
unparenthesized_method_call?(child) ||
188-
below_ternary_precedence?(child)
187+
unparenthesized_method_call?(child) || below_ternary_precedence?(child)
189188
end
190189
end
191190

lib/rubocop/cop/style/trailing_method_end_statement.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ def on_def(node)
4242
return if node.endless? || !trailing_end?(node)
4343

4444
add_offense(node.loc.end) do |corrector|
45-
corrector.insert_before(
46-
node.loc.end,
47-
"\n#{' ' * node.loc.keyword.column}"
48-
)
45+
corrector.insert_before(node.loc.end, "\n#{' ' * node.loc.keyword.column}")
4946
end
5047
end
5148

0 commit comments

Comments
 (0)