Credence.Pattern.PreferPipeMapsetIntersection (credence v0.8.0)

Copy Markdown

Detects a sequence of MapSet.new/1 assignments followed by nested MapSet.intersection/2 calls piped into MapSet.to_list/0, and rewrites them into a single pipeline using |>.

Bad

set_a = MapSet.new(a)
set_b = MapSet.new(b)
set_c = MapSet.new(c)

MapSet.intersection(set_a, MapSet.intersection(set_b, set_c))
|> MapSet.to_list()

Good

a
|> MapSet.new()
|> MapSet.intersection(MapSet.new(b))
|> MapSet.intersection(MapSet.new(c))
|> MapSet.to_list()