-
Notifications
You must be signed in to change notification settings - Fork 0
Home
unurgunite edited this page Jul 11, 2026
·
4 revisions
Static performance analysis for Crystal. Detect allocation anti-patterns, algorithmic complexity issues, and resource leaks before they reach production.
Array & Enumerable (13 rules)
| ID | Rule | Severity | Fix |
|---|---|---|---|
| CAT-001 | sort.first → min/max | warning | ✅ |
| CAT-002 | map{}.sum → sum{} | warning | ✅ |
| CAT-003 | select + reject → partition | info | ❌ |
| CAT-004 | Array#include? → Set | warning | ❌ |
| CAT-005 | shift/unshift → Deque | info | ❌ |
| CAT-007 | reverse.each → reverse_each | hint | ✅ |
| CAT-008 | select.first/last → find | warning | ✅ |
| CAT-022 | shuffle.first → sample | info | ❌ |
| CAT-033 | select.map → single-pass | warning | ❌ |
| CAT-034 | each_with_index.map → map_with_index | info | ❌ |
| CAT-046 | reverse.reverse no-op | hint | ❌ |
| CAT-047 | upcase/downcase no-op | hint | ❌ |
| CAT-048 | puts to_s redundant | hint | ❌ |
Hash (6 rules)
| ID | Rule | Severity | Fix |
|---|---|---|---|
| CAT-006 | hash.keys.each → each_key | info | ✅ |
| CAT-009 | group_by → counter hash | info | ❌ |
| CAT-021 | values.each → each_value | info | ❌ |
| CAT-024 | keys/values.map → each_kv | info | ❌ |
| CAT-030 | keys.includes? → has_key? | info | ❌ |
| CAT-031 | values.includes? → has_value? | info | ❌ |
String (9 rules)
| ID | Rule | Severity | Fix |
|---|---|---|---|
| CAT-010 | String#+ in loop → String.build | warning | ❌ |
| CAT-011 | Multi-pass gsub | hint | ❌ |
| CAT-018 | downcase == → compare | hint | ✅ |
| CAT-023 | includes? → char comparison | info | ❌ |
| CAT-032 | split.first → split_limit | info | ❌ |
| CAT-035 | split("") → each_char | hint | ❌ |
| CAT-036 | chars.each → each_char | info | ❌ |
| CAT-039 | Regex.new → constant | warning | ❌ |
| CAT-040 | String.build for literals | hint | ❌ |
Resource & IO (8 rules)
| ID | Rule | Severity | Fix |
|---|---|---|---|
| CAT-013 | TCPSocket leak | error | ❌ |
| CAT-014 | File.read → streaming | info | ✅ |
| CAT-020 | IO::Memory → pipe | warning | ✅ |
| CAT-025 | File.open leak | error | ❌ |
| CAT-026 | Dir.open leak | error | ❌ |
| CAT-027 | Tempfile leak | error | ❌ |
| CAT-028 | HTTP::Client leak | error | ❌ |
| CAT-029 | DB.open leak | error | ❌ |
Type & Serialization (4 rules)
| ID | Rule | Severity | Fix |
|---|---|---|---|
| CAT-012 | JSON.parse → Serializable | info | ❌ |
| CAT-015 | Struct vs Class | info | ❌ |
| CAT-016 | Large union types | info | ❌ |
| CAT-019 | Regex.new in loop | warning | ✅ |
Performance & Idiom (9 rules)
| ID | Rule | Severity | Fix |
|---|---|---|---|
| CAT-017 | Time.local → Time.utc | hint | ✅ |
| CAT-037 | Logging block form | info | ❌ |
| CAT-038 | Capacity hints | info | ❌ |
| CAT-041 | Parse → constant | hint | ❌ |
| CAT-042 | sleep(0) → Fiber.yield | hint | ❌ |
| CAT-043 | Random.new reuse | info | ❌ |
| CAT-044 | ** → Math.pow | info | ❌ |
| CAT-049 | Thread.new → spawn | warning | ❌ |
| CAT-050 | Fiber.new → spawn | warning | ❌ |
Total: 49 rules | catalyst --list-rules