Type ProcessOptions.Source to prevent typoed scan labels #29

Open
opened 2026-05-12 09:34:45 +02:00 by heiko · 1 comment
Owner

Found during review of #24.

scanner.ProcessOptions.Source is a free-form string. Callers pass literal "initial", "startup", "idle". Typos would silently produce wrong scan labels and only get caught (if at all) by the brittle source-string regression tests.

Suggested change:

type ScanSource string

const (
    ScanInitial ScanSource = "initial"
    ScanStartup ScanSource = "startup"
    ScanIdle    ScanSource = "idle"
)

type ProcessOptions struct {
    ReportProcessed bool
    Source          ScanSource
}

The wire-format value is preserved; callers gain compile-time safety.

Refs: PR #24

Found during review of #24. `scanner.ProcessOptions.Source` is a free-form string. Callers pass literal `"initial"`, `"startup"`, `"idle"`. Typos would silently produce wrong scan labels and only get caught (if at all) by the brittle source-string regression tests. Suggested change: ```go type ScanSource string const ( ScanInitial ScanSource = "initial" ScanStartup ScanSource = "startup" ScanIdle ScanSource = "idle" ) type ProcessOptions struct { ReportProcessed bool Source ScanSource } ``` The wire-format value is preserved; callers gain compile-time safety. Refs: PR #24
Author
Owner

Related commit: 2305c33. ProcessOptions.Source is still a string in the current tree, so the typo risk described in this finding still exists.

Related commit: 2305c33. ProcessOptions.Source is still a string in the current tree, so the typo risk described in this finding still exists.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
IUS/xr-invoiced#29
No description provided.