crystal-ameba / ameba

A static code analysis tool for Crystal
https://crystal-ameba.github.io
MIT License
521 stars 38 forks source link

Add `Performance/MinMaxAfterMap` rule #387

Closed Sija closed 1 year ago

Sija commented 1 year ago

This rule is used to identify usage of min/max/minmax calls that follow map.

For example, this is considered invalid:

%w[Alice Bob].map(&.size).min
%w[Alice Bob].map(&.size).max
%w[Alice Bob].map(&.size).minmax

And it should be written as this:


%w[Alice Bob].min_of(&.size)
%w[Alice Bob].max_of(&.size)
%w[Alice Bob].minmax_of(&.size)