rubocops/shared/desc_helper: fix autocorrect infinite loop
This commit is contained in:
parent
7c620029fb
commit
b2e837f94d
@ -64,7 +64,7 @@ module RuboCop
|
|||||||
if type == :cask &&
|
if type == :cask &&
|
||||||
(match = regex_match_group(desc, /\b(macOS|Mac( ?OS( ?X)?)?|OS ?X)(?! virtual machines?)\b/i)) &&
|
(match = regex_match_group(desc, /\b(macOS|Mac( ?OS( ?X)?)?|OS ?X)(?! virtual machines?)\b/i)) &&
|
||||||
match[1] != "MAC"
|
match[1] != "MAC"
|
||||||
desc_problem "Description shouldn't contain the platform."
|
add_offense(@offensive_source_range, message: "Description shouldn't contain the platform.")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if a full stop is used at the end of a desc (apart from in the case of "etc.").
|
# Check if a full stop is used at the end of a desc (apart from in the case of "etc.").
|
||||||
@ -109,6 +109,8 @@ module RuboCop
|
|||||||
correction.gsub!(/\s+$/, "")
|
correction.gsub!(/\s+$/, "")
|
||||||
correction.gsub!(/\.$/, "")
|
correction.gsub!(/\.$/, "")
|
||||||
|
|
||||||
|
next if correction == match_data[:correction]
|
||||||
|
|
||||||
corrector.replace(@offensive_node.source_range, "#{quote}#{correction}#{quote}")
|
corrector.replace(@offensive_node.source_range, "#{quote}#{correction}#{quote}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user