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:
Mike McQuaid 2021-09-08 13:46:01 +01:00
parent 56c413200c
commit ebc4cce456
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829

View File

@ -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")