Files
hakorune/tools/hako_check
nyash-codex 375edb2a1b HC021 implementation complete: Analyzer IO Safety
 Implementation:
- tools/hako_check/rules/rule_analyzer_io_safety.hako: New rule detecting direct I/O in analyzer rules
- Detects: new FileBox(), .open(), .read(), .write(), network I/O
- CLI-internal push approach: rules should receive data through parameters
- Successfully detects FileBox usage in rule_dead_methods.hako:13-14

 Tests:
- tools/hako_check/tests/HC021_analyzer_io_safety/: Complete test suite
- ok.hako: Safe rule using CLI-internal push approach
- ng.hako: Unsafe rule using direct FileBox I/O (3 warnings expected)
- Test passes with all diagnostics matching

 Integration:
- tools/hako_check/cli.hako: Added HC021 rule invocation
- All existing tests (HC011-HC022) remain green

🎯 Achievement:
- Priority task completed as requested
- Validates "CLI内push案" (CLI-internal push approach) design
- Encourages safer analyzer rule development

🤖 Generated with Claude Code (https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 04:17:38 +09:00
..

Hako Check — Diagnostics Contract (MVP)

This tool lints .hako sources and emits diagnostics.

Diagnostics schema (typed)

  • Map fields:
    • rule: string like "HC011"
    • message: string (human-readable, one line)
    • file: string (path)
    • line: int (1-based)
    • severity: string ("error"|"warning"|"info"), optional (default: warning)
    • quickFix: string, optional

Backwards compatibility

  • Rules may still out.push("[HCxxx] ...") with a single-line string.
  • The CLI accepts both forms. String diagnostics are converted to typed internally.

Suppression policy

  • HC012 (dead static box) takes precedence over HC011 (unreachable method).
  • If a box is reported by HC012, HC011 diagnostics for methods in that box are suppressed at aggregation.

Quiet / JSON output

  • When --format json-lsp is used, output is pure JSON (pretty). Combine with NYASH_JSON_ONLY=1 in the runner to avoid extra lines.
  • Non-JSON formats print human-readable lines per finding.

Planned AST metadata (parser_core.hako)

  • boxes[].span_line: starting line of the static box declaration.
  • methods[].arity: parameter count as an integer.
  • boxes[].is_static: boolean.

Notes

  • Prefer AST intake; text scans are a minimal fallback.
  • For tests, use tools/hako_check/run_tests.sh.