summaryrefslogtreecommitdiff
path: root/rubocop
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2018-09-05 09:34:11 -0700
committerRobert Speicher <rspeicher@gmail.com>2018-09-05 09:34:11 -0700
commit24fc23771029eeb0d5822619c26bea47ea5aaed8 (patch)
treed0be249e38608cb2c6c6e764b283df49af7a01d9 /rubocop
parentba99dfcde262c91e33b5bf7f86ba7c0e3b6f7e52 (diff)
downloadgitlab-ce-24fc23771029eeb0d5822619c26bea47ea5aaed8.tar.gz
Fix LineBreakAroundConditionalBlock cop for a conditional after rescue
Previously this would violate on the `if`: def a_method do_something rescue if condition do_something end end
Diffstat (limited to 'rubocop')
-rw-r--r--rubocop/cop/line_break_around_conditional_block.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/rubocop/cop/line_break_around_conditional_block.rb b/rubocop/cop/line_break_around_conditional_block.rb
index 59fe6e5d98c..8118b314b63 100644
--- a/rubocop/cop/line_break_around_conditional_block.rb
+++ b/rubocop/cop/line_break_around_conditional_block.rb
@@ -77,7 +77,8 @@ module RuboCop
start_clause_line?(previous_line(node)) ||
block_start?(previous_line(node)) ||
begin_line?(previous_line(node)) ||
- assignment_line?(previous_line(node))
+ assignment_line?(previous_line(node)) ||
+ rescue_line?(previous_line(node))
end
def last_line_valid?(node)
@@ -111,6 +112,10 @@ module RuboCop
line =~ /^\s*.*=/
end
+ def rescue_line?(line)
+ line =~ /^\s*rescue/
+ end
+
def block_start?(line)
line.match(/ (do|{)( \|.*?\|)?\s?$/)
end