coreos-assembler
coreos-assembler copied to clipboard
Mantle Code base could use some TLC
Since golint is deprecated, I was looking at using golangci-lint (the new hotness for linting GoLang) for entrypoint and checked out Mantle. The following report shows that we could improve our code quality (and make our testing a lot safer).
If we can clean this up, I would like to bring in golanci-lint to check both Mantle and Entrypoint. Some of these errors like gosimple are not functional but would improve the readability.
ben@porpentina:~/src/cosa/mantle $ golangci-lint -j 16 --color never --timeout=180s run ./... | tee lint.txt
lang/maps/sorted_test.go:66:9: S1005: unnecessary assignment to the blank identifier (gosimple)
for k, _ := range testMap {
^
lang/maps/sorted_test.go:92:9: S1005: unnecessary assignment to the blank identifier (gosimple)
for k, _ := range testMap {
^
kola/tests/rhcos/upgrade.go:29:5: `plog` is unused (deadcode)
var plog = capnslog.NewPackageLogger("github.com/coreos/mantle", "kola/tests/upgrade")
^
kola/tests/rhcos/luks.go:211:10: Error return value of `m.Reboot` is not checked (errcheck)
m.Reboot()
^
kola/tests/rhcos/luks.go:179:3: printf: Fatal call has possible formatting directive %s (govet)
c.Fatal("Failed to match regexp %s: %v", r, err)
^
kola/tests/rhcos/luks.go:182:3: printf: Fatal call has possible formatting directive %s (govet)
c.Fatal("Regexp %s did not match text: %s", r, output)
^
kola/tests/rhcos/luks.go:189:3: printf: Fatal call has possible formatting directive %s (govet)
c.Fatal("Failed to match regexp %s: %v", r, err)
^
cmd/kola/kola.go:118:2: `extDependencyDir` is unused (deadcode)
extDependencyDir string
^
cmd/kola/kola.go:473:6: `runArtifactIgnitionVersion` is unused (deadcode)
func runArtifactIgnitionVersion(cmd *cobra.Command, args []string) error {
^
cmd/kola/devshell.go:199:18: Error return value of `serialLog.Seek` is not checked (errcheck)
serialLog.Seek(0, os.SEEK_SET)
^
cmd/kola/devshell.go:311:16: Error return value of `proc.Signal` is not checked (errcheck)
proc.Signal(os.Interrupt)
^
cmd/kola/kola.go:483:13: Error return value of `errors.New` is not checked (errcheck)
errors.New("Error: missing required argument --build")
^
cmd/kola/qemuexec.go:231:17: Error return value of `builder.AddIso` is not checked (errcheck)
builder.AddIso(kola.QEMUIsoOptions.IsoPath, "")
^
cmd/kola/switchkernel.go:93:34: Error return value of `cmdSwitchKernel.MarkFlagRequired` is not checked (errcheck)
cmdSwitchKernel.MarkFlagRequired("kernel-rt")
^
cmd/kola/testiso.go:171:18: Error return value of `builder.AddDisk` is not checked (errcheck)
builder.AddDisk(&platform.Disk{
^
cmd/kola/testiso.go:177:25: Error return value of `builder.AddPrimaryDisk` is not checked (errcheck)
builder.AddPrimaryDisk(&platform.Disk{
^
cmd/kola/testiso.go:458:20: Error return value of `mach.Destroy` is not checked (errcheck)
defer mach.Destroy()
^
cmd/kola/testiso.go:499:20: Error return value of `mach.Destroy` is not checked (errcheck)
defer mach.Destroy()
^
cmd/kola/testiso.go:513:16: Error return value of `builder.AddIso` is not checked (errcheck)
builder.AddIso(isopath, "")
^
cmd/kola/switchkernel.go:180:2: S1038: should use fmt.Printf instead of fmt.Println(fmt.Sprintf(...)) (but don't forget the newline) (gosimple)
fmt.Println(fmt.Sprintf("%s", stderr))
^
cmd/kola/switchkernel.go:181:2: S1038: should use fmt.Printf instead of fmt.Println(fmt.Sprintf(...)) (but don't forget the newline) (gosimple)
fmt.Println(fmt.Sprintf("%s", stdout))
^
cmd/kola/switchkernel.go:210:2: S1038: should use fmt.Printf instead of fmt.Println(fmt.Sprintf(...)) (but don't forget the newline) (gosimple)
fmt.Println(fmt.Sprintf("%s", stderr))
^
cmd/kola/testiso.go:370:3: S1021: should merge variable declaration with assignment on next line (gosimple)
var err error
^
cmd/kola/qemuexec.go:95:4: S1023: redundant break statement (gosimple)
break
^
cmd/kola/devshell.go:206:8: S1005: unnecessary assignment to the blank identifier (gosimple)
case _ = <-readychan:
^
cmd/kola/testiso.go:355:13: S1039: unnecessary use of fmt.Sprintf (gosimple)
msg := fmt.Sprintf("entered emergency.target in initramfs")
^
cmd/kolet/kolet.go:143:11: Error return value of `cmd.Usage` is not checked (errcheck)
cmd.Usage()
^
cmd/kolet/kolet.go:160:15: Error return value of `cmd.Usage` is not checked (errcheck)
cmd.Usage()
^
cmd/kolet/kolet.go:197:19: Error return value of `sdconn.StartUnit` is not checked (errcheck)
sdconn.StartUnit(unitname, "fail", nil)
^
cmd/kolet/kolet.go:300:20: Error return value of `dispatchRunExtUnit` is not checked (errcheck)
dispatchRunExtUnit(unitname, sdconn)
^
auth/google.go:71:26: SA1019: oauth2.NoContext is deprecated: Use context.Background() or context.TODO() instead. (staticcheck)
ts := conf.TokenSource(oauth2.NoContext, tok)
^
auth/google.go:101:28: SA1019: oauth2.NoContext is deprecated: Use context.Background() or context.TODO() instead. (staticcheck)
tok, err = conf.Exchange(oauth2.NoContext, code)
^
auth/google.go:123:21: SA1019: oauth2.NoContext is deprecated: Use context.Background() or context.TODO() instead. (staticcheck)
return conf.Client(oauth2.NoContext, tok), nil
^
platform/api/do/api.go:167:18: Error return value of `a.DeleteDroplet` is not checked (errcheck)
a.DeleteDroplet(ctx, dropletID)
^
platform/api/do/api.go:264:16: Error return value of `a.DeleteImage` is not checked (errcheck)
a.DeleteImage(ctx, imageID)
^
update/signature/signature.go:28:2: SA1019: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead. (staticcheck)
"github.com/golang/protobuf/proto"
^
update/signature/signature_test.go:22:2: SA1019: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead. (staticcheck)
"github.com/golang/protobuf/proto"
^
update/operation.go:139:33: SA1019: os.SEEK_SET is deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd. (staticcheck)
if _, err := dst.Seek(offset, os.SEEK_SET); err != nil {
^
update/updater.go:117:28: SA1019: os.SEEK_SET is deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd. (staticcheck)
if _, err := file.Seek(0, os.SEEK_SET); err != nil {
^
update/payload.go:25:2: SA1019: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead. (staticcheck)
"github.com/golang/protobuf/proto"
^
kola/tests/docker/docker.go:385:18: Error return value of `cluster.DropFile` is not checked (errcheck)
cluster.DropFile(c.Machines(), oldclient)
^
kola/tests/docker/docker.go:497:12: Error return value of `util.Retry` is not checked (errcheck)
util.Retry(12, 6*time.Second, func() error {
^
cmd/ore/gcloud/upload.go:53:28: Error return value of `cmdUpload.MarkFlagRequired` is not checked (errcheck)
cmdUpload.MarkFlagRequired("bucket")
^
cmd/ore/gcloud/upload.go:55:28: Error return value of `cmdUpload.MarkFlagRequired` is not checked (errcheck)
cmdUpload.MarkFlagRequired("name")
^
cmd/ore/gcloud/upload.go:57:28: Error return value of `cmdUpload.MarkFlagRequired` is not checked (errcheck)
cmdUpload.MarkFlagRequired("file")
^
cmd/ore/gcloud/create-image.go:95:21: SA1019: storage.New is deprecated: please use NewService instead. To provide a custom HTTP client, use option.WithHTTPClient. If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. (staticcheck)
storageAPI, err := storage.New(api.Client())
^
cmd/ore/gcloud/promote-image.go:95:6: SA1019: image.Deprecated is deprecated: The deprecation status associated with this image. (staticcheck)
if image.Deprecated != nil {
^
cmd/ore/gcloud/promote-image.go:97:17: SA1019: image.Deprecated is deprecated: The deprecation status associated with this image. (staticcheck)
image.Name, image.Deprecated.State)
^
cmd/ore/gcloud/promote-image.go:104:6: SA1019: image.Deprecated is deprecated: The deprecation status associated with this image. (staticcheck)
if image.Deprecated == nil ||
^
cmd/ore/gcloud/upload.go:100:21: SA1019: storage.New is deprecated: please use NewService instead. To provide a custom HTTP client, use option.WithHTTPClient. If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. (staticcheck)
storageAPI, err := storage.New(api.Client())
^
harness/harness.go:124:26: Error return value of `outputBufferCopy.WriteTo` is not checked (errcheck)
outputBufferCopy.WriteTo(p.w)
^
harness/harness.go:235:17: Error return value of `c.logger.Output` is not checked (errcheck)
c.logger.Output(3, s)
^
harness/harness.go:393:17: S1012: should use `time.Since` instead of `time.Now().Sub` (gosimple)
t.duration += time.Now().Sub(t.start)
^
update/generator/full.go:65:31: SA1019: os.SEEK_SET is deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd. (staticcheck)
if _, err := payload.Seek(0, os.SEEK_SET); err != nil {
^
sdk/download.go:180:6: `getUrlStream` is unused (deadcode)
func getUrlStream(url string, client *http.Client) (*http.Response, error) {
^
sdk/repo.go:36:6: `isDir` is unused (deadcode)
func isDir(dir string) bool {
^
sdk/repo.go:41:6: `envDir` is unused (deadcode)
func envDir(env string) string {
^
sdk/verify.go:74:64: SA4009: argument err is overwritten before first use (staticcheck)
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
^
sdk/download.go:48:15: SA1019: storage.New is deprecated: please use NewService instead. To provide a custom HTTP client, use option.WithHTTPClient. If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. (staticcheck)
api, err := storage.New(client)
^
platform/machine/qemuiso/cluster.go:115:16: Error return value of `builder.AddIso` is not checked (errcheck)
builder.AddIso(qc.flight.opts.IsoPath, "")
^
network/journal/format.go:60:17: Error return value of `io.WriteString` is not checked (errcheck)
io.WriteString(s.w, "-- Reboot --\n")
^
platform/api/aws/ec2.go:203:23: Error return value of `a.TerminateInstances` is not checked (errcheck)
a.TerminateInstances(ids)
^
platform/api/openstack/api.go:312:17: Error return value of `a.DeleteServer` is not checked (errcheck)
a.DeleteServer(serverID)
^
platform/api/openstack/api.go:320:18: Error return value of `a.DeleteServer` is not checked (errcheck)
a.DeleteServer(serverID)
^
platform/api/openstack/api.go:327:18: Error return value of `a.DeleteServer` is not checked (errcheck)
a.DeleteServer(serverID)
^
platform/api/openstack/api.go:330:22: Error return value of `a.deleteFloatingIP` is not checked (errcheck)
a.deleteFloatingIP(floatingip.ID)
^
platform/api/openstack/api.go:430:25: Error return value of `a.deleteSecurityGroup` is not checked (errcheck)
a.deleteSecurityGroup(securityGroup.ID)
^
platform/api/openstack/api.go:521:16: Error return value of `a.DeleteImage` is not checked (errcheck)
a.DeleteImage(image.ID)
^
platform/api/openstack/api.go:528:16: Error return value of `a.DeleteImage` is not checked (errcheck)
a.DeleteImage(image.ID)
^
platform/api/openstack/api.go:133:17: ineffectual assignment to `err` (ineffassign)
networkClient, err := openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{
^
kola/tests/podman/podman.go:290:6: `podmanNetworkTest` is unused (deadcode)
func podmanNetworkTest(c cluster.TestCluster) {
^
kola/tests/podman/podman.go:193:6: S1002: should omit comparison to bool constant, can be simplified to `!found` (gosimple)
if found == false {
^
kola/tests/podman/podman.go:214:6: S1002: should omit comparison to bool constant, can be simplified to `found` (gosimple)
if found == true {
^
cmd/ore/do/create-image.go:111:21: Error return value of `API.DeleteKey` is not checked (errcheck)
defer API.DeleteKey(ctx, keyID)
^
cmd/ore/do/create-image.go:118:25: Error return value of `API.DeleteDroplet` is not checked (errcheck)
defer API.DeleteDroplet(ctx, dropletID)
^
cosa/build.go:94:14: Error return value of `errors.New` is not checked (errcheck)
errors.New("data is not compliant with schema")
^
cosa/schema.go:65:10: ineffectual assignment to `err` (ineffassign)
result, err := schema.Validate(
^
cosa/schema_test.go:34:5: SA5011: possible nil pointer dereference (staticcheck)
b.Name = ""
^
kola/tests/upgrade/basic.go:277:3: printf: Fatalf format %v reads arg #1, but call has 0 args (govet)
c.Fatalf("failed to marshal graph: %v")
^
network/ntp/protocol_test.go:90:18: Error return value of `h.MarshalBinary` is not checked (errcheck)
h.MarshalBinary()
^
network/ntp/protocol_test.go:100:20: Error return value of `h.UnmarshalBinary` is not checked (errcheck)
h.UnmarshalBinary(d.Raw)
^
network/ntp/protocol_test.go:111:20: Error return value of `h.UnmarshalBinary` is not checked (errcheck)
h.UnmarshalBinary(d)
^
kola/tests/misc/network.go:150:10: Error return value of `m.Reboot` is not checked (errcheck)
m.Reboot()
^
kola/tests/misc/files.go:45:29: S1019: should use make([]string, 0) instead (gosimple)
badfiles := make([]string, 0, 0)
^
kola/tests/misc/files.go:62:6: S1002: should omit comparison to bool constant, can be simplified to `!valid` (gosimple)
if valid != true {
^
network/nsdialer.go:49:14: Error return value of `nsExit` is not checked (errcheck)
defer nsExit()
^
network/ssh.go:117:23: Error return value of `agent.ServeAgent` is not checked (errcheck)
go agent.ServeAgent(a, conn)
^
kola/tests/ostree/basic.go:217:4: printf: Fatalf format %d has arg osRemoteListSplit of wrong type []string (govet)
c.Fatalf(`Did not find expected amount of ostree remotes: %q. Expected %d`, string(osRemoteListOut), osRemoteListSplit)
^
kola/tests/ostree/unlock.go:257:12: printf: Fatalf call has arguments but no formatting directives (govet)
c.Fatalf(`Rollback did not remove hotfix mode; got: $q`, rollbackStatus.Deployments[0].Unlocked)
^
cmd/ore/azure/upload-blob-arm.go:107:2: ineffectual assignment to `err` (ineffassign)
err = json.NewEncoder(os.Stdout).Encode(&struct {
^
cmd/ore/azure/upload-blob-arm.go:104:3: SA4004: the surrounding loop is unconditionally terminated (staticcheck)
break
^
lang/bufpipe/pipe_test.go:268:10: Error return value of `w.Write` is not checked (errcheck)
w.Write([]byte{})
^
lang/bufpipe/pipe_test.go:272:13: Error return value of `io.ReadFull` is not checked (errcheck)
io.ReadFull(r, b[0:2])
^
lang/bufpipe/pipe_test.go:279:10: Error return value of `w.Write` is not checked (errcheck)
w.Write(nil)
^
lang/bufpipe/pipe_test.go:283:13: Error return value of `io.ReadFull` is not checked (errcheck)
io.ReadFull(r, b[0:2])
^
storage/object_test.go:30:2: `testPageMD5` is unused (deadcode)
testPageMD5 = "2a6rirkVBEsl0bzTOzNtzA=="
^
storage/object_test.go:89:8: Error return value of `r.Seek` is not checked (errcheck)
r.Seek(0, 0)
^
platform/machine/packet/cluster.go:124:11: Error return value of `rand.Read` is not checked (errcheck)
rand.Read(b)
^
platform/journal.go:96:18: Error return value of `j.recorder.Wait` is not checked (errcheck)
j.recorder.Wait() // Just need to consume the status.
^
platform/platform.go:276:2: ineffectual assignment to `out` (ineffassign)
out, stderr, err := m.SSH(fmt.Sprintf("sudo mkdir -p %s", dir))
^
platform/platform.go:308:2: ineffectual assignment to `out` (ineffassign)
out, stderr, err := m.SSH(fmt.Sprintf("sudo mkdir -p %s", shellquote.Join(destdir)))
^
platform/qemu.go:98:2: `tmpConfig` is unused (structcheck)
tmpConfig string
^
platform/qemu.go:84:2: `fd` is unused (structcheck)
fd *os.File // builder file descriptor location, e.g. /proc/self/fd/
^
platform/metal.go:258:3: S1023: redundant break statement (gosimple)
break
^
platform/metal.go:265:3: S1023: redundant break statement (gosimple)
break
^
platform/qemu.go:1015:28: S1039: unnecessary use of fmt.Sprintf (gosimple)
builder.Append("-drive", fmt.Sprintf("file=/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw,if=pflash,format=raw,unit=0,readonly=on,auto-read-only=off"))
^
platform/qemu.go:276:58: SA1024: cutset contains duplicate characters (staticcheck)
devpath := filepath.Clean(strings.Trim(dev.DevicePath, "virtio-backend"))
^
kola/tests/rpmostree/deployments.go:302:4: printf: Fatal call has possible formatting directive %d (govet)
c.Fatal("Expected %d deployments, got %d", 2, len(postUninstallStatus.Deployments))
^
platform/api/gcloud/pending.go:57:30: S1012: should use `time.Since` instead of `time.Now().Sub` (gosimple)
err := p.Progress(p.desc, time.Now().Sub(start), op)
^
platform/api/gcloud/api.go:82:15: SA1019: compute.New is deprecated: please use NewService instead. To provide a custom HTTP client, use option.WithHTTPClient. If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. (staticcheck)
capi, err := compute.New(client)
^
platform/api/packet/api.go:469:37: S1012: should use `time.Since` instead of `time.Now().Sub` (gosimple)
time.Sleep(installPollInterval - time.Now().Sub(start))
^
kola/tests/crio/crio.go:364:25: S1039: unnecessary use of fmt.Sprintf (gosimple)
subnet := c.MustSSH(m, fmt.Sprintf("jq --raw-output '.ipam.ranges[0][0].subnet' /usr/etc/cni/net.d/100-crio-bridge.conf"))
^
cli/cli.go:73:6: `setRepoLogLevel` is unused (deadcode)
func setRepoLogLevel(repo string, l capnslog.LogLevel) {
^
platform/api/azure/network.go:116:3: SA4004: the surrounding loop is unconditionally terminated (staticcheck)
return publicIP, *conf.PrivateIPAddress, nil
^
cmd/plume/plume.go:42:6: `getGoogleClient` is unused (deadcode)
func getGoogleClient() (*http.Client, error) {
^
cmd/plume/release.go:153:6: `doGCE` is unused (deadcode)
func doGCE(ctx context.Context, client *http.Client, src *storage.Bucket, spec *channelSpec) {
^
cmd/plume/release.go:294:6: `doAzure` is unused (deadcode)
func doAzure(ctx context.Context, client *http.Client, src *storage.Bucket, spec *channelSpec) {
^
cmd/plume/prerelease.go:106:2: S1032: should use sort.Strings(...) instead of sort.Sort(sort.StringSlice(...)) (gosimple)
sort.Sort(sort.StringSlice(platformList))
^
cmd/plume/prerelease.go:395:70: SA4009: argument imageName is overwritten before first use (staticcheck)
func awsUploadToPartition(spec *channelSpec, part *awsPartitionSpec, imageName, imageDescription, imagePath string) (map[string]string, error) {
^
cmd/plume/release.go:254:6: SA1019: old.Deprecated is deprecated: The deprecation status associated with this image. (staticcheck)
if old.Deprecated != nil && old.Deprecated.State != "" {
^
platform/api/esx/api.go:448:2: ineffectual assignment to `nets` (ineffassign)
nets = append(nets, types.OvfNetworkMapping{
^
kola/harness.go:605:4: ineffectual assignment to `previousRebootState` (ineffassign)
previousRebootState = ""
^
kola/harness.go:154:11: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
match: regexp.MustCompile("ignition\\[[0-9]+\\]: failed to fetch config: context canceled"),
^
kola/harness.go:159:11: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
match: regexp.MustCompile("initrd-cleanup\\.service: Main process exited, code=killed, status=15/TERM"),
^
kola/harness.go:164:11: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
match: regexp.MustCompile("mm/pgtable-generic.c:\\d+: bad (p.d|pte)"),
^
kola/harness.go:543:27: SA5008: unknown JSON option "architectures" (staticcheck)
Architectures string `json:",architectures,omitempty"`
^
kola/harness.go:544:27: SA5008: unknown JSON option "platforms" (staticcheck)
Platforms string `json:",platforms,omitempty"`
^
kola/harness.go:545:27: SA5008: unknown JSON option "distros" (staticcheck)
Distros string `json:",distros,omitempty"`
^
kola/harness.go:546:27: SA5008: unknown JSON option "tags" (staticcheck)
Tags string `json:",tags,omitempty"`
^
kola/harness.go:547:27: SA5008: unknown JSON option "additionalDisks" (staticcheck)
AdditionalDisks []string `json:",additionalDisks,omitempty"`
^
kola/harness.go:548:27: SA5008: unknown JSON option "minMemory" (staticcheck)
MinMemory int `json:",minMemory,omitempty"`
^
cmd/plume/release.go:117:6: func `gceWaitForImage` is unused (unused)
cmd/plume/release.go:112:6: func `sanitizeVersion` is unused (unused)
cmd/plume/release.go:135:6: func `gceUploadImage` is unused (unused)
schematyper/generator.go:314:23: func `stringSetMap.removeFrom` is unused (unused)
schematyper/generator.go:321:23: func `stringSetMap.existsIn` is unused (unused)
platform/local/flight.go:108:24: func `(*LocalFlight).newListenPort` is unused (unused)
platform/local/cluster.go:40:25: func `(*LocalCluster).hostIP` is unused (unused)
ben@porpentina:~/src/cosa/mantle $ cat lint.txt
lang/maps/sorted_test.go:66:9: S1005: unnecessary assignment to the blank identifier (gosimple)
for k, _ := range testMap {
^
lang/maps/sorted_test.go:92:9: S1005: unnecessary assignment to the blank identifier (gosimple)
for k, _ := range testMap {
^
kola/tests/rhcos/upgrade.go:29:5: `plog` is unused (deadcode)
var plog = capnslog.NewPackageLogger("github.com/coreos/mantle", "kola/tests/upgrade")
^
kola/tests/rhcos/luks.go:211:10: Error return value of `m.Reboot` is not checked (errcheck)
m.Reboot()
^
kola/tests/rhcos/luks.go:179:3: printf: Fatal call has possible formatting directive %s (govet)
c.Fatal("Failed to match regexp %s: %v", r, err)
^
kola/tests/rhcos/luks.go:182:3: printf: Fatal call has possible formatting directive %s (govet)
c.Fatal("Regexp %s did not match text: %s", r, output)
^
kola/tests/rhcos/luks.go:189:3: printf: Fatal call has possible formatting directive %s (govet)
c.Fatal("Failed to match regexp %s: %v", r, err)
^
cmd/kola/kola.go:118:2: `extDependencyDir` is unused (deadcode)
extDependencyDir string
^
cmd/kola/kola.go:473:6: `runArtifactIgnitionVersion` is unused (deadcode)
func runArtifactIgnitionVersion(cmd *cobra.Command, args []string) error {
^
cmd/kola/devshell.go:199:18: Error return value of `serialLog.Seek` is not checked (errcheck)
serialLog.Seek(0, os.SEEK_SET)
^
cmd/kola/devshell.go:311:16: Error return value of `proc.Signal` is not checked (errcheck)
proc.Signal(os.Interrupt)
^
cmd/kola/kola.go:483:13: Error return value of `errors.New` is not checked (errcheck)
errors.New("Error: missing required argument --build")
^
cmd/kola/qemuexec.go:231:17: Error return value of `builder.AddIso` is not checked (errcheck)
builder.AddIso(kola.QEMUIsoOptions.IsoPath, "")
^
cmd/kola/switchkernel.go:93:34: Error return value of `cmdSwitchKernel.MarkFlagRequired` is not checked (errcheck)
cmdSwitchKernel.MarkFlagRequired("kernel-rt")
^
cmd/kola/testiso.go:171:18: Error return value of `builder.AddDisk` is not checked (errcheck)
builder.AddDisk(&platform.Disk{
^
cmd/kola/testiso.go:177:25: Error return value of `builder.AddPrimaryDisk` is not checked (errcheck)
builder.AddPrimaryDisk(&platform.Disk{
^
cmd/kola/testiso.go:458:20: Error return value of `mach.Destroy` is not checked (errcheck)
defer mach.Destroy()
^
cmd/kola/testiso.go:499:20: Error return value of `mach.Destroy` is not checked (errcheck)
defer mach.Destroy()
^
cmd/kola/testiso.go:513:16: Error return value of `builder.AddIso` is not checked (errcheck)
builder.AddIso(isopath, "")
^
cmd/kola/switchkernel.go:180:2: S1038: should use fmt.Printf instead of fmt.Println(fmt.Sprintf(...)) (but don't forget the newline) (gosimple)
fmt.Println(fmt.Sprintf("%s", stderr))
^
cmd/kola/switchkernel.go:181:2: S1038: should use fmt.Printf instead of fmt.Println(fmt.Sprintf(...)) (but don't forget the newline) (gosimple)
fmt.Println(fmt.Sprintf("%s", stdout))
^
cmd/kola/switchkernel.go:210:2: S1038: should use fmt.Printf instead of fmt.Println(fmt.Sprintf(...)) (but don't forget the newline) (gosimple)
fmt.Println(fmt.Sprintf("%s", stderr))
^
cmd/kola/testiso.go:370:3: S1021: should merge variable declaration with assignment on next line (gosimple)
var err error
^
cmd/kola/qemuexec.go:95:4: S1023: redundant break statement (gosimple)
break
^
cmd/kola/devshell.go:206:8: S1005: unnecessary assignment to the blank identifier (gosimple)
case _ = <-readychan:
^
cmd/kola/testiso.go:355:13: S1039: unnecessary use of fmt.Sprintf (gosimple)
msg := fmt.Sprintf("entered emergency.target in initramfs")
^
cmd/kolet/kolet.go:143:11: Error return value of `cmd.Usage` is not checked (errcheck)
cmd.Usage()
^
cmd/kolet/kolet.go:160:15: Error return value of `cmd.Usage` is not checked (errcheck)
cmd.Usage()
^
cmd/kolet/kolet.go:197:19: Error return value of `sdconn.StartUnit` is not checked (errcheck)
sdconn.StartUnit(unitname, "fail", nil)
^
cmd/kolet/kolet.go:300:20: Error return value of `dispatchRunExtUnit` is not checked (errcheck)
dispatchRunExtUnit(unitname, sdconn)
^
auth/google.go:71:26: SA1019: oauth2.NoContext is deprecated: Use context.Background() or context.TODO() instead. (staticcheck)
ts := conf.TokenSource(oauth2.NoContext, tok)
^
auth/google.go:101:28: SA1019: oauth2.NoContext is deprecated: Use context.Background() or context.TODO() instead. (staticcheck)
tok, err = conf.Exchange(oauth2.NoContext, code)
^
auth/google.go:123:21: SA1019: oauth2.NoContext is deprecated: Use context.Background() or context.TODO() instead. (staticcheck)
return conf.Client(oauth2.NoContext, tok), nil
^
platform/api/do/api.go:167:18: Error return value of `a.DeleteDroplet` is not checked (errcheck)
a.DeleteDroplet(ctx, dropletID)
^
platform/api/do/api.go:264:16: Error return value of `a.DeleteImage` is not checked (errcheck)
a.DeleteImage(ctx, imageID)
^
update/signature/signature.go:28:2: SA1019: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead. (staticcheck)
"github.com/golang/protobuf/proto"
^
update/signature/signature_test.go:22:2: SA1019: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead. (staticcheck)
"github.com/golang/protobuf/proto"
^
update/operation.go:139:33: SA1019: os.SEEK_SET is deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd. (staticcheck)
if _, err := dst.Seek(offset, os.SEEK_SET); err != nil {
^
update/updater.go:117:28: SA1019: os.SEEK_SET is deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd. (staticcheck)
if _, err := file.Seek(0, os.SEEK_SET); err != nil {
^
update/payload.go:25:2: SA1019: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead. (staticcheck)
"github.com/golang/protobuf/proto"
^
kola/tests/docker/docker.go:385:18: Error return value of `cluster.DropFile` is not checked (errcheck)
cluster.DropFile(c.Machines(), oldclient)
^
kola/tests/docker/docker.go:497:12: Error return value of `util.Retry` is not checked (errcheck)
util.Retry(12, 6*time.Second, func() error {
^
cmd/ore/gcloud/upload.go:53:28: Error return value of `cmdUpload.MarkFlagRequired` is not checked (errcheck)
cmdUpload.MarkFlagRequired("bucket")
^
cmd/ore/gcloud/upload.go:55:28: Error return value of `cmdUpload.MarkFlagRequired` is not checked (errcheck)
cmdUpload.MarkFlagRequired("name")
^
cmd/ore/gcloud/upload.go:57:28: Error return value of `cmdUpload.MarkFlagRequired` is not checked (errcheck)
cmdUpload.MarkFlagRequired("file")
^
cmd/ore/gcloud/create-image.go:95:21: SA1019: storage.New is deprecated: please use NewService instead. To provide a custom HTTP client, use option.WithHTTPClient. If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. (staticcheck)
storageAPI, err := storage.New(api.Client())
^
cmd/ore/gcloud/promote-image.go:95:6: SA1019: image.Deprecated is deprecated: The deprecation status associated with this image. (staticcheck)
if image.Deprecated != nil {
^
cmd/ore/gcloud/promote-image.go:97:17: SA1019: image.Deprecated is deprecated: The deprecation status associated with this image. (staticcheck)
image.Name, image.Deprecated.State)
^
cmd/ore/gcloud/promote-image.go:104:6: SA1019: image.Deprecated is deprecated: The deprecation status associated with this image. (staticcheck)
if image.Deprecated == nil ||
^
cmd/ore/gcloud/upload.go:100:21: SA1019: storage.New is deprecated: please use NewService instead. To provide a custom HTTP client, use option.WithHTTPClient. If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. (staticcheck)
storageAPI, err := storage.New(api.Client())
^
harness/harness.go:124:26: Error return value of `outputBufferCopy.WriteTo` is not checked (errcheck)
outputBufferCopy.WriteTo(p.w)
^
harness/harness.go:235:17: Error return value of `c.logger.Output` is not checked (errcheck)
c.logger.Output(3, s)
^
harness/harness.go:393:17: S1012: should use `time.Since` instead of `time.Now().Sub` (gosimple)
t.duration += time.Now().Sub(t.start)
^
update/generator/full.go:65:31: SA1019: os.SEEK_SET is deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd. (staticcheck)
if _, err := payload.Seek(0, os.SEEK_SET); err != nil {
^
sdk/download.go:180:6: `getUrlStream` is unused (deadcode)
func getUrlStream(url string, client *http.Client) (*http.Response, error) {
^
sdk/repo.go:36:6: `isDir` is unused (deadcode)
func isDir(dir string) bool {
^
sdk/repo.go:41:6: `envDir` is unused (deadcode)
func envDir(env string) string {
^
sdk/verify.go:74:64: SA4009: argument err is overwritten before first use (staticcheck)
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
^
sdk/download.go:48:15: SA1019: storage.New is deprecated: please use NewService instead. To provide a custom HTTP client, use option.WithHTTPClient. If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. (staticcheck)
api, err := storage.New(client)
^
platform/machine/qemuiso/cluster.go:115:16: Error return value of `builder.AddIso` is not checked (errcheck)
builder.AddIso(qc.flight.opts.IsoPath, "")
^
network/journal/format.go:60:17: Error return value of `io.WriteString` is not checked (errcheck)
io.WriteString(s.w, "-- Reboot --\n")
^
platform/api/aws/ec2.go:203:23: Error return value of `a.TerminateInstances` is not checked (errcheck)
a.TerminateInstances(ids)
^
platform/api/openstack/api.go:312:17: Error return value of `a.DeleteServer` is not checked (errcheck)
a.DeleteServer(serverID)
^
platform/api/openstack/api.go:320:18: Error return value of `a.DeleteServer` is not checked (errcheck)
a.DeleteServer(serverID)
^
platform/api/openstack/api.go:327:18: Error return value of `a.DeleteServer` is not checked (errcheck)
a.DeleteServer(serverID)
^
platform/api/openstack/api.go:330:22: Error return value of `a.deleteFloatingIP` is not checked (errcheck)
a.deleteFloatingIP(floatingip.ID)
^
platform/api/openstack/api.go:430:25: Error return value of `a.deleteSecurityGroup` is not checked (errcheck)
a.deleteSecurityGroup(securityGroup.ID)
^
platform/api/openstack/api.go:521:16: Error return value of `a.DeleteImage` is not checked (errcheck)
a.DeleteImage(image.ID)
^
platform/api/openstack/api.go:528:16: Error return value of `a.DeleteImage` is not checked (errcheck)
a.DeleteImage(image.ID)
^
platform/api/openstack/api.go:133:17: ineffectual assignment to `err` (ineffassign)
networkClient, err := openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{
^
kola/tests/podman/podman.go:290:6: `podmanNetworkTest` is unused (deadcode)
func podmanNetworkTest(c cluster.TestCluster) {
^
kola/tests/podman/podman.go:193:6: S1002: should omit comparison to bool constant, can be simplified to `!found` (gosimple)
if found == false {
^
kola/tests/podman/podman.go:214:6: S1002: should omit comparison to bool constant, can be simplified to `found` (gosimple)
if found == true {
^
cmd/ore/do/create-image.go:111:21: Error return value of `API.DeleteKey` is not checked (errcheck)
defer API.DeleteKey(ctx, keyID)
^
cmd/ore/do/create-image.go:118:25: Error return value of `API.DeleteDroplet` is not checked (errcheck)
defer API.DeleteDroplet(ctx, dropletID)
^
cosa/build.go:94:14: Error return value of `errors.New` is not checked (errcheck)
errors.New("data is not compliant with schema")
^
cosa/schema.go:65:10: ineffectual assignment to `err` (ineffassign)
result, err := schema.Validate(
^
cosa/schema_test.go:34:5: SA5011: possible nil pointer dereference (staticcheck)
b.Name = ""
^
kola/tests/upgrade/basic.go:277:3: printf: Fatalf format %v reads arg #1, but call has 0 args (govet)
c.Fatalf("failed to marshal graph: %v")
^
network/ntp/protocol_test.go:90:18: Error return value of `h.MarshalBinary` is not checked (errcheck)
h.MarshalBinary()
^
network/ntp/protocol_test.go:100:20: Error return value of `h.UnmarshalBinary` is not checked (errcheck)
h.UnmarshalBinary(d.Raw)
^
network/ntp/protocol_test.go:111:20: Error return value of `h.UnmarshalBinary` is not checked (errcheck)
h.UnmarshalBinary(d)
^
kola/tests/misc/network.go:150:10: Error return value of `m.Reboot` is not checked (errcheck)
m.Reboot()
^
kola/tests/misc/files.go:45:29: S1019: should use make([]string, 0) instead (gosimple)
badfiles := make([]string, 0, 0)
^
kola/tests/misc/files.go:62:6: S1002: should omit comparison to bool constant, can be simplified to `!valid` (gosimple)
if valid != true {
^
network/nsdialer.go:49:14: Error return value of `nsExit` is not checked (errcheck)
defer nsExit()
^
network/ssh.go:117:23: Error return value of `agent.ServeAgent` is not checked (errcheck)
go agent.ServeAgent(a, conn)
^
kola/tests/ostree/basic.go:217:4: printf: Fatalf format %d has arg osRemoteListSplit of wrong type []string (govet)
c.Fatalf(`Did not find expected amount of ostree remotes: %q. Expected %d`, string(osRemoteListOut), osRemoteListSplit)
^
kola/tests/ostree/unlock.go:257:12: printf: Fatalf call has arguments but no formatting directives (govet)
c.Fatalf(`Rollback did not remove hotfix mode; got: $q`, rollbackStatus.Deployments[0].Unlocked)
^
cmd/ore/azure/upload-blob-arm.go:107:2: ineffectual assignment to `err` (ineffassign)
err = json.NewEncoder(os.Stdout).Encode(&struct {
^
cmd/ore/azure/upload-blob-arm.go:104:3: SA4004: the surrounding loop is unconditionally terminated (staticcheck)
break
^
lang/bufpipe/pipe_test.go:268:10: Error return value of `w.Write` is not checked (errcheck)
w.Write([]byte{})
^
lang/bufpipe/pipe_test.go:272:13: Error return value of `io.ReadFull` is not checked (errcheck)
io.ReadFull(r, b[0:2])
^
lang/bufpipe/pipe_test.go:279:10: Error return value of `w.Write` is not checked (errcheck)
w.Write(nil)
^
lang/bufpipe/pipe_test.go:283:13: Error return value of `io.ReadFull` is not checked (errcheck)
io.ReadFull(r, b[0:2])
^
storage/object_test.go:30:2: `testPageMD5` is unused (deadcode)
testPageMD5 = "2a6rirkVBEsl0bzTOzNtzA=="
^
storage/object_test.go:89:8: Error return value of `r.Seek` is not checked (errcheck)
r.Seek(0, 0)
^
platform/machine/packet/cluster.go:124:11: Error return value of `rand.Read` is not checked (errcheck)
rand.Read(b)
^
platform/journal.go:96:18: Error return value of `j.recorder.Wait` is not checked (errcheck)
j.recorder.Wait() // Just need to consume the status.
^
platform/platform.go:276:2: ineffectual assignment to `out` (ineffassign)
out, stderr, err := m.SSH(fmt.Sprintf("sudo mkdir -p %s", dir))
^
platform/platform.go:308:2: ineffectual assignment to `out` (ineffassign)
out, stderr, err := m.SSH(fmt.Sprintf("sudo mkdir -p %s", shellquote.Join(destdir)))
^
platform/qemu.go:98:2: `tmpConfig` is unused (structcheck)
tmpConfig string
^
platform/qemu.go:84:2: `fd` is unused (structcheck)
fd *os.File // builder file descriptor location, e.g. /proc/self/fd/
^
platform/metal.go:258:3: S1023: redundant break statement (gosimple)
break
^
platform/metal.go:265:3: S1023: redundant break statement (gosimple)
break
^
platform/qemu.go:1015:28: S1039: unnecessary use of fmt.Sprintf (gosimple)
builder.Append("-drive", fmt.Sprintf("file=/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw,if=pflash,format=raw,unit=0,readonly=on,auto-read-only=off"))
^
platform/qemu.go:276:58: SA1024: cutset contains duplicate characters (staticcheck)
devpath := filepath.Clean(strings.Trim(dev.DevicePath, "virtio-backend"))
^
kola/tests/rpmostree/deployments.go:302:4: printf: Fatal call has possible formatting directive %d (govet)
c.Fatal("Expected %d deployments, got %d", 2, len(postUninstallStatus.Deployments))
^
platform/api/gcloud/pending.go:57:30: S1012: should use `time.Since` instead of `time.Now().Sub` (gosimple)
err := p.Progress(p.desc, time.Now().Sub(start), op)
^
platform/api/gcloud/api.go:82:15: SA1019: compute.New is deprecated: please use NewService instead. To provide a custom HTTP client, use option.WithHTTPClient. If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. (staticcheck)
capi, err := compute.New(client)
^
platform/api/packet/api.go:469:37: S1012: should use `time.Since` instead of `time.Now().Sub` (gosimple)
time.Sleep(installPollInterval - time.Now().Sub(start))
^
kola/tests/crio/crio.go:364:25: S1039: unnecessary use of fmt.Sprintf (gosimple)
subnet := c.MustSSH(m, fmt.Sprintf("jq --raw-output '.ipam.ranges[0][0].subnet' /usr/etc/cni/net.d/100-crio-bridge.conf"))
^
cli/cli.go:73:6: `setRepoLogLevel` is unused (deadcode)
func setRepoLogLevel(repo string, l capnslog.LogLevel) {
^
platform/api/azure/network.go:116:3: SA4004: the surrounding loop is unconditionally terminated (staticcheck)
return publicIP, *conf.PrivateIPAddress, nil
^
cmd/plume/plume.go:42:6: `getGoogleClient` is unused (deadcode)
func getGoogleClient() (*http.Client, error) {
^
cmd/plume/release.go:153:6: `doGCE` is unused (deadcode)
func doGCE(ctx context.Context, client *http.Client, src *storage.Bucket, spec *channelSpec) {
^
cmd/plume/release.go:294:6: `doAzure` is unused (deadcode)
func doAzure(ctx context.Context, client *http.Client, src *storage.Bucket, spec *channelSpec) {
^
cmd/plume/prerelease.go:106:2: S1032: should use sort.Strings(...) instead of sort.Sort(sort.StringSlice(...)) (gosimple)
sort.Sort(sort.StringSlice(platformList))
^
cmd/plume/prerelease.go:395:70: SA4009: argument imageName is overwritten before first use (staticcheck)
func awsUploadToPartition(spec *channelSpec, part *awsPartitionSpec, imageName, imageDescription, imagePath string) (map[string]string, error) {
^
cmd/plume/release.go:254:6: SA1019: old.Deprecated is deprecated: The deprecation status associated with this image. (staticcheck)
if old.Deprecated != nil && old.Deprecated.State != "" {
^
platform/api/esx/api.go:448:2: ineffectual assignment to `nets` (ineffassign)
nets = append(nets, types.OvfNetworkMapping{
^
kola/harness.go:605:4: ineffectual assignment to `previousRebootState` (ineffassign)
previousRebootState = ""
^
kola/harness.go:154:11: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
match: regexp.MustCompile("ignition\\[[0-9]+\\]: failed to fetch config: context canceled"),
^
kola/harness.go:159:11: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
match: regexp.MustCompile("initrd-cleanup\\.service: Main process exited, code=killed, status=15/TERM"),
^
kola/harness.go:164:11: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
match: regexp.MustCompile("mm/pgtable-generic.c:\\d+: bad (p.d|pte)"),
^
kola/harness.go:543:27: SA5008: unknown JSON option "architectures" (staticcheck)
Architectures string `json:",architectures,omitempty"`
^
kola/harness.go:544:27: SA5008: unknown JSON option "platforms" (staticcheck)
Platforms string `json:",platforms,omitempty"`
^
kola/harness.go:545:27: SA5008: unknown JSON option "distros" (staticcheck)
Distros string `json:",distros,omitempty"`
^
kola/harness.go:546:27: SA5008: unknown JSON option "tags" (staticcheck)
Tags string `json:",tags,omitempty"`
^
kola/harness.go:547:27: SA5008: unknown JSON option "additionalDisks" (staticcheck)
AdditionalDisks []string `json:",additionalDisks,omitempty"`
^
kola/harness.go:548:27: SA5008: unknown JSON option "minMemory" (staticcheck)
MinMemory int `json:",minMemory,omitempty"`
^
cmd/plume/release.go:117:6: func `gceWaitForImage` is unused (unused)
cmd/plume/release.go:112:6: func `sanitizeVersion` is unused (unused)
cmd/plume/release.go:135:6: func `gceUploadImage` is unused (unused)
schematyper/generator.go:314:23: func `stringSetMap.removeFrom` is unused (unused)
schematyper/generator.go:321:23: func `stringSetMap.existsIn` is unused (unused)
platform/local/flight.go:108:24: func `(*LocalFlight).newListenPort` is unused (unused)
platform/local/cluster.go:40:25: func `(*LocalCluster).hostIP` is unused (unused)
@bh7cw Are you interest in tackling this? The effort for this is low and the high value. I think the best approach would be to do a single PR for each file cleaned up.
See [1] or you can use the container [2] to get started.
[1] https://golangci-lint.run/usage/install/#local-installation [2] In the Mantle directory:
podman run --rm -it --volume=$$PWD:/code:z --workdir /code docker.io/golangci/golangci-lint golangci-lint run -v ./...
Roughly this shows we have the following issues:
50 (errcheck)
29 (staticcheck)
24 (gosimple)
12 (deadcode)
7 (unused)
7 (ineffassign)
7 (govet)
2 (structcheck)
Fixed by https://github.com/coreos/coreos-assembler/pull/2978.