Skip to content

Commit b36891d

Browse files
refactor: rename Version to MinVersion in Config
1 parent 4517df1 commit b36891d

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

config/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func GetConfig(confPath string) (*lint.Config, error) {
4242
return nil, errors.New("conf error: formatter is empty")
4343
}
4444

45-
err = checkVersion(conf.Version)
45+
err = isValidVersion(conf.MinVersion)
4646
if err != nil {
4747
return nil, err
4848
}
@@ -107,7 +107,7 @@ func Validate(conf *lint.Config) []error {
107107
}
108108
}
109109

110-
err := checkVersion(conf.Version)
110+
err := isValidVersion(conf.MinVersion)
111111
if err != nil {
112112
errs = append(errs, err)
113113
}
@@ -161,14 +161,14 @@ func WriteToFile(outFilePath string, conf *lint.Config) (retErr error) {
161161
return enc.Encode(conf)
162162
}
163163

164-
func checkVersion(versionNo string) error {
164+
func isValidVersion(versionNo string) error {
165165
if versionNo == "" {
166166
return errors.New("version is empty")
167167
}
168168
if !semver.IsValid(versionNo) {
169169
return errors.New("invalid version should be in semver format")
170170
}
171-
return checkIfMinVersion(versionNo)
171+
return nil
172172
}
173173

174174
func checkIfMinVersion(versionNo string) error {

config/default.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
)
99

1010
var defConf = &lint.Config{
11-
Version: internal.Version(),
11+
MinVersion: internal.Version(),
1212

1313
Formatter: (&formatter.DefaultFormatter{}).Name(),
1414

@@ -156,9 +156,9 @@ func GetDefaultConfig(onlyEnabled bool) *lint.Config {
156156
}
157157

158158
confClone := &lint.Config{
159-
Version: defConf.Version,
160-
Formatter: defConf.Formatter,
161-
Rules: map[string]lint.RuleConfig{},
159+
MinVersion: defConf.MinVersion,
160+
Formatter: defConf.Formatter,
161+
Rules: map[string]lint.RuleConfig{},
162162
}
163163

164164
for ruleName, r := range defConf.Rules {

config/lint.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
// GetLinter returns Linter for given confFilePath
1111
func GetLinter(conf *lint.Config) (*lint.Linter, error) {
12-
err := checkIfMinVersion(conf.Version)
12+
err := checkIfMinVersion(conf.MinVersion)
1313
if err != nil {
1414
return nil, err
1515
}
@@ -23,7 +23,7 @@ func GetLinter(conf *lint.Config) (*lint.Linter, error) {
2323

2424
// GetFormatter returns the formatter as defined in conf
2525
func GetFormatter(conf *lint.Config) (lint.Formatter, error) {
26-
err := checkIfMinVersion(conf.Version)
26+
err := checkIfMinVersion(conf.MinVersion)
2727
if err != nil {
2828
return nil, err
2929
}

lint/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ type RuleConfig struct {
1414

1515
// Config represent linter config
1616
type Config struct {
17-
// Version is the minimum version required
17+
// MinVersion is the minimum version of commitlint required
1818
// should be in semver format
19-
Version string `yaml:"version"`
19+
MinVersion string `yaml:"version"`
2020

2121
// Formatter of the lint result
2222
Formatter string `yaml:"formatter"`

0 commit comments

Comments
 (0)