Skip to content

Commit 751ee39

Browse files
committed
fix: resolve lint and staticcheck CI failures
Fix errcheck on Close() calls, remove unused func firstWordLower, simplify loop to append spread, and add staticcheck directive for deprecated toml API.
1 parent 8d5d6c9 commit 751ee39

4 files changed

Lines changed: 8 additions & 14 deletions

File tree

internal/compress/caveman_safety.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,6 @@ func isUpperLetter(b byte) bool {
221221
return b >= 'A' && b <= 'Z'
222222
}
223223

224-
// firstWordLower returns the first whitespace-delimited word of s,
225-
// lower-cased. Empty if s has no word.
226-
func firstWordLower(s string) string {
227-
fields := strings.Fields(s)
228-
if len(fields) == 0 {
229-
return ""
230-
}
231-
return strings.ToLower(fields[0])
232-
}
233224

234225
// isCJK reports whether s is primarily CJK characters (Chinese/Japanese/Korean).
235226
// Used to decide if the caveman rules even apply — CJK text doesn't have

internal/filter/toml_filter.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// command output before it enters the main compression layers. Each
55
// filter is defined as a TOML section with these stages:
66
//
7+
// staticcheck:ignore SA1019 — toml.PrimitiveDecode is deprecated but has
8+
// no direct replacement in the current go-toml API for this decode pattern.
9+
//
710
// 1. match_command - regex that selects this filter for a given command
811
// 2. strip_ansi - bool, strip ANSI escape sequences
912
// 3. replace - array of {pattern, replacement} regex pairs
@@ -109,11 +112,13 @@ func LoadTOMLFilterFile(path string) (*TOMLFilterFile, error) {
109112
return nil, fmt.Errorf("toml_filter: decode %s: %w", path, err)
110113
}
111114
if v, ok := raw["schema_version"]; ok {
115+
//nolint:staticcheck // PrimitiveDecode is deprecated but still the simplest API for this use case
112116
_ = toml.PrimitiveDecode(v, &f.Schema)
113117
delete(raw, "schema_version")
114118
}
115119
for name, prim := range raw {
116120
cfg := &TOMLFilterConfig{Name: name}
121+
//nolint:staticcheck // PrimitiveDecode is deprecated but still the simplest API for this use case
117122
if err := toml.PrimitiveDecode(prim, cfg); err != nil {
118123
return nil, fmt.Errorf("toml_filter: decode section [%s] in %s: %w", name, path, err)
119124
}
@@ -417,9 +422,7 @@ func readDir(dir string) ([]string, error) {
417422
return nil, err
418423
}
419424
names := make([]string, 0, len(entries))
420-
for _, e := range entries {
421-
names = append(names, e)
422-
}
425+
names = append(names, entries...)
423426
return names, nil
424427
}
425428

internal/tracking/tracking.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func (t *Tracker) Recent(ctx context.Context, n int) ([]Event, error) {
236236
if err != nil {
237237
return nil, fmt.Errorf("tracking: recent: %w", err)
238238
}
239-
defer rows.Close()
239+
defer func() { _ = rows.Close() }()
240240
var out []Event
241241
for rows.Next() {
242242
var ev Event

tracker_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func TestNewTracker_AtCustomPath(t *testing.T) {
1515
if err != nil {
1616
t.Fatalf("NewTrackerAt: %v", err)
1717
}
18-
defer tr.Close()
18+
defer func() { _ = tr.Close() }()
1919

2020
ctx := context.Background()
2121
if err := tr.Record(ctx, tok.TrackerEvent{

0 commit comments

Comments
 (0)