diff --git a/cmd/bd/doctor/fix/common.go b/cmd/bd/doctor/fix/common.go index edc665ec..b019b9c4 100644 --- a/cmd/bd/doctor/fix/common.go +++ b/cmd/bd/doctor/fix/common.go @@ -86,5 +86,5 @@ func isWithinWorkspace(root, candidate string) bool { if err != nil { return false } - return rel == "." || !(rel == ".." || strings.HasPrefix(rel, ".."+string(os.PathSeparator))) + return rel == "." || (rel != ".." && !strings.HasPrefix(rel, ".."+string(os.PathSeparator))) } diff --git a/cmd/bd/doctor/fix/deletions.go b/cmd/bd/doctor/fix/deletions.go index 76449de7..df587fdd 100644 --- a/cmd/bd/doctor/fix/deletions.go +++ b/cmd/bd/doctor/fix/deletions.go @@ -106,7 +106,9 @@ func getCurrentJSONLIDs(jsonlPath string) (map[string]bool, error) { } return nil, err } - defer file.Close() + defer func() { + _ = file.Close() + }() scanner := bufio.NewScanner(file) scanner.Buffer(make([]byte, 0, 64*1024), 10*1024*1024) @@ -161,14 +163,16 @@ func looksLikeIssueID(id string) bool { // Prefix should be alphanumeric (letters/numbers/underscores) prefix := id[:dashIdx] for _, c := range prefix { - if !((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_') { + isValidPrefixChar := (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' + if !isValidPrefixChar { return false } } // Suffix should be alphanumeric (base36 hash or number), may contain dots for children suffix := id[dashIdx+1:] for _, c := range suffix { - if !((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.') { + isValidSuffixChar := (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' + if !isValidSuffixChar { return false } } diff --git a/cmd/bd/doctor/fix/deletions_test.go b/cmd/bd/doctor/fix/deletions_test.go index 76f49765..a8eb11af 100644 --- a/cmd/bd/doctor/fix/deletions_test.go +++ b/cmd/bd/doctor/fix/deletions_test.go @@ -47,11 +47,11 @@ func TestGetCurrentJSONLIDs_SkipsTombstones(t *testing.T) { encoder := json.NewEncoder(file) for _, issue := range issues { if err := encoder.Encode(issue); err != nil { - file.Close() + _ = file.Close() t.Fatalf("Failed to write issue to JSONL: %v", err) } } - file.Close() + _ = file.Close() // Call getCurrentJSONLIDs ids, err := getCurrentJSONLIDs(jsonlPath)