Skip to content

CAT 010

unurgunite edited this page Jul 11, 2026 · 3 revisions

CAT-010 — String#+ in loop → String.build

Severity: warning | Confidence: high | Auto-fix:

Description

String#+ in loop → String.build — Repeated String#+ creates new strings each iteration. Use String.build for efficient incremental building.

Bad code

str = ""
10.times { str += "x" }

Performance Impact

Tip

This rule can significantly improve performance in hot code paths.

Benchmark

Note

See bench results at bench/cat-010/

Clone this wiki locally