chore(lint): drop nolint directives that suppress nothing
29 of 59 directives did nothing. Removing each one individually and re-running the gate revealed no issue from any of them: 20 named gosec, which is not enabled in .golangci.yml and never has been, plus 4 nilerr in functions that return no error, 2 dupl where dupl reports nothing repo-wide, and one each of contextcheck, nestif and unused. The funlen name on settings.go:147 is gone for the same reason; its gocyclo and cyclop names are both live. The unused directive in webui/authorize.go sat on `var _ = slog.Default`, a statement that only existed to keep the log/slog import alive. Both go. The 30 remaining directives all suppress a real issue.
This commit is contained in:
15 files changed
+28
-34
No files matched your search
@@ -64,7 +64,7 @@ func ProtectionMatcher(p agentrun.Protection, readOnly bool) func(string) bool {
|
||||
func ValidateCaptureArgs(spec agentrun.CaptureTool, value json.RawMessage) (string, bool) {
|
||||
var object map[string]json.RawMessage
|
||||
if err := json.Unmarshal(value, &object); err != nil {
|
||||
return spec.Name + " rejected: arguments must be a JSON object", false //nolint:nilerr // the agent loop must see malformed tool arguments as feedback it can correct, not as a failed tool call
|
||||
return spec.Name + " rejected: arguments must be a JSON object", false // the agent loop must see malformed tool arguments as feedback it can correct, not as a failed tool call
|
||||
}
|
||||
for _, check := range []func(agentrun.CaptureTool, map[string]json.RawMessage) (string, bool){
|
||||
checkRequiredFields,
|
||||
|
||||
@@ -340,7 +340,7 @@ func (b *boot) setupObservability(ctx context.Context) {
|
||||
|
||||
const reactionStreamMaxAge = 24 * time.Hour
|
||||
|
||||
func (b *boot) connectNATS(ctx context.Context) error { //nolint:nestif // embedded broker discovery and startup require explicit fallback branches
|
||||
func (b *boot) connectNATS(ctx context.Context) error { // embedded broker discovery and startup require explicit fallback branches
|
||||
cfg, log := b.cfg, b.log
|
||||
url := cfg.NATS.URL
|
||||
var natsToken string
|
||||
|
||||
@@ -174,8 +174,6 @@ func (s scheduleResourceStore) MarkRun(ctx context.Context, id string, runAt tim
|
||||
// The stop path derives its own timeout budget from Background rather than
|
||||
// the boot context, which is already cancelled by the time shutdown runs --
|
||||
// the same reasoning as shutdownCuratorRuntime.
|
||||
//
|
||||
//nolint:contextcheck
|
||||
func shutdownSchedulingEngine(e *scheduling.Engine, log *slog.Logger) func() {
|
||||
return func() {
|
||||
stopCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
|
||||
@@ -144,7 +144,7 @@ func (c *SettingsCommand) replace(ctx context.Context, actor, input string) stri
|
||||
return fmt.Sprintf("Updated %s to version %d.", updated.Kind, updated.Version)
|
||||
}
|
||||
|
||||
func (c *SettingsCommand) identity(ctx context.Context, actor string, args []string) string { //nolint:gocyclo,cyclop,funlen // command arity checks remain adjacent to spoof-sensitive dispatch
|
||||
func (c *SettingsCommand) identity(ctx context.Context, actor string, args []string) string { //nolint:gocyclo,cyclop // command arity checks remain adjacent to spoof-sensitive dispatch
|
||||
const usage = "Usage: /settings identity <list|create <kind> <name>|rename <id> <name>|suspend <id>|reactivate <id>|retire <id>>"
|
||||
actorID, refusal := c.resolveActor(ctx, "Identity changes", actor)
|
||||
if refusal != "" {
|
||||
|
||||
@@ -21,7 +21,7 @@ func (randomSampler) Sample(_ context.Context, candidates []Candidate, req Reque
|
||||
return nil, nil
|
||||
}
|
||||
n := effectiveCap(req.Cap, len(candidates))
|
||||
seed := uint64(req.Seed) //nolint:gosec // deterministic seeding, not a security boundary
|
||||
seed := uint64(req.Seed) // deterministic seeding, not a security boundary
|
||||
rng := rand.New(rand.NewPCG(seed, seed))
|
||||
order := rng.Perm(len(candidates))
|
||||
out := make([]Candidate, n)
|
||||
|
||||
@@ -99,7 +99,7 @@ func runPrecisionGate(ctx context.Context, tc *TaskContext, findings []prreview.
|
||||
Parameters: precisionGateSchema, RequiredFields: []string{"verdicts"}, MaxCalls: 1,
|
||||
}})
|
||||
if err != nil || res.Status != agentrun.StatusPassed {
|
||||
return findings //nolint:nilerr // recall-first: a gate that could not run is not evidence any finding should drop
|
||||
return findings // recall-first: a gate that could not run is not evidence any finding should drop
|
||||
}
|
||||
calls := res.Captures["precision_gate"]
|
||||
if len(calls) != 1 {
|
||||
@@ -455,7 +455,7 @@ func runCompoundClusterCheck(ctx context.Context, tc *TaskContext, clusterID str
|
||||
Parameters: params, RequiredFields: []string{"indices"}, MaxCalls: 1,
|
||||
}})
|
||||
if err != nil || res.Status != agentrun.StatusPassed {
|
||||
return nil //nolint:nilerr // a cluster call that could not run flags nothing rather than failing the whole compound-check stage
|
||||
return nil // a cluster call that could not run flags nothing rather than failing the whole compound-check stage
|
||||
}
|
||||
calls := res.Captures["compound_findings"]
|
||||
if len(calls) != 1 {
|
||||
@@ -618,7 +618,7 @@ func runMergeGateCall(ctx context.Context, tc *TaskContext, f prreview.ScoredFin
|
||||
Parameters: mergeGateSchema, RequiredFields: []string{"blocking"}, MaxCalls: 1,
|
||||
}})
|
||||
if err != nil || res.Status != agentrun.StatusPassed {
|
||||
return false //nolint:nilerr // a merge-gate call that could not run leaves the finding advisory
|
||||
return false // a merge-gate call that could not run leaves the finding advisory
|
||||
}
|
||||
calls := res.Captures["classify_blocking"]
|
||||
if len(calls) != 1 {
|
||||
|
||||
@@ -57,7 +57,7 @@ func confinedCommand(ctx context.Context, binary *os.File, socket string) (*exec
|
||||
// network, for a package that declares no egress hosts.
|
||||
func openCommand(ctx context.Context, binary *os.File) *exec.Cmd {
|
||||
path := fmt.Sprintf("/proc/%d/fd/%d", os.Getpid(), binary.Fd())
|
||||
cmd := exec.CommandContext(ctx, path) //nolint:gosec // the host-verified binary, by descriptor
|
||||
cmd := exec.CommandContext(ctx, path) // the host-verified binary, by descriptor
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Pdeathsig: syscall.SIGKILL}
|
||||
return cmd
|
||||
}
|
||||
@@ -94,7 +94,7 @@ func launch(socket string) int {
|
||||
func runExtension(ctx context.Context, path string) int {
|
||||
runtime.LockOSThread()
|
||||
proxy := "http://" + proxyAddr
|
||||
cmd := exec.CommandContext(ctx, path) //nolint:gosec // the host-verified binary, by descriptor
|
||||
cmd := exec.CommandContext(ctx, path) // the host-verified binary, by descriptor
|
||||
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||
cmd.Env = append(os.Environ(),
|
||||
"HTTP_PROXY="+proxy, "HTTPS_PROXY="+proxy, "ALL_PROXY="+proxy,
|
||||
|
||||
@@ -16,5 +16,5 @@ func confinedCommand(context.Context, *os.File, string) (*exec.Cmd, error) {
|
||||
}
|
||||
|
||||
func openCommand(ctx context.Context, binary *os.File) *exec.Cmd {
|
||||
return exec.CommandContext(ctx, binary.Name()) //nolint:gosec // the host-verified binary
|
||||
return exec.CommandContext(ctx, binary.Name()) // the host-verified binary
|
||||
}
|
||||
@@ -169,7 +169,7 @@ func (h *Host) Close() {
|
||||
|
||||
// openVerified opens the extension binary and checks it against sum.
|
||||
func openVerified(path string, sum []byte) (*os.File, error) {
|
||||
f, err := os.Open(path) //nolint:gosec // the path is the installed package's binary
|
||||
f, err := os.Open(path) // the path is the installed package's binary
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ func call[T any](ctx context.Context, f *Forge, op string, fn func(forgev1.Forge
|
||||
func ref(owner, repo string) *forgev1.RepoRef { return &forgev1.RepoRef{Owner: owner, Repo: repo} }
|
||||
|
||||
func prRef(owner, repo string, number int) *forgev1.PullRequestRef {
|
||||
return &forgev1.PullRequestRef{Repo: ref(owner, repo), Number: int32(number)} //nolint:gosec // issue numbers fit int32
|
||||
return &forgev1.PullRequestRef{Repo: ref(owner, repo), Number: int32(number)} // issue numbers fit int32
|
||||
}
|
||||
|
||||
func issues(in []*forgev1.Issue) []forge.Issue {
|
||||
@@ -169,21 +169,21 @@ func (f *Forge) IssuesWithLabel(ctx context.Context, owner, repo, label string)
|
||||
|
||||
func (f *Forge) Comment(ctx context.Context, owner, repo string, number int, body string) (int64, error) {
|
||||
resp, err := call(ctx, f, "comment", func(c forgev1.ForgeServiceClient) (*forgev1.CommentResponse, error) {
|
||||
return c.Comment(ctx, &forgev1.CommentRequest{Repo: ref(owner, repo), Number: int32(number), Body: body}) //nolint:gosec // issue numbers fit int32
|
||||
return c.Comment(ctx, &forgev1.CommentRequest{Repo: ref(owner, repo), Number: int32(number), Body: body}) // issue numbers fit int32
|
||||
})
|
||||
return resp.GetId(), err
|
||||
}
|
||||
|
||||
func (f *Forge) CloseIssue(ctx context.Context, owner, repo string, number int, comment string) error {
|
||||
_, err := call(ctx, f, "close issue", func(c forgev1.ForgeServiceClient) (*forgev1.CloseIssueResponse, error) {
|
||||
return c.CloseIssue(ctx, &forgev1.CloseIssueRequest{Repo: ref(owner, repo), Number: int32(number), Comment: comment}) //nolint:gosec // issue numbers fit int32
|
||||
return c.CloseIssue(ctx, &forgev1.CloseIssueRequest{Repo: ref(owner, repo), Number: int32(number), Comment: comment}) // issue numbers fit int32
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (f *Forge) React(ctx context.Context, owner, repo string, number int, reaction string) error {
|
||||
_, err := call(ctx, f, "react", func(c forgev1.ForgeServiceClient) (*forgev1.ReactResponse, error) {
|
||||
return c.React(ctx, &forgev1.ReactRequest{Repo: ref(owner, repo), Number: int32(number), Reaction: reaction}) //nolint:gosec // issue numbers fit int32
|
||||
return c.React(ctx, &forgev1.ReactRequest{Repo: ref(owner, repo), Number: int32(number), Reaction: reaction}) // issue numbers fit int32
|
||||
})
|
||||
return err
|
||||
}
|
||||
@@ -192,7 +192,7 @@ func (f *Forge) React(ctx context.Context, owner, repo string, number int, react
|
||||
// state change corrects the label.
|
||||
func (f *Forge) SetStateLabel(ctx context.Context, owner, repo string, number int, label string, knownLabels []string) {
|
||||
_, err := call(ctx, f, "set state label", func(c forgev1.ForgeServiceClient) (*forgev1.SetStateLabelResponse, error) {
|
||||
return c.SetStateLabel(ctx, &forgev1.SetStateLabelRequest{Repo: ref(owner, repo), Number: int32(number), Label: label, KnownLabels: knownLabels}) //nolint:gosec // issue numbers fit int32
|
||||
return c.SetStateLabel(ctx, &forgev1.SetStateLabelRequest{Repo: ref(owner, repo), Number: int32(number), Label: label, KnownLabels: knownLabels}) // issue numbers fit int32
|
||||
})
|
||||
if err != nil {
|
||||
f.log.Warn("set state label", "owner", owner, "repo", repo, "number", number, "err", err)
|
||||
@@ -208,28 +208,28 @@ func (f *Forge) CreatePR(ctx context.Context, owner, repo, title, head, base, bo
|
||||
|
||||
func (f *Forge) ClosePR(ctx context.Context, owner, repo string, number int, comment string) error {
|
||||
_, err := call(ctx, f, "close pull request", func(c forgev1.ForgeServiceClient) (*forgev1.ClosePRResponse, error) {
|
||||
return c.ClosePR(ctx, &forgev1.ClosePRRequest{Repo: ref(owner, repo), Number: int32(number), Comment: comment}) //nolint:gosec // PR numbers fit int32
|
||||
return c.ClosePR(ctx, &forgev1.ClosePRRequest{Repo: ref(owner, repo), Number: int32(number), Comment: comment}) // PR numbers fit int32
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (f *Forge) MergePR(ctx context.Context, owner, repo string, number int) error {
|
||||
_, err := call(ctx, f, "merge pull request", func(c forgev1.ForgeServiceClient) (*forgev1.MergePRResponse, error) {
|
||||
return c.MergePR(ctx, &forgev1.MergePRRequest{Repo: ref(owner, repo), Number: int32(number)}) //nolint:gosec // PR numbers fit int32
|
||||
return c.MergePR(ctx, &forgev1.MergePRRequest{Repo: ref(owner, repo), Number: int32(number)}) // PR numbers fit int32
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (f *Forge) PRState(ctx context.Context, owner, repo string, number int) (string, error) {
|
||||
resp, err := call(ctx, f, "pull request state", func(c forgev1.ForgeServiceClient) (*forgev1.PRStateResponse, error) {
|
||||
return c.PRState(ctx, &forgev1.PRStateRequest{Repo: ref(owner, repo), Number: int32(number)}) //nolint:gosec // issue numbers fit int32
|
||||
return c.PRState(ctx, &forgev1.PRStateRequest{Repo: ref(owner, repo), Number: int32(number)}) // issue numbers fit int32
|
||||
})
|
||||
return resp.GetState(), err
|
||||
}
|
||||
|
||||
func (f *Forge) GetPullRequest(ctx context.Context, owner, repo string, number int) (forge.PullRequest, error) {
|
||||
resp, err := call(ctx, f, "get pull request", func(c forgev1.ForgeServiceClient) (*forgev1.GetPullRequestResponse, error) {
|
||||
return c.GetPullRequest(ctx, &forgev1.GetPullRequestRequest{Repo: ref(owner, repo), Number: int32(number)}) //nolint:gosec // issue numbers fit int32
|
||||
return c.GetPullRequest(ctx, &forgev1.GetPullRequestRequest{Repo: ref(owner, repo), Number: int32(number)}) // issue numbers fit int32
|
||||
})
|
||||
if err != nil {
|
||||
return forge.PullRequest{}, err
|
||||
@@ -244,7 +244,7 @@ func (f *Forge) GetPullRequest(ctx context.Context, owner, repo string, number i
|
||||
|
||||
func (f *Forge) GetPullRequestDiff(ctx context.Context, owner, repo string, number int) (string, error) {
|
||||
resp, err := call(ctx, f, "get pull request diff", func(c forgev1.ForgeServiceClient) (*forgev1.GetPullRequestDiffResponse, error) {
|
||||
return c.GetPullRequestDiff(ctx, &forgev1.GetPullRequestDiffRequest{Repo: ref(owner, repo), Number: int32(number)}) //nolint:gosec // issue numbers fit int32
|
||||
return c.GetPullRequestDiff(ctx, &forgev1.GetPullRequestDiffRequest{Repo: ref(owner, repo), Number: int32(number)}) // issue numbers fit int32
|
||||
})
|
||||
return resp.GetDiff(), err
|
||||
}
|
||||
@@ -290,7 +290,7 @@ func (f *Forge) ReplyToReview(ctx context.Context, owner, repo string, number in
|
||||
func (f *Forge) CreateReviewComments(ctx context.Context, owner, repo string, number int, reviewedHeadSHA string, comments []forge.InlineReviewComment) error {
|
||||
in := make([]*forgev1.InlineReviewComment, 0, len(comments))
|
||||
for _, c := range comments {
|
||||
in = append(in, &forgev1.InlineReviewComment{Path: c.Path, Line: int32(c.Line), Body: c.Body}) //nolint:gosec // line numbers fit int32
|
||||
in = append(in, &forgev1.InlineReviewComment{Path: c.Path, Line: int32(c.Line), Body: c.Body}) // line numbers fit int32
|
||||
}
|
||||
_, err := call(ctx, f, "create review comments", func(c forgev1.ForgeServiceClient) (*forgev1.CreateReviewCommentsResponse, error) {
|
||||
return c.CreateReviewComments(ctx, &forgev1.CreateReviewCommentsRequest{PullRequest: prRef(owner, repo, number), ReviewedHeadSha: reviewedHeadSHA, Comments: in})
|
||||
@@ -314,7 +314,7 @@ func (f *Forge) VerifyPush(ctx context.Context, owner, repo string) error {
|
||||
|
||||
func (f *Forge) LinkBranch(ctx context.Context, owner, repo string, issueNumber int, branch string) error {
|
||||
_, err := call(ctx, f, "link branch", func(c forgev1.ForgeServiceClient) (*forgev1.LinkBranchResponse, error) {
|
||||
return c.LinkBranch(ctx, &forgev1.LinkBranchRequest{Repo: ref(owner, repo), IssueNumber: int32(issueNumber), Branch: branch}) //nolint:gosec // issue numbers fit int32
|
||||
return c.LinkBranch(ctx, &forgev1.LinkBranchRequest{Repo: ref(owner, repo), IssueNumber: int32(issueNumber), Branch: branch}) // issue numbers fit int32
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -557,7 +557,7 @@ func (s *EDA) SetDispatchTask(ctx context.Context, bindingID, captureID string,
|
||||
|
||||
// ListDispatches returns the newest ledger rows matching filter.
|
||||
func (s *EDA) ListDispatches(ctx context.Context, filter storecontract.DispatchFilter) ([]storecontract.Dispatch, error) {
|
||||
params := postgresdb.ListBindingDispatchesParams{EntryLimit: int32(min(max(filter.Limit, 1), 500))} //nolint:gosec // clamped
|
||||
params := postgresdb.ListBindingDispatchesParams{EntryLimit: int32(min(max(filter.Limit, 1), 500))} // clamped
|
||||
if filter.BindingID != "" {
|
||||
params.Binding = pgtype.Text{String: filter.BindingID, Valid: true}
|
||||
}
|
||||
|
||||
@@ -701,7 +701,7 @@ func (s *Store) Tasks(ctx context.Context, limit int) ([]workflow.Task, error) {
|
||||
func (s *Store) TasksPage(ctx context.Context, page storecontract.TaskPage) ([]workflow.Task, error) {
|
||||
params := postgresdb.ListTaskSummariesParams{
|
||||
Statuses: append([]string{}, page.Statuses...),
|
||||
PageLimit: int32(min(max(page.Limit, 1), 500)), //nolint:gosec // clamped
|
||||
PageLimit: int32(min(max(page.Limit, 1), 500)), // clamped
|
||||
}
|
||||
if page.After.ID != 0 {
|
||||
params.BeforeUpdated = pgtype.Timestamptz{Time: page.After.UpdatedAt, Valid: true}
|
||||
|
||||
@@ -596,7 +596,7 @@ func (c *Client) ListBindings(ctx context.Context) ([]binding.Binding, error) {
|
||||
|
||||
func (c *Client) ListDispatches(ctx context.Context, filter storecontract.DispatchFilter) ([]storecontract.Dispatch, error) {
|
||||
r, err := c.client.ListDispatches(ctx, &pb.ListDispatchesRequest{
|
||||
BindingId: filter.BindingID, CaptureId: filter.CaptureID, TaskId: filter.TaskID, Limit: int32(filter.Limit), //nolint:gosec // the store clamps it
|
||||
BindingId: filter.BindingID, CaptureId: filter.CaptureID, TaskId: filter.TaskID, Limit: int32(filter.Limit), // the store clamps it
|
||||
})
|
||||
if err != nil {
|
||||
return nil, unmapError(err)
|
||||
|
||||
@@ -54,7 +54,7 @@ func mapValues[A, B any](in []A, f func(A) B) []B {
|
||||
return out
|
||||
}
|
||||
|
||||
func taskProto(t *task.Task) *pb.Task { //nolint:dupl // mirror-image field-by-field proto<->domain mapping; taskValue below reverses every assignment, so line-level duplication is unavoidable without reflection
|
||||
func taskProto(t *task.Task) *pb.Task { // mirror-image field-by-field proto<->domain mapping; taskValue below reverses every assignment, so line-level duplication is unavoidable without reflection
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -86,7 +86,7 @@ func taskProto(t *task.Task) *pb.Task { //nolint:dupl // mirror-image field-by-f
|
||||
}
|
||||
}
|
||||
|
||||
func taskValue(t *pb.Task) *task.Task { //nolint:dupl // see taskProto above
|
||||
func taskValue(t *pb.Task) *task.Task { // see taskProto above
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package webui
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@@ -267,6 +266,3 @@ func matchPrefix(path, prefix string) bool {
|
||||
func matchSegment(path, prefix, suffix string) bool {
|
||||
return strings.HasPrefix(path, prefix) && strings.HasSuffix(path, suffix)
|
||||
}
|
||||
|
||||
// The log the authorize wrapper reports assembly failures with.
|
||||
var _ = slog.Default //nolint:unused // logging stays on s.Log
|
||||
Reference in new issue
Block a user