Skip to content

Commit f4e2a01

Browse files
fix(config): validate conf in GetConfig, not in Parse
1 parent cbceb0b commit f4e2a01

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

config/config.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const (
1818
ConfFileName = "commitlint.yaml"
1919
)
2020

21-
// GetConfig returns parses config file and returns Config instance
22-
func GetConfig(flagConfPath string) (*lint.Config, error) {
23-
confFilePath, useDefault, err := GetConfigPath(flagConfPath)
21+
// GetConfig returns parses config file, validate it and returns config instance
22+
func GetConfig(confPath string) (*lint.Config, error) {
23+
confFilePath, useDefault, err := GetConfigPath(confPath)
2424
if err != nil {
2525
return nil, err
2626
}
@@ -33,6 +33,11 @@ func GetConfig(flagConfPath string) (*lint.Config, error) {
3333
if err != nil {
3434
return nil, err
3535
}
36+
37+
err = Validate(conf)
38+
if err != nil {
39+
return nil, fmt.Errorf("config: %w", err)
40+
}
3641
return conf, nil
3742
}
3843

@@ -74,11 +79,6 @@ func Parse(confPath string) (*lint.Config, error) {
7479
if err != nil {
7580
return nil, err
7681
}
77-
78-
err = Validate(conf)
79-
if err != nil {
80-
return nil, fmt.Errorf("config: %w", err)
81-
}
8282
return conf, nil
8383
}
8484

0 commit comments

Comments
 (0)