Skip to content

Commit

Permalink
MINOR: add more words to globally accepted list
Browse files Browse the repository at this point in the history
  • Loading branch information
oktalz committed Aug 8, 2024
1 parent 92e4f25 commit 57466a6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
11 changes: 0 additions & 11 deletions .aspell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@ ignore:
allowed:
- aspell
- repo
- yaml
- config
- Github
- Gitlab
- env
- failsafe
- golang
- mkdir
- WORKDIR
- apk
- ENTRYPOINT
- ubuntu
- golangci
- splitted
- sudo
- mri
- IID
- repo
Expand All @@ -32,9 +24,6 @@ allowed:
- MINSUBJECTPARTS
- malformatted
- cmdline
- Dockerfile
- ghcr
- sed
- stdin
- runnumber
- args
27 changes: 20 additions & 7 deletions aspell/aspell.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,27 @@ type Aspell struct {
}

var (
camelCaseOK = map[string]struct{}{
"HAProxy": {},
acceptableWordsGlobal = map[string]struct{}{
"haproxy": {},
"golang": {},
"ascii": {},
"api": {},
"goreleaser": {},
"github": {},
"gitlab": {},
"yaml": {},
"env": {},
"config": {},
"workdir": {},
"entrypoint": {},
"sudo": {},
"dockerfile": {},
"ghcr": {},
"sed": {},
"stdin": {},
"args": {},
}
camelCaseNotOK = map[string]struct{}{}
badWordsGlobal = map[string]struct{}{}
)

func (a Aspell) checkSingle(data string, allowedWords []string) error {
Expand All @@ -50,11 +63,11 @@ func (a Aspell) checkSingle(data string, allowedWords []string) error {
if len(word) < a.MinLength {
continue
}
if _, ok := camelCaseNotOK[wordLower]; ok {
if _, ok := badWordsGlobal[wordLower]; ok {
badWords = append(badWords, wordLower)
continue
}
if _, ok := camelCaseOK[wordLower]; ok {
if _, ok := acceptableWordsGlobal[wordLower]; ok {
continue
}
if slices.Contains(a.AllowedWords, wordLower) || slices.Contains(allowedWords, wordLower) {
Expand All @@ -70,13 +83,13 @@ func (a Aspell) checkSingle(data string, allowedWords []string) error {
for _, s := range splitted {
er := a.checkSingle(s, allowedWords)
if er != nil {
camelCaseNotOK[wordLower] = struct{}{}
badWordsGlobal[wordLower] = struct{}{}
badWords = append(badWords, word+":"+s)
break
}
}
} else {
camelCaseNotOK[wordLower] = struct{}{}
badWordsGlobal[wordLower] = struct{}{}
badWords = append(badWords, word)
}
}
Expand Down

0 comments on commit 57466a6

Please sign in to comment.