Crc: golangci-lint report

Created on 12 Jun 2019  路  3Comments  路  Source: code-ready/crc

I've used https://github.com/golangci/golangci-lint on crc project. And I think some of them might be important. Could you please take a look

pkg/crc/systemd/host.go:13:2: `commander` is unused (structcheck)
    commander SystemdCommander
    ^
cmd/crc/cmd/config/config.go:49:12: Error return value of `cmd.Help` is not checked (errcheck)
            cmd.Help()
                    ^
cmd/crc/cmd/root.go:23:11: Error return value of `cmd.Help` is not checked (errcheck)
        cmd.Help()
                ^
cmd/crc/cmd/root.go:37:18: Error return value of `config.InitViper` is not checked (errcheck)
    config.InitViper()
                    ^
cmd/crc/cmd/start.go:23:23: Error return value of `crcConfig.BindFlagSet` is not checked (errcheck)
    crcConfig.BindFlagSet(startCmd.Flags())
                         ^
pkg/crc/config/viper_config.go:61:16: Error return value of `f.WriteString` is not checked (errcheck)
        f.WriteString("{}")
                     ^
pkg/crc/errors/atexit.go:47:14: Error return value of `output.OutW` is not checked (errcheck)
        output.OutW(os.Stdout, fmt.Sprintf(text, args...))
                   ^
pkg/crc/errors/atexit.go:49:14: Error return value of `output.OutW` is not checked (errcheck)
        output.OutW(os.Stderr, fmt.Sprintf(text, args...))
                   ^
pkg/crc/machine/bundle/extract.go:68:11: Error return value of `io.Copy` is not checked (errcheck)
            io.Copy(writer, tarBallReader)
                   ^
pkg/crc/network/template.go:23:11: Error return value of `t.Execute` is not checked (errcheck)
    t.Execute(&resolvFile, values)
             ^
pkg/crc/oc/oc_cache.go:109:7: Error return value of `copy` is not checked (errcheck)
        copy(binaryPath, finalBinaryPath)
            ^
pkg/crc/services/dns/dns.go:41:33: Error return value of `drivers.RunSSHCommandFromDriver` is not checked (errcheck)
    drivers.RunSSHCommandFromDriver(serviceConfig.Driver, "sudo podman rm -f dnsmasq")
                                   ^
pkg/crc/services/dns/dns_darwin.go:53:11: Error return value of `t.Execute` is not checked (errcheck)
    t.Execute(&resolverFile, values)
             ^
pkg/crc/services/dns/template.go:73:11: Error return value of `t.Execute` is not checked (errcheck)
    t.Execute(&dnsConfigFile, values)
             ^
pkg/crc/state/global.go:71:16: Error return value of `json.Unmarshal` is not checked (errcheck)
    json.Unmarshal(raw, &cfg)
                  ^
pkg/crc/systemd/host.go:45:16: Error return value of `c.DaemonReload` is not checked (errcheck)
    c.DaemonReload()
                  ^
pkg/crc/systemd/host.go:55:16: Error return value of `c.DaemonReload` is not checked (errcheck)
    c.DaemonReload()
                  ^
pkg/crc/systemd/host.go:65:16: Error return value of `c.DaemonReload` is not checked (errcheck)
    c.DaemonReload()
                  ^
pkg/extract/extract.go:106:15: Error return value of `os.MkdirAll` is not checked (errcheck)
            os.MkdirAll(path, file.Mode())
                       ^
pkg/crc/machine/bundle/extract.go:29:6: ineffectual assignment to `fileReader` (ineffassign)
    var fileReader io.Reader = file
        ^
pkg/crc/services/dns/dns_darwin.go:31:2: ineffectual assignment to `success` (ineffassign)
    success, err := createResolverFile(serviceConfig.IP, filepath.Join("/", "etc", "resolver", serviceConfig.BundleMetadata.ClusterInfo.BaseDomain))
    ^
pkg/crc/services/dns/dns_darwin.go:72:6: ineffectual assignment to `stderr` (ineffassign)
        _, stderr, err := crcos.RunWithDefaultLocale("networksetup", "-setnetworkserviceenabled", netdevice, "off")
           ^
pkg/crc/machine/machine.go:301:20: ineffectual assignment to `err` (ineffassign)
    jsonDriverConfig, err := json.Marshal(driverOptions)
                      ^
pkg/crc/preflight/preflight_checks_darwin.go:40:3: ineffectual assignment to `path` (ineffassign)
        path, err = os.Readlink(path)
        ^
pkg/crc/output/output.go:17:9: printf: missing ... in args forwarded to print-like function (govet)
    return fmt.Fprintln(w, args)
           ^
cmd/crc/cmd/start.go:74:2: S1008: should use 'return <expr>' instead of 'if <expr> { return <bool> }; return <bool>' (gosimple)
    if logging.LogLevel == "debug" {
    ^
pkg/crc/config/viper_config.go:60:3: SA5001: should check returned error before deferring f.Close() (staticcheck)
        defer f.Close()
        ^
pkg/crc/machine/machine.go:89:10: SA4006: this value of `err` is never used (staticcheck)
    exists, err := existVM(libMachineAPIClient, machineConfig)
            ^
pkg/crc/machine/machine.go:107:9: SA4006: this value of `err` is never used (staticcheck)
        host, err := libMachineAPIClient.Load(machineConfig.Name)
              ^
pkg/crc/machine/machine.go:140:8: SA4006: this value of `err` is never used (staticcheck)
    host, err := libMachineAPIClient.Load(machineConfig.Name)
          ^
pkg/crc/oc/oc_cache.go:127:2: SA5001: should check returned error before deferring srcFile.Close() (staticcheck)
    defer srcFile.Close()
    ^
pkg/crc/oc/oc_cache.go:133:2: SA5001: should check returned error before deferring destFile.Close() (staticcheck)
    defer destFile.Close()
    ^
pkg/crc/services/dns/dns_darwin.go:71:14: SA1004: sleeping for 2 nanoseconds is probably a bug. Be explicit if it isn't: time.Sleep(2 * time.Nanosecond) (staticcheck)
        time.Sleep(2)
                   ^

kinbug

Most helpful comment

Here is example of how you can add this to Makefile https://github.com/openshift/hive/blob/master/Makefile#L205-L212. golangci-lint is a lint aggregator.

All 3 comments

For example

pkg/crc/services/dns/dns_darwin.go:71:14: SA1004: sleeping for 2 nanoseconds is probably a bug. Be explicit if it isn't: time.Sleep(2 * time.Nanosecond) (staticcheck)
        time.Sleep(2)
                   ^

Are you sure this is 2 nanosecond and not 2 seconds?

Great, I think we should add this in our CI 馃憤

Here is example of how you can add this to Makefile https://github.com/openshift/hive/blob/master/Makefile#L205-L212. golangci-lint is a lint aggregator.

Was this page helpful?
0 / 5 - 0 ratings