LightBitsLabs / los-csi

Lightbits LightOS CSI Plugin
Other
0 stars 2 forks source link

Draft: Linter #5

Closed majst01 closed 2 years ago

majst01 commented 2 years ago

Current code does show some errors by golangci-lint:

golangci-lint run 
pkg/lb/lbgrpc/client.go:140:2: SA1019: r.cc.NewAddress is deprecated: Use UpdateState instead. (staticcheck)
        r.cc.NewAddress(addrs)
        ^
pkg/util/endpoint/endpoint.go:148:9: S1005: unnecessary assignment to the blank identifier (gosimple)
        for k, _ := range uniq {
               ^
pkg/lb/clientpool.go:371:12: SA4003: no value of type uint64 is less than 0 (staticcheck)
        } else if pm.rc < 0 {
                  ^
pkg/util/strlist/strlist.go:32:9: S1005: unnecessary assignment to the blank identifier (gosimple)
        for k, _ := range uniq {
               ^
pkg/driver/driver.go:53:2: `accessModesCache` is unused (deadcode)
        accessModesCache []*csi.VolumeCapability_AccessMode
        ^
pkg/driver/status.go:78:6: `mkEExecOsErr` is unused (deadcode)
func mkEExecOsErr(errno syscall.Errno, desc string) error {
     ^
main.go:85:2: `jwt` is unused (deadcode)
        jwt = flag.StringP("jwt", "j", "",
        ^
pkg/driver/driver.go:343:20: Error return value of `watcher.Remove` is not checked (errcheck)
                                        watcher.Remove(event.Name)
                                                      ^
pkg/driver/driver.go:345:17: Error return value of `watcher.Add` is not checked (errcheck)
                                        watcher.Add(jwtFile)
                                                   ^
main.go:138:29: Error return value of `flag.CommandLine.MarkHidden` is not checked (errcheck)
        flag.CommandLine.MarkHidden("transport")
                                   ^
main.go:139:29: Error return value of `flag.CommandLine.MarkHidden` is not checked (errcheck)
        flag.CommandLine.MarkHidden("squelch-panics")
                                   ^
main.go:140:29: Error return value of `flag.CommandLine.MarkHidden` is not checked (errcheck)
        flag.CommandLine.MarkHidden("pretty-json")
                                   ^
pkg/driver/node.go:350:2: assign: self-assignment of vid to vid (govet)
        vid = vid
        ^
pkg/driver/node.go:564:2: assign: self-assignment of vid to vid (govet)
        vid = vid
        ^

With this PR, all of them are fixed and a github action ensures no new errors get added.

When we create additional code we want to ensure that we dont add additional errors.

Important: GH Actions are enable if master branch contains the relevant .github/workflows folder

majst01 commented 2 years ago

closing in favour of #7