Credence.Pattern.PreferStringSplitTrim (credence v0.8.0)

Copy Markdown

Detects String.split/2 followed by Enum.filter/2 that removes empty strings, which can be replaced with the :trim option on String.split/3.

Bad

sentence
|> String.split(~r/ +/)
|> Enum.filter(&(&1 != ""))

Good

sentence
|> String.split(~r/ +/, trim: true)