Skip to content

Commit

Permalink
linter fixes (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldemailly authored Oct 28, 2023
1 parent 19347b5 commit 12dd5e2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
13 changes: 4 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Config for golanglint-ci
# Config for golangci-lint

# output configuration options

Expand Down Expand Up @@ -45,14 +45,6 @@ linters-settings:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).FErrf
enable-all: true
disable-all: false
depguard:
list-type: blacklist
include-go-root: false
packages:
- github.com/sirupsen/logrus
packages-with-error-message:
# specify an error message to output when a blacklisted package is used
- github.com/sirupsen/logrus: "logging is allowed only by fortio.log"
lll:
# max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
Expand Down Expand Up @@ -82,6 +74,8 @@ linters-settings:

linters:
disable:
# bad ones:
- musttag
# Deprecated ones:
- scopelint
- golint
Expand Down Expand Up @@ -113,6 +107,7 @@ linters:
- cyclop
- forcetypeassert
- ireturn
- depguard
enable-all: true
disable-all: false
# Must not use fast: true in newer golangci-lint or it'll just skip a bunch of linter instead of doing caching like before (!)
Expand Down
6 changes: 2 additions & 4 deletions configmap/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,10 @@ func (u *Updater) readAll(dynamicOnly bool) error {
fullPath := path.Join(u.dirPath, f.Name())
log.S(log.Debug, "checking flag", log.Str("flag", f.Name()), log.Str("path", fullPath))
if err := u.readFlagFile(fullPath, dynamicOnly); err != nil {
if errors.Is(err, errFlagNotDynamic) && dynamicOnly {
// ignore
} else if errors.Is(err, errFlagNotFound) {
if errors.Is(err, errFlagNotFound) {
log.S(log.Warning, "config map for unknown flag", log.Str("flag", f.Name()), log.Str("path", fullPath))
u.warnings.Add(1)
} else {
} else if !(errors.Is(err, errFlagNotDynamic) && dynamicOnly) {
errorStrings = append(errorStrings, fmt.Sprintf("flag %v: %v", f.Name(), err.Error()))
}
}
Expand Down
2 changes: 1 addition & 1 deletion dyngeneric.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func New[T DynValueTypes](value T, usage string) *DynValue[T] {
return &dynValue
}

// Flag assigns a dynamic value to a command line flag.
// Flag binds a dynamic value to a command line flag.
// e.g. in a library:
//
// var Value1 = dflag.New("default value", "explanation for value1's usage")
Expand Down
4 changes: 2 additions & 2 deletions dynloglevel/dynloglevel.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func ChangeFlagsDefault(newDefault string, flagNames ...string) {
for _, flagName := range flagNames {
f := flag.Lookup(flagName)
if f == nil {
log.Fatalf("flag %s not found", flagName)
continue // not reached but linter doesn't know Fatalf panics/exits
log.Fatalf("flag %s not found", flagName) //nolint:revive // we know it's unreachable after
continue // not reached but linter doesn't know Fatalf panics/exits
}
f.DefValue = newDefault
err := f.Value.Set(newDefault)
Expand Down

0 comments on commit 12dd5e2

Please sign in to comment.