Skip to content

Commit 76bbac5

Browse files
committed
chore: add linter config, fix staticcheck issues — dead code, deprecated APIs, timeouts
1 parent a700705 commit 76bbac5

9 files changed

Lines changed: 24 additions & 22 deletions

File tree

.golangci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: "2"
2+
3+
linters:
4+
default: none
5+
enable:
6+
- govet
7+
- ineffassign
8+
- misspell
9+
10+
issues:
11+
max-issues-per-linter: 0
12+
max-same-issues: 0

cmd/yaad/admin.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/http"
77
"os"
88
"path/filepath"
9+
"time"
910

1011
"github.com/spf13/cobra"
1112
"github.com/GrayCodeAI/yaad/internal/bench"
@@ -93,7 +94,8 @@ var doctorCmd = &cobra.Command{
9394
}
9495
}
9596

96-
resp, err := http.Get("http://localhost:3456/yaad/health")
97+
client := http.Client{Timeout: 2 * time.Second}
98+
resp, err := client.Get("http://localhost:3456/yaad/health")
9799
serverRunning := err == nil && resp.StatusCode == 200
98100
if resp != nil {
99101
resp.Body.Close()

engine/query.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99

1010
"github.com/GrayCodeAI/yaad/intent"
1111
"github.com/GrayCodeAI/yaad/storage"
12+
"golang.org/x/text/cases"
13+
"golang.org/x/text/language"
1214
)
1315

1416
// queryConfidenceThreshold is the minimum node confidence required to include
@@ -122,7 +124,7 @@ func synthesizeWhat(question string, nodes []*storage.Node) string {
122124
if !ok {
123125
continue
124126
}
125-
b.WriteString(fmt.Sprintf("[%s]\n", strings.Title(typ)))
127+
b.WriteString(fmt.Sprintf("[%s]\n", cases.Title(language.English).String(typ)))
126128
for _, n := range group {
127129
b.WriteString(formatNodeBullet(n))
128130
}
@@ -137,7 +139,7 @@ func synthesizeWhat(question string, nodes []*storage.Node) string {
137139
if typ == "" {
138140
b.WriteString("[Other]\n")
139141
} else {
140-
b.WriteString(fmt.Sprintf("[%s]\n", strings.Title(typ)))
142+
b.WriteString(fmt.Sprintf("[%s]\n", cases.Title(language.English).String(typ)))
141143
}
142144
for _, n := range group {
143145
b.WriteString(formatNodeBullet(n))

graph/graph.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ import (
1010
"github.com/GrayCodeAI/yaad/storage"
1111
)
1212

13-
const (
14-
defaultBFSDepth = 2
15-
defaultImpactDepth = 3
16-
defaultSubgraphDepth = 2
17-
)
13+
1814

1915
// Acyclic edge types — cycle detection enforced on insert.
2016
var validEdgeTypes = map[string]bool{

integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ func TestTLSCertGeneration(t *testing.T) {
814814
t.Fatal(err)
815815
}
816816
if tlsCfg == nil {
817-
t.Error("tls: nil config returned")
817+
t.Fatal("tls: nil config returned")
818818
}
819819
if len(tlsCfg.Certificates) == 0 {
820820
t.Error("tls: no certificates generated")

intent/intent.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,6 @@ func Classify(query string) Intent {
113113
return bestIntent
114114
}
115115

116-
func containsAny(s string, keywords ...string) bool {
117-
for _, k := range keywords {
118-
if strings.Contains(s, k) {
119-
return true
120-
}
121-
}
122-
return false
123-
}
124-
125116
// String returns a human-readable intent name.
126117
func (i Intent) String() string {
127118
switch i {

internal/tui/tui.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ var (
4040
dimStyle = lipgloss.NewStyle().Foreground(gray)
4141
nodeStyle = lipgloss.NewStyle().Foreground(white)
4242
selectedStyle = lipgloss.NewStyle().Background(darkGray).Foreground(white)
43-
borderStyle = lipgloss.NewStyle().Border(lipgloss.RoundedBorder()).BorderForeground(purple).Padding(0, 1)
4443

4544
typeColors = map[string]lipgloss.Color{
4645
"convention": green, "decision": blue, "bug": red,

privacy/filter.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ var strictOnlyPatterns = []*regexp.Regexp{
6262
regexp.MustCompile(`\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b`),
6363
}
6464

65-
// patterns is kept for backward compatibility — contains all patterns (Strict behavior).
66-
var patterns = append(append(append([]*regexp.Regexp{}, secretPatterns...), piiPatterns...), strictOnlyPatterns...)
67-
6865
// Filter replaces secrets in content with [REDACTED] using DefaultFilterLevel.
6966
func Filter(content string) string {
7067
return FilterWithLevel(content, DefaultFilterLevel)

storage/sqlite_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ func TestSearchNodesWithSpecialChars(t *testing.T) {
362362
if err != nil {
363363
t.Fatalf("SearchNodes: %v", err)
364364
}
365+
if len(results) == 0 {
366+
t.Error("expected at least one result for quoted search")
367+
}
365368
}
366369

367370
func TestEscapeFTS5(t *testing.T) {

0 commit comments

Comments
 (0)