Skip to content

Commit f7db534

Browse files
committed
fix: gofumpt formatting + go mod tidy
1 parent ff74109 commit f7db534

18 files changed

Lines changed: 115 additions & 88 deletions

autofix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ type AutoFix struct {
1515
// FixSuggestion is a proposed code change to resolve a finding.
1616
type FixSuggestion struct {
1717
Finding *Finding
18-
FixedCode string // the corrected code
19-
Explanation string // why this fix works
18+
FixedCode string // the corrected code
19+
Explanation string // why this fix works
2020
Confidence float64 // 0-1 how confident the fix is correct
2121
}
2222

checks_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enabled: true
2626
Do not use console.log or fmt.Println for debugging.
2727
Remove all debug logging before merge.
2828
`
29-
if err := os.WriteFile(filepath.Join(dir, "no-debug-logging.md"), []byte(content), 0644); err != nil {
29+
if err := os.WriteFile(filepath.Join(dir, "no-debug-logging.md"), []byte(content), 0o644); err != nil {
3030
t.Fatal(err)
3131
}
3232

@@ -62,7 +62,7 @@ Remove all debug logging before merge.
6262
func TestLoadChecks_NoFrontmatter(t *testing.T) {
6363
dir := t.TempDir()
6464
content := "Check that all errors are wrapped with context before returning."
65-
if err := os.WriteFile(filepath.Join(dir, "wrap-errors.md"), []byte(content), 0644); err != nil {
65+
if err := os.WriteFile(filepath.Join(dir, "wrap-errors.md"), []byte(content), 0o644); err != nil {
6666
t.Fatal(err)
6767
}
6868

@@ -96,7 +96,7 @@ enabled: false
9696
---
9797
This check is disabled.
9898
`
99-
if err := os.WriteFile(filepath.Join(dir, "disabled-check.md"), []byte(content), 0644); err != nil {
99+
if err := os.WriteFile(filepath.Join(dir, "disabled-check.md"), []byte(content), 0o644); err != nil {
100100
t.Fatal(err)
101101
}
102102

@@ -114,9 +114,9 @@ This check is disabled.
114114

115115
func TestLoadChecks_SkipsNonMarkdown(t *testing.T) {
116116
dir := t.TempDir()
117-
os.WriteFile(filepath.Join(dir, "check.md"), []byte("valid check"), 0644)
118-
os.WriteFile(filepath.Join(dir, "notes.txt"), []byte("not a check"), 0644)
119-
os.WriteFile(filepath.Join(dir, "data.json"), []byte("{}"), 0644)
117+
os.WriteFile(filepath.Join(dir, "check.md"), []byte("valid check"), 0o644)
118+
os.WriteFile(filepath.Join(dir, "notes.txt"), []byte("not a check"), 0o644)
119+
os.WriteFile(filepath.Join(dir, "data.json"), []byte("{}"), 0o644)
120120

121121
checks, err := LoadChecks(dir)
122122
if err != nil {
@@ -145,10 +145,10 @@ func TestCustomChecksToConcerns_FiltersDisabled(t *testing.T) {
145145
func TestLoadChecksFromRepo(t *testing.T) {
146146
dir := t.TempDir()
147147
checksDir := filepath.Join(dir, ".sight", "checks")
148-
if err := os.MkdirAll(checksDir, 0755); err != nil {
148+
if err := os.MkdirAll(checksDir, 0o755); err != nil {
149149
t.Fatal(err)
150150
}
151-
os.WriteFile(filepath.Join(checksDir, "test.md"), []byte("test check"), 0644)
151+
os.WriteFile(filepath.Join(checksDir, "test.md"), []byte("test check"), 0o644)
152152

153153
checks, err := LoadChecksFromRepo(dir)
154154
if err != nil {

config.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import (
99

1010
// FileConfig represents the contents of a .sight.toml configuration file.
1111
type FileConfig struct {
12-
Model string `json:"model"`
13-
Concerns []string `json:"concerns"`
14-
FailOn string `json:"fail_on"`
15-
MaxTokens int `json:"max_tokens"`
16-
Exclude []string `json:"exclude"`
17-
GitContext *bool `json:"git_context"`
18-
Reflection *bool `json:"reflection"`
19-
Parallel *bool `json:"parallel"`
20-
Prompts map[string]string `json:"prompts"`
12+
Model string `json:"model"`
13+
Concerns []string `json:"concerns"`
14+
FailOn string `json:"fail_on"`
15+
MaxTokens int `json:"max_tokens"`
16+
Exclude []string `json:"exclude"`
17+
GitContext *bool `json:"git_context"`
18+
Reflection *bool `json:"reflection"`
19+
Parallel *bool `json:"parallel"`
20+
Prompts map[string]string `json:"prompts"`
2121
}
2222

2323
// LoadConfigFile reads .sight.toml from the given directory (or parents).

config_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func TestApplyFileConfig_Empty(t *testing.T) {
203203
func TestFindConfigFile_Found(t *testing.T) {
204204
dir := t.TempDir()
205205
configPath := filepath.Join(dir, ".sight.toml")
206-
if err := os.WriteFile(configPath, []byte("model = \"gpt-4\""), 0644); err != nil {
206+
if err := os.WriteFile(configPath, []byte("model = \"gpt-4\""), 0o644); err != nil {
207207
t.Fatal(err)
208208
}
209209

@@ -216,11 +216,11 @@ func TestFindConfigFile_Found(t *testing.T) {
216216
func TestFindConfigFile_ParentDir(t *testing.T) {
217217
parent := t.TempDir()
218218
child := filepath.Join(parent, "sub", "dir")
219-
if err := os.MkdirAll(child, 0755); err != nil {
219+
if err := os.MkdirAll(child, 0o755); err != nil {
220220
t.Fatal(err)
221221
}
222222
configPath := filepath.Join(parent, ".sight.toml")
223-
if err := os.WriteFile(configPath, []byte("model = \"gpt-4\""), 0644); err != nil {
223+
if err := os.WriteFile(configPath, []byte("model = \"gpt-4\""), 0o644); err != nil {
224224
t.Fatal(err)
225225
}
226226

@@ -233,7 +233,7 @@ func TestFindConfigFile_ParentDir(t *testing.T) {
233233
func TestFindConfigFile_AlternateNames(t *testing.T) {
234234
dir := t.TempDir()
235235
configPath := filepath.Join(dir, "sight.toml")
236-
if err := os.WriteFile(configPath, []byte("model = \"gpt-4\""), 0644); err != nil {
236+
if err := os.WriteFile(configPath, []byte("model = \"gpt-4\""), 0o644); err != nil {
237237
t.Fatal(err)
238238
}
239239

@@ -246,7 +246,7 @@ func TestFindConfigFile_AlternateNames(t *testing.T) {
246246
func TestFindConfigFile_JSONFormat(t *testing.T) {
247247
dir := t.TempDir()
248248
configPath := filepath.Join(dir, ".sight.json")
249-
if err := os.WriteFile(configPath, []byte(`{"model": "gpt-4"}`), 0644); err != nil {
249+
if err := os.WriteFile(configPath, []byte(`{"model": "gpt-4"}`), 0o644); err != nil {
250250
t.Fatal(err)
251251
}
252252

@@ -266,8 +266,8 @@ func TestFindConfigFile_NotFound(t *testing.T) {
266266

267267
func TestFindConfigFile_PrioritizesToml(t *testing.T) {
268268
dir := t.TempDir()
269-
os.WriteFile(filepath.Join(dir, ".sight.toml"), []byte("model = \"a\""), 0644)
270-
os.WriteFile(filepath.Join(dir, ".sight.json"), []byte(`{"model": "b"}`), 0644)
269+
os.WriteFile(filepath.Join(dir, ".sight.toml"), []byte("model = \"a\""), 0o644)
270+
os.WriteFile(filepath.Join(dir, ".sight.json"), []byte(`{"model": "b"}`), 0o644)
271271

272272
found := findConfigFile(dir)
273273
expected := filepath.Join(dir, ".sight.toml")
@@ -294,7 +294,7 @@ model = "gpt-4"
294294
fail_on = "high"
295295
max_tokens = 4096
296296
`
297-
if err := os.WriteFile(filepath.Join(dir, ".sight.toml"), []byte(content), 0644); err != nil {
297+
if err := os.WriteFile(filepath.Join(dir, ".sight.toml"), []byte(content), 0o644); err != nil {
298298
t.Fatal(err)
299299
}
300300

eval.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ func matchesSingleExpectation(exp EvalExpectation, f Finding) bool {
147147
}
148148
}
149149
if exp.MessageContains != "" && !strings.Contains(
150-
strings.ToLower(f.Message), strings.ToLower(exp.MessageContains)) {
150+
strings.ToLower(f.Message), strings.ToLower(exp.MessageContains),
151+
) {
151152
return false
152153
}
153154
if exp.File != "" && !strings.EqualFold(f.File, exp.File) {
@@ -171,7 +172,8 @@ func matchesSingleDenial(deny EvalDenial, f Finding) bool {
171172
return false
172173
}
173174
if deny.MessageContains != "" && !strings.Contains(
174-
strings.ToLower(f.Message), strings.ToLower(deny.MessageContains)) {
175+
strings.ToLower(f.Message), strings.ToLower(deny.MessageContains),
176+
) {
175177
return false
176178
}
177179
return true

eval_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ func TestLoadEvalSuite(t *testing.T) {
454454

455455
dir := t.TempDir()
456456
path := filepath.Join(dir, "suite.json")
457-
if err := os.WriteFile(path, []byte(suiteJSON), 0644); err != nil {
457+
if err := os.WriteFile(path, []byte(suiteJSON), 0o644); err != nil {
458458
t.Fatalf("failed to write temp file: %v", err)
459459
}
460460

filter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ type FilterResult struct {
3131
}
3232

3333
func FilterFindings(ctx context.Context, provider Provider, findings []Finding,
34-
fileContents map[string]string, config FilterConfig) ([]Finding, []FilterResult, error) {
35-
34+
fileContents map[string]string, config FilterConfig,
35+
) ([]Finding, []FilterResult, error) {
3636
if provider == nil {
3737
return findings, nil, ErrNoProvider
3838
}

incremental.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// IncrementalState tracks the last-reviewed commit SHA for incremental reviews.
1313
// It is safe for concurrent use.
1414
type IncrementalState struct {
15-
mu sync.Mutex
15+
mu sync.Mutex
1616
lastReviewedSHA string
1717
}
1818

internal/context/git.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ func Blame(file string, startLine, endLine int) (string, error) {
8989
return "", fmt.Errorf("git blame: invalid path: %w", err)
9090
}
9191

92-
args := []string{"blame", "--line-porcelain",
92+
args := []string{
93+
"blame", "--line-porcelain",
9394
"-L", strconv.Itoa(startLine) + "," + strconv.Itoa(endLine),
94-
"--", file}
95+
"--", file,
96+
}
9597

9698
out, err := exec.Command("git", args...).Output()
9799
if err != nil {

internal/output/output.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ type Stats struct {
3232
DurationPerConcern map[string]time.Duration
3333
}
3434

35-
var severityNames = [...]string{"INFO", "LOW", "MEDIUM", "HIGH", "CRITICAL"}
36-
var severityColors = [...]string{"\033[36m", "\033[34m", "\033[33m", "\033[31m", "\033[35;1m"}
35+
var (
36+
severityNames = [...]string{"INFO", "LOW", "MEDIUM", "HIGH", "CRITICAL"}
37+
severityColors = [...]string{"\033[36m", "\033[34m", "\033[33m", "\033[31m", "\033[35;1m"}
38+
)
3739

38-
const reset = "\033[0m"
39-
const bold = "\033[1m"
40-
const dim = "\033[2m"
40+
const (
41+
reset = "\033[0m"
42+
bold = "\033[1m"
43+
dim = "\033[2m"
44+
)
4145

4246
// FormatTerminal renders a human-readable review report with ANSI colors.
4347
func FormatTerminal(findings []Finding, stats Stats) string {

0 commit comments

Comments
 (0)