Skip to content

fix(lint): select the Go model-rule forms deferred in #196 - #257

Merged
furedea merged 6 commits into
mainfrom
fix/196-go-rules
Nov 20, 2026
Merged

furedea merged 6 commits into
mainfrom
fix/196-go-rules

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

概要

#196 の Go の項目を origin/main で確かめ,残っていた Go のモデル規則(jev-lint,助言)の見逃しを直し,ユーザー決定(2026-11-19)に従って go-style の t.Parallel() の文を戻した.Jev 規則は昇格しない(ADR-0027).

Refs #196

項目ごとの状態

出典 項目 状態
#190 go_sealed_interface_sumtype_decl:// sumtype:decl を受け入れる 対応済み(obsolete.規則は #216 の時点で削除済み)
#190 go_error_no_capitalized_message:import path・シャドー 対応済み(obsolete.同上)
#190 go_context_param_named_ctx / go_no_context_in_struct:import path 対応済み(#216.標準 context を別名なしで import したファイルに限定)
#190 go_use_slog:import path,引数・receiver・名前付き戻り値のシャドー 対応済み(#216)
#190 go_use_slog:ローカル変数のシャドー 対応済み(#216 で規則の Limits: に記録.スコープ解析が要る)
#190 go_iota_enum_typed:iota + 1 などの式 対応済み(#216 で Limits: に記録.構文では enum と区別できない)
#190 go_no_generated_mocks://go:generate 経由,// Code generated by ヘッダー 対応済み(#216)
#190 go_no_context_in_struct:*context.Context 対応済み(#216)
#190 error-handled-once:slog.Default().Error(...),log.Default().Printf(...) 修正
#190 error-handled-once:receiver 名が log / logger 以外(l,audit),receiver の Output 修正
#190 error-handled-once:入れ子のクロージャのログで親関数も選ばれる 修正(ログ呼び出しに最も近い関数だけを選ぶ)
#190 severity: error を hook のブロックに結びつける 対応済み(static_rule_scan.py が severity error を error として扱う)
#190 model rule 5 件の fixtures・eval・baseline 対応済み(#244 で Go の 13 規則を当てはめ)
#191 Go construction-separate-from-execution:client.New(...) 修正(errors / uuid / hash / container などの標準の New は除く)
#191 Go no-exposed-mutable-collection:複数戻り値 ([]string, error) 修正
#191 Go no-exposed-mutable-collection:名前付きの slice / map 型 修正(同じファイルで宣言した型に限る.別ファイルの型は Limits)
#191 selector が広く Go の getter も選ぶ 変更なし(#196 の方針でモデル規則の matcher は広く取り,criteria で判定する)
#191 Go no-comment-restating-code:関数直前の doc comment misc レーン(4 言語まとめて直す「コメントの位置」の項目)
#191 Go no-reaching-through-collaborators:プロパティ連鎖 misc レーン(4 言語まとめて直す Demeter の項目)
#190 go-style の t.Parallel() の文 修正(ユーザー決定により文を戻した)
#216 ローカルで失敗する test_go_rules_select_the_functions_they_ask_about,test_main_is_thin_selects_func_main_of_package_main 対応済み(origin/main で通る)
#194 test_main_is_thin_selects_... が command-query-naming に指摘される 対象外(Python の規則の判定.py レーン)

Limits(レビューで記録したもの)

matcher を直すと baseline がまた無効になり,この PR では eval を再実行しない(ユーザーの指示)ため,規則ファイルの Limits: に記録した(6de1d32d).

  • error-handled-once:ログに似た呼び出しも選ぶ(http.Error,cmd.Output(),c.Error(err),s.t.Fatal(...)).自分で実行するクロージャ内のログ(defer func() { log.Error(err) }())は親関数を選ばない.引数付きで派生したロガー(slog.With("k", v).Error(...),logrus の log.WithError(err).Error(...))を見逃す(見逃し.後続).
  • construction-separate-from-execution:log.New,slog.New,zap.New,メソッドの tmpl.New("x") も選ぶ.
  • no-exposed-mutable-collection:(Items, error) や名前付きの (items Items) など括弧で書いた結果リスト内の名前付き型と,別ファイルで宣言した型を見逃す(見逃し.次に eval を回すときに直す後続).*[]T,chan []byte,func() []string も選ぶ.

