Skip to content

Add -no-star flag to lint-scan to forbid SELECT * usage#6

Merged
tomoemon merged 3 commits into
mainfrom
feat/lint-scan-no-star
Apr 2, 2026
Merged

Add -no-star flag to lint-scan to forbid SELECT * usage#6
tomoemon merged 3 commits into
mainfrom
feat/lint-scan-no-star

Conversation

@tomoemon

@tomoemon tomoemon commented Apr 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Diagnostic に Severity フィールド(Error / Warning)を追加
  • lint-scan に -no-star フラグを追加。指定時は SELECT * / SELECT t.* をエラーとして報告
  • -no-star 未指定時も SELECT * によるバリデーションスキップを warning として stderr に出力(従来はサイレントスキップ)
  • hasStar チェックを analyzeFuncBody の前に移動し、スキップ時の不要なコールバック解析を回避
  • README を更新

設計の背景

従来 SELECT * は DDL なしではカラム数を確定できないためサイレントにスキップされていた。しかしユーザーがスキップされていることに気づけない問題があったため、2段階のアプローチを採用した:

  1. デフォルト: warning を出力してスキップされたことを通知(既存の動作を壊さない)
  2. -no-star フラグ: SELECT * 自体を禁止するルールとしてエラー報告

検討した代替案

  • warning なしで -no-star フラグのみ追加する案: ユーザーがフラグの存在を知らないとスキップに気づけないため不採用
  • Diagnostic に Severity を追加せず stderr に直接出力する案: テスタビリティが下がるため不採用

Test plan

  • go test ./... 全テスト通過
  • SELECT * / SELECT t.* / SELECT a, * の各パターンで -no-star 時にエラー検出
  • -no-star 未指定時に warning が返ること
  • 明示的カラム指定時に -no-star が影響しないこと
  • 既存テスト(SelectStar, SelectDotStar)が warning 期待に更新済み

🤖 Generated with Claude Code

tomoemon and others added 3 commits April 2, 2026 16:38
Add Severity to Diagnostic so lint-scan can emit warnings for SELECT *
queries that skip validation. With -no-star flag, SELECT * is reported
as an error instead. This also moves the hasStar check before
analyzeFuncBody to avoid unnecessary callback analysis.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tomoemon
tomoemon merged commit 8188f12 into main Apr 2, 2026
2 checks passed
@tomoemon
tomoemon deleted the feat/lint-scan-no-star branch April 2, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant