Files
hakorune/tools/hako_check/rules/rule_using_quoted.hako
nyash-codex 58a6471883 Phase 21.3 WIP: Hako Source Checker improvements - HC011/HC016/HC017 実装完了
主な変更:
-  HC011 (dead methods) 実装・テスト緑
-  HC016 (unused alias) 実装・テスト緑
-  HC017 (non-ascii quotes) 実装完了
- 🔧 tokenizer/parser_core 強化(AST優先ルート)
- 🛡️ plugin_guard.rs 追加(stderr専用出力)
- 📋 テストインフラ整備(run_tests.sh改善)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 00:46:34 +09:00

37 lines
1.3 KiB
Plaintext

using selfhost.shared.common.string_helpers as Str
static box RuleUsingQuotedBox {
apply(text, path, out) {
local lines = me._split_lines(text)
local i = 0
while i < lines.size() {
local ln = me._ltrim(lines.get(i))
if ln.indexOf("using ") == 0 {
if ln.indexOf('using "') != 0 { out.push("[HC003] using must be quoted: " + path + ":" + me._itoa(i+1)) }
}
i = i + 1
}
}
_ltrim(s) { return me._ltrim_chars(s, " \t") }
_itoa(n) { local v=0+n; if v==0 { return "0" } local out=""; local digits="0123456789"; local tmp=""; while v>0 { local d=v%10; tmp=digits.substring(d,d+1)+tmp; v=v/10 } out=tmp; return out }
_split_lines(s) {
local arr = new ArrayBox(); if s == null { return arr }
local n = s.length(); local last = 0; local i = 0
while i < n { local ch = s.substring(i,i+1); if ch == "\n" { arr.push(s.substring(last,i)); last = i+1 } i = i + 1 }
arr.push(s.substring(last)); return arr
}
_ltrim_chars(s, cs) {
local n = s.length(); local head = 0
local i = 0
while i < n {
local ch = s.substring(i,i+1)
if ch != " " && ch != "\t" { head = i; break }
if i == n-1 { head = n }
i = i + 1
}
return s.substring(head)
}
}
static box RuleUsingQuotedMain { method main(args) { return 0 } }