mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
rubocops/lines: add some OS cop comments/exceptions.
Exclude and comment the cases the autocorrect currently doesn't work. Follow-up from #11955.
This commit is contained in:
parent
56c413200c
commit
ebc4cce456
@ -368,6 +368,9 @@ module RuboCop
|
|||||||
block_node = offending_node.parent
|
block_node = offending_node.parent
|
||||||
next if block_node.type != :block
|
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)
|
source_range = offending_node.source_range.join(offending_node.parent.loc.begin)
|
||||||
corrector.replace(source_range, if_method_and_class)
|
corrector.replace(source_range, if_method_and_class)
|
||||||
end
|
end
|
||||||
@ -383,6 +386,9 @@ module RuboCop
|
|||||||
block_node = offending_node.parent
|
block_node = offending_node.parent
|
||||||
next if block_node.type != :block
|
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)
|
source_range = offending_node.source_range.join(offending_node.parent.loc.begin)
|
||||||
corrector.replace(source_range, if_method_and_class)
|
corrector.replace(source_range, if_method_and_class)
|
||||||
end
|
end
|
||||||
@ -414,6 +420,8 @@ module RuboCop
|
|||||||
problem "Don't use '#{if_method_and_class}', use '#{on_method_name} do' instead." do |corrector|
|
problem "Don't use '#{if_method_and_class}', use '#{on_method_name} do' instead." do |corrector|
|
||||||
if_node = method.parent
|
if_node = method.parent
|
||||||
next if if_node.type != :if
|
next if if_node.type != :if
|
||||||
|
|
||||||
|
# TODO: could fix corrector to handle this but punting for now.
|
||||||
next if if_node.unless?
|
next if if_node.unless?
|
||||||
|
|
||||||
corrector.replace(if_node.source_range, "#{on_method_name} do\n#{if_node.body.source}\nend")
|
corrector.replace(if_node.source_range, "#{on_method_name} do\n#{if_node.body.source}\nend")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user