## Overview Detects method calls with incorrect number of arguments (arity mismatch). MVP version focuses on clear `Box.method()` calls with wrong arity. ## Implementation Details - **Rule**: `rule_arity_mismatch.hako` following box principles - **Detection Method**: IR-based analysis using arity inference - Leverages `analysis_consumer.hako`'s `_infer_call_arity()` (already implemented) - Compares called arity vs. defined arity from methods[] - Reports mismatches as HC015 warnings - **Integration**: Added to cli.hako in IR-based rules section ## Technical Approach - **Arity Parsing**: Extracts arity from qualified names (`Box.method/arity`) - **Method Lookup**: Searches methods[] for matching Box.method definition - **Mismatch Detection**: Compares called arity vs. expected arity - **MVP Scope**: Detects clear cases only (skips plugin/external methods if not found) ## Helper Methods - `_parse_qualified()`: Parses `Box.method/arity` into components (MapBox result) - `_find_method_arity()`: Searches methods[] for Box.method definition arity - `_itoa()` / `_atoi()`: Integer conversion utilities ## Test Cases - **ok.hako**: All calls match definitions - `Calculator.add(1, 2)` → matches `add/2` - `Helper.double(5)` → matches `double/1` - **ng.hako**: Arity mismatches - `Calculator.add()` → expects `add/2`, got `add/0` - `Helper.double(1, 2)` → expects `double/1`, got `double/2` ## Test Results ``` [TEST/OK] HC011_dead_methods [TEST/OK] HC012_dead_static_box [TEST/OK] HC013_duplicate_method [TEST/OK] HC014_missing_entrypoint [TEST/OK] HC015_arity_mismatch ← NEW [TEST/OK] HC016_unused_alias [TEST/OK] HC017_non_ascii_quotes [TEST/OK] HC018_top_level_local [TEST/SUMMARY] all green ``` ## Diagnostic Format ``` [HC015] arity mismatch: Box.method expects N arguments, got M :: Box.method/M ``` ## Architecture - Box-first design: RuleArityMismatchBox with single responsibility - IR-based: Uses analysis_consumer's arity inference (no duplication) - Clean separation: parsing, lookup, comparison, reporting ## Dependencies - Relies on `analysis_consumer.hako`'s `_infer_call_arity()` implementation - Fixed parser_core.hako arity bug (HC013 commit) ensures accuracy 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Hako Check — Rule Tests (MVP)
構成(1 ルール = 1 ディレクトリ)
- tools/hako_check/tests/<rule_name>/
- ok.hako … 検出なし
- ng.hako … 最低 1 件の検出
- edge.hako … 端境(任意)
- expected.json …
--format json-lspの期待ダイアグノスティクス
実行(MVP)
bash tools/hako_check/run_tests.shで全テストを走査- 差分があれば終了コード 1、詳細を提示
注意
- 21.4 は AST JSON 優先。Text fallback の差異は expected に反映
- ルール名は HCxxx を推奨(例: HC002)