Skip to content

CAT 025

unurgunite edited this page Jul 11, 2026 · 3 revisions

CAT-025 — File.open resource leak

Severity: errorConfidence: highAuto-fix:

Warning

This rule flags real bugs, not just performance issues.

Description

File.open resource leak — File.open without a block leaks file descriptors. Use the block form for automatic closing.

Bad code

f = File.open("data.txt")
content = f.gets_to_end

Performance Impact

Tip

This rule can significantly improve performance in hot code paths.

Benchmark

Note

See bench results at bench/cat-025/

Clone this wiki locally