From 091be2653ac9c771f91054fc4dadd20cc4f69f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Tue, 19 May 2026 09:47:52 +0400 Subject: [PATCH] Enforce multiline rule for single multiline arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update go-style guide and cursor rule to clarify that even a single argument spanning multiple lines must break after the opening parenthesis. Fix six violations across the branch. Signed-off-by: Émile Ré --- contrib/claude/go-style.md | 27 ++++++++++++++ pkg/agent/tools/search/firecrawl.go | 23 +++++++----- pkg/cookiebanner/pattern_analysis_worker.go | 36 +++++++++++-------- pkg/coredata/common_tracker_pattern.go | 11 +++--- .../common_tracker_patterns.go | 15 ++++---- 5 files changed, 78 insertions(+), 34 deletions(-) diff --git a/contrib/claude/go-style.md b/contrib/claude/go-style.md index 05304334a..bf68a0966 100644 --- a/contrib/claude/go-style.md +++ b/contrib/claude/go-style.md @@ -106,6 +106,33 @@ t.Run( svc, err := foo.NewService(ctx, db, logger, foo.Config{ Interval: 10 * time.Second, }) + +// Bad — single multiline argument starts on the opening ( line +body, err := json.Marshal(firecrawlRequest{ + Query: query, + Limit: maxResults, +}) + +// Good — single multiline argument: break after (, trailing comma, ) alone +body, err := json.Marshal( + firecrawlRequest{ + Query: query, + Limit: maxResults, + }, +) + +// Bad — function literal starts on the opening ( line +sort.Slice(items, func(i, j int) bool { + return items[i].Name < items[j].Name +}) + +// Good — function literal on its own line +sort.Slice( + items, + func(i, j int) bool { + return items[i].Name < items[j].Name + }, +) ``` The same rule applies to **method calls** `x.M(a1, …)` — the receiver is already bound; the rule applies to the **argument list** after the method name. diff --git a/pkg/agent/tools/search/firecrawl.go b/pkg/agent/tools/search/firecrawl.go index 91163248e..86f940747 100644 --- a/pkg/agent/tools/search/firecrawl.go +++ b/pkg/agent/tools/search/firecrawl.go @@ -91,10 +91,12 @@ func firecrawlSearch( return nil, fmt.Errorf("cannot build search URL: %w", err) } - body, err := json.Marshal(firecrawlRequest{ - Query: query, - Limit: maxResults, - }) + body, err := json.Marshal( + firecrawlRequest{ + Query: query, + Limit: maxResults, + }, + ) if err != nil { return nil, fmt.Errorf("cannot marshal request: %w", err) } @@ -132,11 +134,14 @@ func firecrawlSearch( results := make([]searchResult, 0, len(fcResp.Data.Web)) for _, r := range fcResp.Data.Web { - results = append(results, searchResult{ - Title: r.Title, - URL: r.URL, - Snippet: r.Description, - }) + results = append( + results, + searchResult{ + Title: r.Title, + URL: r.URL, + Snippet: r.Description, + }, + ) } return results, nil diff --git a/pkg/cookiebanner/pattern_analysis_worker.go b/pkg/cookiebanner/pattern_analysis_worker.go index 0ec5ef8b3..f3ad65f8f 100644 --- a/pkg/cookiebanner/pattern_analysis_worker.go +++ b/pkg/cookiebanner/pattern_analysis_worker.go @@ -306,18 +306,21 @@ func findMergeGroups( // Sort: heuristic first, then descending specificity (more fixed // characters), then descending coverage, then template name for a // fully deterministic order. - sort.Slice(candidates, func(i, j int) bool { - if candidates[i].isHeuristic != candidates[j].isHeuristic { - return candidates[i].isHeuristic - } - if candidates[i].fixedChars != candidates[j].fixedChars { - return candidates[i].fixedChars > candidates[j].fixedChars - } - if len(candidates[i].patterns) != len(candidates[j].patterns) { - return len(candidates[i].patterns) > len(candidates[j].patterns) - } - return candidates[i].key.template < candidates[j].key.template - }) + sort.Slice( + candidates, + func(i, j int) bool { + if candidates[i].isHeuristic != candidates[j].isHeuristic { + return candidates[i].isHeuristic + } + if candidates[i].fixedChars != candidates[j].fixedChars { + return candidates[i].fixedChars > candidates[j].fixedChars + } + if len(candidates[i].patterns) != len(candidates[j].patterns) { + return len(candidates[i].patterns) > len(candidates[j].patterns) + } + return candidates[i].key.template < candidates[j].key.template + }, + ) assigned := make(map[*coredata.TrackerPattern]bool) groups := make(map[mergeGroupKey][]*coredata.TrackerPattern) @@ -598,9 +601,12 @@ func (h *patternAnalysisHandler) adoptUncategorisedPatterns( return false, nil } - sort.Slice(globPatterns, func(i, j int) bool { - return len(globPatterns[i].Pattern) > len(globPatterns[j].Pattern) - }) + sort.Slice( + globPatterns, + func(i, j int) bool { + return len(globPatterns[i].Pattern) > len(globPatterns[j].Pattern) + }, + ) exactMatchType := coredata.TrackerPatternMatchTypeExact var uncategorisedExact coredata.TrackerPatterns diff --git a/pkg/coredata/common_tracker_pattern.go b/pkg/coredata/common_tracker_pattern.go index 29a5f6ba3..ca9e82bdd 100644 --- a/pkg/coredata/common_tracker_pattern.go +++ b/pkg/coredata/common_tracker_pattern.go @@ -251,10 +251,13 @@ RETURNING id, (xmax = 0) AS inserted Inserted bool } - res, err := pgx.CollectExactlyOneRow(rows, func(row pgx.CollectableRow) (upsertResult, error) { - var r upsertResult - return r, row.Scan(&r.ID, &r.Inserted) - }) + res, err := pgx.CollectExactlyOneRow( + rows, + func(row pgx.CollectableRow) (upsertResult, error) { + var r upsertResult + return r, row.Scan(&r.ID, &r.Inserted) + }, + ) if err != nil { return gid.GID{}, false, fmt.Errorf("cannot collect upsert result: %w", err) } diff --git a/pkg/proboctl/seed/common-tracker-patterns/common_tracker_patterns.go b/pkg/proboctl/seed/common-tracker-patterns/common_tracker_patterns.go index 43f3ab187..a91b8e2dd 100644 --- a/pkg/proboctl/seed/common-tracker-patterns/common_tracker_patterns.go +++ b/pkg/proboctl/seed/common-tracker-patterns/common_tracker_patterns.go @@ -344,12 +344,15 @@ var domainValidRe = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9.-]*[a-zA-Z]$`) func normalizeDomain(s string) string { s = strings.TrimSpace(s) - s = strings.Map(func(r rune) rune { - if r == '\u200b' || r == '\ufeff' { - return -1 - } - return r - }, s) + s = strings.Map( + func(r rune) rune { + if r == '\u200b' || r == '\ufeff' { + return -1 + } + return r + }, + s, + ) if idx := strings.Index(s, " or "); idx != -1 { s = s[:idx]