From 60db35096f23b0d0011e934e63f4aea47fc39811 Mon Sep 17 00:00:00 2001 From: Max Eisner <4730112+max-ae@users.noreply.github.com> Date: Sun, 31 Jul 2022 21:29:50 +0200 Subject: [PATCH] simplify and comment dangling comma handling --- Library/Homebrew/rubocops/lines.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/rubocops/lines.rb b/Library/Homebrew/rubocops/lines.rb index 8d767a738c..e065e2f28b 100644 --- a/Library/Homebrew/rubocops/lines.rb +++ b/Library/Homebrew/rubocops/lines.rb @@ -527,10 +527,8 @@ module RuboCop offending_node(offenses.last) replacement = if (%w[:bash :zsh :fish] - shells).empty? @offensive_node.source.sub(/shells: \[(:bash|:zsh|:fish)\]/, "") - .gsub(",,", ",") - .sub(", )", ")") - .sub("(, ", "(") - .sub("()", "") + .sub(", )", ")") # clean up dangling trailing comma + .sub("(, ", "(") # clean up dangling leading comma else @offensive_node.source.sub(/shells: \[(:bash|:zsh|:fish)\]/, "shells: [#{shells.join(", ")}]")