判断が要るもの

  • go-style の文の扱い:feat(lint): migrate go-style rules to ast-grep and jev-lint rules #190 は template-go の golangci-lint が覆う文を t.Parallel() 以外にも削除した(testifylint の require / assert,usetesting の t.TempDir() / t.Setenv() など).ユーザー決定の方針(template でしか有効でない linter の規則は文を残す)をこれらにも当てはめて戻すかを決めてほしい.この PR では明示された t.Parallel() だけを戻した.

検証

  • uv run pytest tests/test_model_rule_files.py:選択のテスト 3 件を先に足して失敗を確認し,matcher の修正後に通った.
  • uv run pytest tests/test_model_rule_files.py:17 件通過(baseline の replay を含む).
  • jev-lint eval --accept -r 3(ユーザーが 2026-11-19 に実行):3 規則とも fp / fn 0.閾値を fitted midpoint に合わせた.error-handled-once 0.37 → 0.41(最高の clean 0.06,最低の bad 0.75),construction-separate-from-execution 0.6(0.24 / 0.96),no-exposed-mutable-collection 0.57 → 0.59(0.24 / 0.93).error-handled-once と no-exposed-mutable-collection は blind のまま inconclusive: を残した.
  • レビュー:Codex P2(zerolog の log.Error().Err(err).Msg(...) の見逃し)は a25d8c9 で修正.P1(baseline の無効化)は c27cb73 で解消.

計画との差

なし.

🤖 Generated with Claude Code

furedea and others added 2 commits November 19, 2026 20:38
… model rules missed

error-handled-once now selects a logger reached through Default() and a
logger of any receiver name, and only the function literal nearest to a
log call. construction-separate-from-execution selects a package-level
New of a collaborator package. no-exposed-mutable-collection selects a
collection among several results and a named slice or map type declared
in the same file.

Refs #196

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aralleltest

paralleltest is enabled only in projects created from template-go, so the
prose stays for the others.

Refs #196

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@furedea

furedea commented Nov 19, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T12:50:18.240721Z e3d2e77 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

Review summary

P1 (1)

  • Saved eval baselines for the three changed rules (error-handled-once, construction-separate-from-execution, no-exposed-mutable-collection) are stale. test_every_saved_eval_baseline_still_scores_as_accepted fails, as the PR description states. Regenerate them with jev-lint eval --accept -r 3 before merging, otherwise the suite is red on main.

Not found

  • The three new selection tests match the intended behavior. I did not run them: the sandbox denied uv run pytest, so I only read the diff.
  • The matchers are deliberately broad (for example cmd.Output() or http.Error(...) may be selected), and the criteria decide the final result, so I did not flag them.

The go-style t.Parallel() wording change is docs only and has no correctness concern.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 024c69f9a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea

furedea commented Nov 19, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

The three Go matcher changes and the t.Parallel() doc revert look correct from reading the diff. I could not run the tests in this environment, so I did not confirm the new selection tests myself. The PR description reports they pass.

P1 (blocks merge)

  • The saved eval baselines for error-handled-once, construction-separate-from-execution and no-exposed-mutable-collection are stale. By the PR's own account, test_every_saved_eval_baseline_still_scores_as_accepted fails ("question changed"). Merging leaves the suite red. Regenerate the baselines first.

