rubocops/cask/array_alphabetization: skip blank lines when sorting

This commit is contained in:
Justin Krehel 2024-04-17 13:48:06 -04:00
parent 726d65c0ab
commit 36cc201616
No known key found for this signature in database
GPG Key ID: 757F1864C8CF3605

View File

@ -37,6 +37,7 @@ module RuboCop
def sort_array(source) def sort_array(source)
# Combine each comment with the line(s) below so that they remain in the same relative location # Combine each comment with the line(s) below so that they remain in the same relative location
combined_source = source.each_with_index.filter_map do |line, index| combined_source = source.each_with_index.filter_map do |line, index|
next if line.blank?
next if line.strip.start_with?("#") next if line.strip.start_with?("#")
next recursively_find_comments(source, index, line) next recursively_find_comments(source, index, line)