Skip to content

Commit 45fabf9

Browse files
author
Test User
committed
fix(lint): resolve golangci-lint errors for CI
- Fix errcheck: suppress git config errors in test setup - Remove unused code: componentType field, normalizeHeadings, trimTrailingWhitespace, parseJSON - Fix gosimple: use variadic append for toolWarnings - Fix staticcheck: replace deprecated strings.Title with cases.Title - Remove unused imports (encoding/json, regexp)
1 parent f08d66d commit 45fabf9

7 files changed

Lines changed: 9 additions & 34 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require (
88
github.com/charmbracelet/lipgloss v1.1.0
99
github.com/spf13/cobra v1.10.2
1010
github.com/spf13/viper v1.21.0
11+
golang.org/x/text v0.32.0
1112
gopkg.in/yaml.v3 v3.0.1
1213
)
1314

@@ -44,7 +45,6 @@ require (
4445
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 // indirect
4546
golang.org/x/net v0.48.0 // indirect
4647
golang.org/x/sys v0.39.0 // indirect
47-
golang.org/x/text v0.32.0 // indirect
4848
golang.org/x/tools v0.40.0 // indirect
4949
google.golang.org/protobuf v1.36.11 // indirect
5050
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect

internal/cli/agent_linter.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ func (l *AgentLinter) ValidateSpecific(data map[string]interface{}, filePath, co
5151

5252
// Validate allowed-tools
5353
toolWarnings := ValidateAllowedTools(data, filePath, contents)
54-
for _, w := range toolWarnings {
55-
errors = append(errors, w)
56-
}
54+
errors = append(errors, toolWarnings...)
5755

5856
return errors
5957
}

internal/cli/command_linter.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ func (l *CommandLinter) ValidateSpecific(data map[string]interface{}, filePath,
4848

4949
// Validate allowed-tools
5050
toolWarnings := ValidateAllowedTools(data, filePath, contents)
51-
for _, w := range toolWarnings {
52-
errors = append(errors, w)
53-
}
51+
errors = append(errors, toolWarnings...)
5452

5553
return errors
5654
}

internal/cli/lineutil.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"strings"
77

88
"github.com/dotcommander/cclint/internal/cue"
9+
"golang.org/x/text/cases"
10+
"golang.org/x/text/language"
911
)
1012

1113
// FindLineNumber finds the line number (1-based) where a pattern first appears
@@ -372,7 +374,7 @@ func ValidateToolFieldName(data map[string]interface{}, filePath string, content
372374
if _, hasTools := data["tools"]; hasTools {
373375
errors = append(errors, cue.ValidationError{
374376
File: filePath,
375-
Message: fmt.Sprintf("%ss must use 'allowed-tools:', not 'tools:'. Rename the field.", strings.Title(componentType)),
377+
Message: fmt.Sprintf("%ss must use 'allowed-tools:', not 'tools:'. Rename the field.", cases.Title(language.English).String(componentType)),
376378
Severity: "error",
377379
Source: cue.SourceCClintObserve,
378380
Line: FindFrontmatterFieldLine(contents, "tools"),

internal/cli/settings.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cli
22

33
import (
4-
"encoding/json"
54
"fmt"
65
"regexp"
76
"strings"
@@ -18,11 +17,6 @@ func LintSettings(rootPath string, quiet bool, verbose bool, noCycleCheck bool)
1817
return lintBatch(ctx, NewSettingsLinter()), nil
1918
}
2019

21-
// parseJSON parses JSON content into the provided interface
22-
func parseJSON(content string, out interface{}) error {
23-
return json.Unmarshal([]byte(content), out)
24-
}
25-
2620
// Valid hook events according to Anthropic documentation
2721
var validHookEvents = map[string]bool{
2822
"PreToolUse": true,

internal/format/formatter.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package format
33
import (
44
"bytes"
55
"fmt"
6-
"regexp"
76
"sort"
87
"strings"
98

@@ -19,9 +18,7 @@ type Formatter interface {
1918
}
2019

2120
// ComponentFormatter provides base formatting for all component types.
22-
type ComponentFormatter struct {
23-
componentType string
24-
}
21+
type ComponentFormatter struct{}
2522

2623
// NewComponentFormatter creates a formatter for a specific component type.
2724
func NewComponentFormatter(componentType string) Formatter {
@@ -284,17 +281,3 @@ func Diff(original, formatted, filename string) string {
284281

285282
return buf.String()
286283
}
287-
288-
// normalizeHeadings ensures consistent heading levels.
289-
// This is a placeholder for more sophisticated heading normalization.
290-
func normalizeHeadings(content string) string {
291-
// For now, just return as-is. Future: normalize ## to consistent levels.
292-
return content
293-
}
294-
295-
// trimTrailingWhitespace removes trailing whitespace from lines.
296-
var trailingWhitespaceRegex = regexp.MustCompile(`[ \t]+$`)
297-
298-
func trimTrailingWhitespace(line string) string {
299-
return trailingWhitespaceRegex.ReplaceAllString(line, "")
300-
}

internal/git/diff_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ func TestGitIntegration(t *testing.T) {
215215
}
216216

217217
// Configure git user (required for commits)
218-
exec.Command("git", "config", "user.email", "test@test.com").Run()
219-
exec.Command("git", "config", "user.name", "Test User").Run()
218+
_ = exec.Command("git", "config", "user.email", "test@test.com").Run()
219+
_ = exec.Command("git", "config", "user.name", "Test User").Run()
220220

221221
// Create test files
222222
agentPath := filepath.Join(tmpDir, "agents", "test-agent.md")

0 commit comments

Comments
 (0)