Skip to content

feat: Add -fix flag support for auto-correction#7

Merged
tomoemon merged 1 commit into
mainfrom
feat-suggested-fix
Feb 10, 2026
Merged

feat: Add -fix flag support for auto-correction#7
tomoemon merged 1 commit into
mainfrom
feat-suggested-fix

Conversation

@tomoemon

@tomoemon tomoemon commented Feb 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • errstklint に SuggestedFix を実装し、-fix フラグ(スタンドアロン)および --fix(golangci-lint)による自動修正をサポート
  • 名前なし返り値を名前付きに変換(errorerr error、その他 → _ type)し、defer errstk.Wrap(&err) を関数本体の先頭に挿入、必要に応じて import も追加
  • 複数の error 返り値を持つ関数は自動修正対象外とし、警告メッセージを表示
  • サンプル設定ファイル(.custom-gcl.example.yml, .golangci.example.yml)を追加
  • README を更新し、Auto-fix の使い方とサンプル設定への参照を追記

Test plan

  • go test ./errstklint/ -v で既存テスト・新規テスト全て通ること
  • TestAnalyzerWithSuggestedFixes で Case A〜D(名前付き返り値、名前なし単一、名前なし複数、複数error)の自動修正が期待通り動作すること
  • インポート追加テスト(import なし / grouped import / single import)の .golden ファイルとの一致を確認
  • errstklint -fix ./... でスタンドアロン実行時の自動修正を動作確認

🤖 Generated with Claude Code

Enable automatic fixing of missing defer errstk.Wrap(&err) via the -fix
flag (standalone) or --fix (golangci-lint). The auto-fix handles:
- Unnamed return values converted to named returns (error→err, others→_)
- defer errstk.Wrap(&err) inserted at function body start
- errstk import added if not present

Functions with multiple error return values are not auto-fixed and show
a warning message instead.

Also adds sample golangci-lint configuration files and updates READMEs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tomoemon
tomoemon merged commit 159ad52 into main Feb 10, 2026
1 check passed
@tomoemon
tomoemon deleted the feat-suggested-fix branch February 10, 2026 00:43
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