simplify and comment dangling comma handling
This commit is contained in:
parent
ab09d15703
commit
60db35096f
@ -527,10 +527,8 @@ module RuboCop
|
|||||||
offending_node(offenses.last)
|
offending_node(offenses.last)
|
||||||
replacement = if (%w[:bash :zsh :fish] - shells).empty?
|
replacement = if (%w[:bash :zsh :fish] - shells).empty?
|
||||||
@offensive_node.source.sub(/shells: \[(:bash|:zsh|:fish)\]/, "")
|
@offensive_node.source.sub(/shells: \[(:bash|:zsh|:fish)\]/, "")
|
||||||
.gsub(",,", ",")
|
.sub(", )", ")") # clean up dangling trailing comma
|
||||||
.sub(", )", ")")
|
.sub("(, ", "(") # clean up dangling leading comma
|
||||||
.sub("(, ", "(")
|
|
||||||
.sub("()", "")
|
|
||||||
else
|
else
|
||||||
@offensive_node.source.sub(/shells: \[(:bash|:zsh|:fish)\]/,
|
@offensive_node.source.sub(/shells: \[(:bash|:zsh|:fish)\]/,
|
||||||
"shells: [#{shells.join(", ")}]")
|
"shells: [#{shells.join(", ")}]")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user