P3 (optional)

  • error-handled-once: http.Error(w, ...), c.Error(err) and similar calls now count as loggers, and the exclusion list is narrow. Its tests have no negative cases for the new exclusions.
  • error-handled-once: a log call inside defer func(){...}() now selects only the closure, not the enclosing function. That is a deliberate trade-off, but it is untested.
  • construction-separate-from-execution: the bare pkg.New( match is broad and relies on a fixed exclusion list.
  • no-exposed-mutable-collection: dropping the ^ anchor also matches types like *[]T, chan []byte and Result[map[..]]. The named-type branch does not handle (Items, error).

Nothing in the diff raises a security concern.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a25d8c956b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

error-handled-once 0.41, construction-separate-from-execution 0.6 and
no-exposed-mutable-collection 0.59, from the eval of 2026-11-19 (3 passes,
no false positive or negative).

Refs #196

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@furedea

furedea commented Nov 19, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

I reviewed this statically. The sandbox blocked uv run pytest, so I did not run the tests.

  • P1: The PR knowingly leaves test_every_saved_eval_baseline_still_scores_as_accepted failing. The baseline.json files are rewritten with new timestamps, hashes and values even though the description says eval --accept could not run. The baseline at values (0.37 and 0.57) also disagree with the new rule thresholds (0.41 and 0.59). Regenerate the baselines with a real run, or drop the baseline and threshold edits.
  • P3: The error-handled-once matcher is now broad enough to select functions that don't log, such as cmd.Output() and http.Error(...). Nothing in the new tests checks these negatives.
  • P3: The construction-separate-from-execution exclusion list omits log.New, slog.New and zap.New. The new test has no case for them.

The go-style t.Parallel() wording change and the no-exposed-mutable-collection matcher look fine. I could not check whether the return $R.$F pattern matches multi-value returns such as return c.names, nil, since I didn't run the test that covers it.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c27cb73aab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea

furedea commented Nov 19, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

No P0 or P1 findings. I read the diff but could not run tests/test_model_rule_files.py in this environment, so I have not confirmed the new tests pass.

  • P3, error-handled-once/rule.yml\:38: the logger matcher misses calls on a derived logger such as slog.With(...).Error(...) or log.WithError(err).Error(...). This is not a regression, and the Limits: comment doesn't mention it.

Other things I checked:

  • The new thresholds (0.41, 0.59, 0.6) match the midpoints of the baseline scores given in the rule comments.
  • The Go matcher rewrites look consistent with their tests.
  • The t.Parallel() sentence in go-style/references/testing.md is restored as the PR describes.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6de1d32d69

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Also record in error-handled-once that a derived logger with arguments
is not matched.

Refs #196

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@furedea

furedea commented Nov 19, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary: I read the full diff and found no issues worth blocking the merge. I couldn't run tests/test_model_rule_files.py in this environment because the command needed approval, so the new ast-grep selector tests and the eval-derived thresholds and baselines are unverified. The error-handled-once, construction-separate-from-execution and no-exposed-mutable-collection matcher changes match their documented Limits. The test expectations (6, 1 and 3 subjects) match my reading of the fixtures.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e3d2e77055

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea
furedea merged commit 8c347fe into main Nov 20, 2026
29 checks passed
@furedea
furedea deleted the fix/196-go-rules branch November 20, 2026 06:07
furedea pushed a commit that referenced this pull request Nov 20, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.3.1](v0.3.0...v0.3.1)
(2026-11-20)


### Bug Fixes

* **hooks:** do not count a printf whose format holds %n as writing
nothing ([#262](#262))
([f3a4543](f3a4543))
* **hooks:** judge gh beside commands that write nothing as gh alone
([#256](#256))
([540bbad](540bbad))
* **hooks:** stop asking for gh calls whose target and arguments are
known at hook time
([#254](#254))
([f4aa355](f4aa355))
* **lint:** close the Rust and TypeScript items of
[#196](#196)
([#259](#259))
([1d2a81e](1d2a81e))
* **lint:** select the Go model-rule forms deferred in
[#196](#196)
([#257](#257))
([8c347fe](8c347fe))
* **lint:** widen three Python model-rule selectors deferred in
[#196](#196)
([#258](#258))
([b3fc801](b3fc801))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: furedea-release[bot] <353651101+furedea-release[bot]@users.noreply.github.com>
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