Skip to content

Commit 1f1cf6c

Browse files
committed
feat: refactor
1 parent 64b11b9 commit 1f1cf6c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/golinters/misspell.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ func runMisspellOnFile(lintCtx *linter.Context, filename string, replacer *missp
161161
}
162162

163163
func appendExtraWords(replacer *misspell.Replacer, extraWords []config.MisspellExtraWords) error {
164-
var extra []string
164+
if len(extraWords) == 0 {
165+
return nil
166+
}
167+
168+
extra := make([]string, len(extraWords))
165169

166170
for _, word := range extraWords {
167171
if word.Typo == "" || word.Correction == "" {
@@ -178,9 +182,7 @@ func appendExtraWords(replacer *misspell.Replacer, extraWords []config.MisspellE
178182
extra = append(extra, strings.ToLower(word.Typo), strings.ToLower(word.Correction))
179183
}
180184

181-
if len(extra) > 0 {
182-
replacer.AddRuleList(extra)
183-
}
185+
replacer.AddRuleList(extra)
184186

185187
return nil
186188
}

0 commit comments

Comments
 (0)