From ebc4cce4569acc946a5078e672021c05bcad6e4c Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 8 Sep 2021 13:46:01 +0100 Subject: [PATCH] rubocops/lines: add some OS cop comments/exceptions. Exclude and comment the cases the autocorrect currently doesn't work. Follow-up from #11955. --- Library/Homebrew/rubocops/lines.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Library/Homebrew/rubocops/lines.rb b/Library/Homebrew/rubocops/lines.rb index 01d53088f7..638ae164f0 100644 --- a/Library/Homebrew/rubocops/lines.rb +++ b/Library/Homebrew/rubocops/lines.rb @@ -368,6 +368,9 @@ module RuboCop block_node = offending_node.parent next if block_node.type != :block + # TODO: could fix corrector to handle this but punting for now. + next if block_node.single_line? + source_range = offending_node.source_range.join(offending_node.parent.loc.begin) corrector.replace(source_range, if_method_and_class) end @@ -383,6 +386,9 @@ module RuboCop block_node = offending_node.parent next if block_node.type != :block + # TODO: could fix corrector to handle this but punting for now. + next if block_node.single_line? + source_range = offending_node.source_range.join(offending_node.parent.loc.begin) corrector.replace(source_range, if_method_and_class) end @@ -414,6 +420,8 @@ module RuboCop problem "Don't use '#{if_method_and_class}', use '#{on_method_name} do' instead." do |corrector| if_node = method.parent next if if_node.type != :if + + # TODO: could fix corrector to handle this but punting for now. next if if_node.unless? corrector.replace(if_node.source_range, "#{on_method_name} do\n#{if_node.body.source}\nend")