Skip to content

Remove -strict flag, add //nolint:spantool and blank param support#4

Merged
tomoemon merged 2 commits into
mainfrom
refactor/remove-strict-add-nolint
Apr 2, 2026
Merged

Remove -strict flag, add //nolint:spantool and blank param support#4
tomoemon merged 2 commits into
mainfrom
refactor/remove-strict-add-nolint

Conversation

@tomoemon

@tomoemon tomoemon commented Apr 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • -strict フラグを廃止し、検出不可時のエラー報告をデフォルト動作に変更
  • //nolint:spantool コメントディレクティブで個別の診断を抑制可能に
  • func(_ *spanner.Row) error コールバック(row を意図的に使わない)をチェック対象外に
  • エラーメッセージに nolint の案内を追加
  • 不要になった flag パッケージのインポートを削除

設計の背景

-strict フラグはオプトインのため、利用者が有効化しない限り検出不可ケースが見逃されていた。一方でデフォルト strict にすると、外部パッケージに row を渡すなど正しいコードでも誤検知が発生し、抑制手段がなかった。

golangci-lint と同じ //nolint:spantool ディレクティブ方式を採用することで、デフォルトで厳密なチェックを行いつつ、個別に抑制できるようにした。

_ パラメータのコールバック(SELECT 1 による存在チェック等)は、そもそも row を使わないため検出不可エラーを出す意味がない。コールバック認識の段階でスキップすることで自然に除外される。

検討した代替案

  • strict モードを残したまま nolint を追加する案: strict の存在意義がなくなるため却下
  • //spantool:ignore のようなカスタムプレフィックス: golangci-lint との一貫性を優先し nolint:spantool を採用

Test plan

  • TestScan_Undetectable: 検出不可時に常にエラーが出ること、メッセージに nolint ヒントが含まれること
  • TestScan_UndetectableNolint: //nolint:spantool で診断が抑制されること
  • TestScan_BlankParamCallback: _ パラメータでスキップされること
  • TestScan_Detectable: 検出可能な場合はエラーなし
  • 既存テスト全件パス (go test ./... -count=1)

🤖 Generated with Claude Code

tomoemon and others added 2 commits April 2, 2026 14:32
…suppression

- Remove -strict flag and make undetectable callback detection always-on
- Add //nolint:spantool comment directive to suppress individual diagnostics
- Skip callbacks with _ parameter (intentionally unused row)
- Include nolint hint in error message to guide users

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tomoemon
tomoemon merged commit ea0fcff into main Apr 2, 2026
2 checks passed
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