Keep newFromSmartConfig within the length limit (closes #64)
check / check (push) Successful in 3m0s

Rebasing onto the four settings from
#142 put newFromSmartConfig at 82
lines, over the linter's 80-line limit. validateKnownKeys now returns
early for a nil config (no config file) itself, as lookupValue already
does, so the caller drops its own nil check. Behavior is unchanged.

Model: opus-5-5
This commit is contained in:
2026-09-29 06:57:04 +00:00
parent 3a7af08838
commit 7a348655ee
+7 -4
View File
@@ -236,14 +236,12 @@ func New(_ fx.Lifecycle, params Params) (*Config, error) {
// unparseable or invalid is an error: defaults apply only to omitted // unparseable or invalid is an error: defaults apply only to omitted
// keys, never to invalid explicit values. // keys, never to invalid explicit values.
func newFromSmartConfig(sc *smartconfig.Config) (*Config, error) { func newFromSmartConfig(sc *smartconfig.Config) (*Config, error) {
if sc != nil {
err := validateKnownKeys(sc) err := validateKnownKeys(sc)
if err != nil { if err != nil {
return nil, err return nil, err
} }
}
err := validateAllowlistHostsValue(sc) err = validateAllowlistHostsValue(sc)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -337,8 +335,13 @@ func newFromSmartConfig(sc *smartconfig.Config) (*Config, error) {
// being silently ignored, and rejects keys that are explicitly set to // being silently ignored, and rejects keys that are explicitly set to
// null: a null is a SET value, never an omission, so it must not // null: a null is a SET value, never an omission, so it must not
// silently take the default. The env section is permitted because // silently take the default. The env section is permitted because
// smartconfig consumes it for environment variable injection. // smartconfig consumes it for environment variable injection. A nil sc
// means no config file, which has no keys to check.
func validateKnownKeys(sc *smartconfig.Config) error { func validateKnownKeys(sc *smartconfig.Config) error {
if sc == nil {
return nil
}
var unknown, nullKeys []string var unknown, nullKeys []string
for key, value := range sc.Data() { for key, value := range sc.Data() {