fix(lint): address errcheck and De Morgan's law violations in doctor/fix
- Handle file.Close() errors in deletions.go and deletions_test.go - Simplify boolean logic to apply De Morgan's law in common.go - All golangci-lint checks now pass
This commit is contained in:
@@ -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)))
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user