Repository navigation
Description
Overview
Sampled analysis of rotation slice 1/1 for pkg/linters/contextcancelnotdeferred and slice 1/1 for pkg/linters/ctxbackground (date 2026-10-22, 5 of 11795 total functions reviewed, coverage_days 798 for a full unchanged-inventory rotation). This is a sampled check of these two slices only, not a review of either package or the repository as a whole.
Finding
isContextBackgroundCall in pkg/linters/ctxbackground/ctxbackground.go (lines 83-101) manually re-implements the same "is this selector rooted in an import of package X" check that isContextWithCancelCall in pkg/linters/contextcancelnotdeferred/contextcancelnotdeferred.go (lines 48-62) performs by calling the shared helper astutil.IsPkgSelector(pass, sel, "context").
Observed duplicate logic in isContextBackgroundCall:
ident, ok := sel.X.(*ast.Ident)
if !ok || pass.TypesInfo == nil {
return false
}
obj := pass.TypesInfo.ObjectOf(ident)
if obj == nil {
return false
}
pkgName, ok := obj.(*types.PkgName)
if !ok {
return false
}
return pkgName.Imported().Path() == "context"versus the sibling linter's one-line equivalent:
if !astutil.IsPkgSelector(pass, sel, "context") {
return false
}Both resolve a *ast.SelectorExpr's base identifier to its types.Object, assert it is a *types.PkgName, and compare the imported path to "context" -- the same multi-step package-identifier resolution, just inlined in one file and factored into a helper in the other.
Proposed refactoring
Replace the inline block in isContextBackgroundCall with a call to astutil.IsPkgSelector(pass, sel, "context"), matching the pattern already used by isContextWithCancelCall. This removes about 7 duplicated lines and keeps the selector-resolution logic in one place.
Preservation risks
isContextBackgroundCalladditionally guards onpass.TypesInfo == nilbefore the lookup; confirmastutil.IsPkgSelectorhas equivalent nil-safety (not visible in this excerpt) before removing that check.- Only the selector-ownership check should move; the existing
sel.Sel.Name != "Background"check inisContextBackgroundCallis specific to this linter and must stay as-is.
Scope
Sampled, not exhaustive: based only on the 5 functions supplied in today's rotation slice for these 2 packages. No other files or functions in either package were reviewed.
Generated by 🔧 Semantic Function Refactoring · claude · sonnet50 · 40.9 AIC · ⌖ 19.1 AIC · ⊞ 5.2K · ◷
- expires on Oct 23, 2026, 6:41 PM UTC-08:00
Activity
github-actions commentedon Oct 22, 2026
🍪 Issue Monster selected this for Copilot
I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.
If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.
Om nom nom! 🍪
github-actions commentedon Oct 23, 2026
Superseded by a new sampled semantic-function-refactor report filed today (rotation slice pkg/workflow 455/636, pkg/cli 456/557, 2026-10-23). This workflow closes prior [refactor]-tagged issues each time it files a new one; this closure does not imply the original finding in this issue was invalid, only that the daily sampled report has moved on.
github-actions commentedon Oct 23, 2026
🍪 Issue Monster selected this for Copilot
I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.
If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.
Om nom nom! 🍪
github-actions commentedon Oct 24, 2026
🍪 Issue Monster selected this for Copilot
I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.
If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.
Om nom nom! 🍪
github-actions commentedon Oct 24, 2026
This issue was automatically closed because it expired on 2026-10-24T02:41:23.399Z.