Credence.Pattern.PreferStringSliceForTrimLastChar
(credence v0.8.0)
Copy Markdown
Detects the verbose case String.graphemes(str) idiom for removing the
last character from a string, and rewrites it to the idiomatic
String.slice(str, 0..-2//1).
Bad
case String.graphemes(str) do
[] -> ""
[_last] -> ""
[_head | _tail] -> String.slice(str, 0, String.length(str) - 1)
endGood
String.slice(str, 0..-2//1)