Skip to content

Commit 0ad1a7e

Browse files
refactor(config)!: rename functions and constants
* rename GetDefaultConf to DefaultConfig * rename WriteConfToFile to WriteToFile * rename DefaultFile to ConfigFileName
1 parent 899aa49 commit 0ad1a7e

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

cmd/callback.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ func hookCreate(confPath string, isReplace bool) error {
4848

4949
// configCreate is the callback function for create config command
5050
func configCreate(onlyEnabled, isReplace bool) error {
51-
defConf := config.GetDefaultConf(onlyEnabled)
52-
outPath := filepath.Join(".", config.DefaultFile)
51+
defConf := config.DefaultConfig(onlyEnabled)
52+
outPath := filepath.Join(".", config.ConfigFile)
5353
// if config file already exists skip creating or overwriting it
5454
if _, err := os.Stat(outPath); !os.IsNotExist(err) {
5555
if !isReplace {
5656
return errConfigExist
5757
}
5858
}
59-
return config.WriteConfToFile(outPath, defConf)
59+
return config.WriteToFile(outPath, defConf)
6060
}
6161

6262
// configCheck is the callback function for check/verify command

config/config.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515
)
1616

1717
const (
18-
// DefaultFile represent default config file name
19-
DefaultFile = "commitlint.yaml"
18+
// ConfigFile represent default config file name
19+
ConfigFile = "commitlint.yaml"
2020
)
2121

2222
// GetConfig gets the config according to precedence
@@ -59,7 +59,7 @@ func getConfigPath(confFilePath string) (confPath string, isDefault bool, retErr
5959
}
6060

6161
// check if conf file exists in current directory
62-
currentDirConf := filepath.Join(currentDir, DefaultFile)
62+
currentDirConf := filepath.Join(currentDir, ConfigFile)
6363
if _, err1 := os.Stat(currentDirConf); !os.IsNotExist(err1) {
6464
return currentDirConf, false, nil
6565
}
@@ -130,8 +130,8 @@ func Validate(conf *lint.Config) []error {
130130
return errs
131131
}
132132

133-
// WriteConfToFile util func to write config object to given file
134-
func WriteConfToFile(outFilePath string, conf *lint.Config) (retErr error) {
133+
// WriteToFile util func to write config object to given file
134+
func WriteToFile(outFilePath string, conf *lint.Config) (retErr error) {
135135
file, err := os.Create(outFilePath)
136136
if err != nil {
137137
return err

config/default.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ var defaultRules = []lint.Rule{
179179
&rule.DescriptionMinLenRule{},
180180
}
181181

182-
// GetDefaultConf writes default config to given file
183-
func GetDefaultConf(onlyEnabled bool) *lint.Config {
182+
// DefaultConfig writes default config to given file
183+
func DefaultConfig(onlyEnabled bool) *lint.Config {
184184
if !onlyEnabled {
185185
return defConf
186186
}

0 commit comments

Comments
 (0)