Skip to content

Commit

Permalink
refactor: use if-else instead of switch for bool
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Dec 11, 2024
1 parent 61ffb56 commit ffd62fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
13 changes: 6 additions & 7 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,17 @@ func (config *Config) walkIndex(index RuleIndex, key string, list Ls) error {
}

if reflect.TypeOf(v).Kind() == reflect.Map {
switch key == "" {
case true:
if key == "" {
if err := config.walkIndex(index, k, v.(Ls)); err != nil {
return err
}
case false:
keyCombination := fmt.Sprintf("%s%s%s", key, sep, k)
if err := config.walkIndex(index, keyCombination, v.(Ls)); err != nil {
return err
}
continue
}

keyCombination := fmt.Sprintf("%s%s%s", key, sep, k)
if err := config.walkIndex(index, keyCombination, v.(Ls)); err != nil {
return err
}
continue
}

Expand Down
5 changes: 2 additions & 3 deletions internal/linter/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,9 @@ func (linter *Linter) Run(filesystem fs.FS, paths map[string]struct{}, debug boo
if debug {
fmt.Printf("=============================\nls index\n-----------------------------\n")
for path, pathIndex := range index {
switch path == "" {
case true:
if path == "" {
fmt.Printf(".:")
case false:
} else {
fmt.Printf("%s:", path)
}

Expand Down

0 comments on commit ffd62fd

Please sign in to comment.