Skip to content

CAT 033

unurgunite edited this page Jul 11, 2026 · 3 revisions

CAT-033 — select.map → single-pass

Severity: warningConfidence: mediumAuto-fix:

Description

select.map → single-pass — Chaining select + map creates two intermediate arrays. Combine into a single pass.

Bad code

ary.select { |x| x > 0 }.map { |x| x * 2 }

Performance Impact

Tip

This rule can significantly improve performance in hot code paths.

Benchmark

Note

See bench results at bench/cat-033/

Clone this wiki locally