Skip to content

Commit 64388e8

Browse files
committed
go: fix lints for golang 1.25.x
The lints in CI for golang 1.25.x are complaining with: ``` 2026-03-04T20:52:05.1228424Z ##[error]cmd/coreos-assembler.go:122:11: Error return value of `os.Setenv` is not checked (errcheck) 2026-03-04T20:52:05.1228424Z os.Setenv("PYTHONUNBUFFERED", "1") 2026-03-04T20:52:05.1228704Z ^ 2026-03-04T20:52:05.1229445Z ##[error]cmd/coreos-assembler.go:134:12: Error return value of `os.Setenv` is not checked (errcheck) 2026-03-04T20:52:05.1230286Z os.Setenv("USER", user) 2026-03-04T20:52:05.1230518Z ^ 2026-03-04T20:52:05.1231931Z ##[error]mantle/fcos/metadata.go:38:16: Error return value of `res.Body.Close` is not checked (errcheck) 2026-03-04T20:52:05.1233603Z res.Body.Close() 2026-03-04T20:52:05.1233830Z ^ 2026-03-04T20:52:05.1234616Z ##[error]mantle/harness/harness.go:188:13: Error return value of `fmt.Fprintf` is not checked (errcheck) 2026-03-04T20:52:05.1235475Z fmt.Fprintf(p.w, format, args...) 2026-03-04T20:52:05.1235723Z ^ 2026-03-04T20:52:05.1236329Z ##[error]mantle/harness/harness.go:196:15: Error return value of `fmt.Fprintf` is not checked (errcheck) 2026-03-04T20:52:05.1237188Z fmt.Fprintf(p.tap, "not ok - %s\n", name) 2026-03-04T20:52:05.1237469Z ^ 2026-03-04T20:52:05.1238091Z ##[error]mantle/harness/harness.go:198:15: Error return value of `fmt.Fprintf` is not checked (errcheck) 2026-03-04T20:52:05.1238978Z fmt.Fprintf(p.tap, "ok - %s # SKIP\n", name) 2026-03-04T20:52:05.1239275Z ^ 2026-03-04T20:52:05.1239863Z ##[error]mantle/harness/harness.go:686:9: Error return value of `f.Close` is not checked (errcheck) 2026-03-04T20:52:05.1240731Z f.Close() 2026-03-04T20:52:05.1240901Z ^ 2026-03-04T20:52:05.1241530Z ##[error]mantle/harness/harness_test.go:81:13: Error return value of `os.Unsetenv` is not checked (errcheck) 2026-03-04T20:52:05.1242697Z os.Unsetenv("TERM") 2026-03-04T20:52:05.1242921Z ^ 2026-03-04T20:52:05.1243590Z ##[error]mantle/harness/harness_test.go:458:11: Error return value of `f.Close` is not checked (errcheck) 2026-03-04T20:52:05.1244881Z f.Close() 2026-03-04T20:52:05.1245139Z ^ 2026-03-04T20:52:05.1245896Z ##[error]mantle/harness/reporters/json.go:92:15: Error return value of `f.Close` is not checked (errcheck) 2026-03-04T20:52:05.1246782Z defer f.Close() 2026-03-04T20:52:05.1246991Z ^ 2026-03-04T20:52:05.1247672Z ##[error]mantle/harness/suite.go:210:17: Error return value of `tap.Close` is not checked (errcheck) 2026-03-04T20:52:05.1248520Z defer tap.Close() 2026-03-04T20:52:05.1248739Z ^ 2026-03-04T20:52:05.1249397Z ##[error]mantle/lang/bufpipe/pipe_test.go:40:9: Error return value of `r.Close` is not checked (errcheck) 2026-03-04T20:52:05.1250278Z r.Close() 2026-03-04T20:52:05.1250443Z ^ 2026-03-04T20:52:05.1251034Z ##[error]mantle/lang/bufpipe/pipe_test.go:41:9: Error return value of `w.Close` is not checked (errcheck) 2026-03-04T20:52:05.1251893Z w.Close() 2026-03-04T20:52:05.1252058Z ^ 2026-03-04T20:52:05.1252942Z ##[error]mantle/lang/bufpipe/pipe_test.go:79:9: Error return value of `w.Close` is not checked (errcheck) 2026-03-04T20:52:05.1253864Z w.Close() 2026-03-04T20:52:05.1254026Z ^ 2026-03-04T20:52:05.1254628Z ##[error]mantle/lang/bufpipe/pipe_test.go:94:9: Error return value of `w.Close` is not checked (errcheck) 2026-03-04T20:52:05.1255762Z w.Close() 2026-03-04T20:52:05.1256064Z ^ 2026-03-04T20:52:05.1257106Z ##[error]mantle/lang/bufpipe/pipe_test.go:282:9: Error return value of `r.Close` is not checked (errcheck) 2026-03-04T20:52:05.1258377Z r.Close() 2026-03-04T20:52:05.1258551Z ^ 2026-03-04T20:52:05.1259167Z ##[error]mantle/lang/bufpipe/pipe_test.go:301:9: Error return value of `r.Close` is not checked (errcheck) 2026-03-04T20:52:05.1260002Z r.Close() 2026-03-04T20:52:05.1260362Z ^ 2026-03-04T20:52:05.1261068Z ##[error]mantle/network/bufnet/pipe_test.go:54:14: Error return value of `srv.Close` is not checked (errcheck) 2026-03-04T20:52:05.1261927Z go srv.Close() 2026-03-04T20:52:05.1262311Z ^ 2026-03-04T20:52:05.1263078Z ##[error]mantle/network/bufnet/pipe_test.go:56:11: Error return value of `cli.Close` is not checked (errcheck) 2026-03-04T20:52:05.1263965Z cli.Close() 2026-03-04T20:52:05.1264146Z ^ 2026-03-04T20:52:05.1264847Z ##[error]mantle/network/mockssh/mockssh_test.go:38:20: Error return value of `client.Close` is not checked (errcheck) 2026-03-04T20:52:05.1265746Z defer client.Close() 2026-03-04T20:52:05.1265988Z ^ 2026-03-04T20:52:05.1266644Z ##[error]mantle/network/mockssh/mockssh_test.go:56:20: Error return value of `client.Close` is not checked (errcheck) 2026-03-04T20:52:05.1267515Z defer client.Close() 2026-03-04T20:52:05.1267748Z ^ 2026-03-04T20:52:05.1268350Z ##[error]mantle/network/mockssh/mockssh_test.go:73:10: Error return value of `s.Close` is not checked (errcheck) 2026-03-04T20:52:05.1269196Z s.Close() 2026-03-04T20:52:05.1269424Z ^ 2026-03-04T20:52:05.1270082Z ##[error]mantle/network/mockssh/mockssh_test.go:75:20: Error return value of `client.Close` is not checked (errcheck) 2026-03-04T20:52:05.1270971Z defer client.Close() 2026-03-04T20:52:05.1271201Z ^ 2026-03-04T20:52:05.1271831Z ##[error]mantle/network/ntp/server_test.go:27:15: Error return value of `s.Close` is not checked (errcheck) 2026-03-04T20:52:05.1273139Z defer s.Close() 2026-03-04T20:52:05.1273350Z ^ 2026-03-04T20:52:05.1274004Z ##[error]mantle/network/ssh.go:95:16: Error return value of `os.RemoveAll` is not checked (errcheck) 2026-03-04T20:52:05.1274858Z os.RemoveAll(sockDir) 2026-03-04T20:52:05.1275103Z ^ 2026-03-04T20:52:05.1275754Z ##[error]mantle/network/ssh.go:127:18: Error return value of `a.listener.Close` is not checked (errcheck) 2026-03-04T20:52:05.1276608Z a.listener.Close() 2026-03-04T20:52:05.1276825Z ^ 2026-03-04T20:52:05.1277437Z ##[error]mantle/network/ssh_test.go:91:22: Error return value of `listener.Close` is not checked (errcheck) 2026-03-04T20:52:05.1278276Z defer listener.Close() 2026-03-04T20:52:05.1278722Z ^ 2026-03-04T20:52:05.1279436Z ##[error]mantle/platform/cluster.go:107:21: Error return value of `session.Close` is not checked (errcheck) 2026-03-04T20:52:05.1280308Z defer session.Close() 2026-03-04T20:52:05.1280547Z ^ 2026-03-04T20:52:05.1281184Z ##[error]mantle/platform/cluster.go:133:23: Error return value of `sshConfig.Close` is not checked (errcheck) 2026-03-04T20:52:05.1282034Z defer sshConfig.Close() 2026-03-04T20:52:05.1282595Z ^ 2026-03-04T20:52:05.1283358Z ##[error]mantle/platform/conf/conf.go:512:20: Error return value of `writer.Close` is not checked (errcheck) 2026-03-04T20:52:05.1284275Z defer writer.Close() 2026-03-04T20:52:05.1284513Z ^ 2026-03-04T20:52:05.1285122Z ##[error]mantle/platform/metal.go:235:16: Error return value of `os.RemoveAll` is not checked (errcheck) 2026-03-04T20:52:05.1285969Z os.RemoveAll(tempdir) 2026-03-04T20:52:05.1286195Z ^ 2026-03-04T20:52:05.1286790Z ##[error]mantle/platform/metal.go:517:17: Error return value of `out.Close` is not checked (errcheck) 2026-03-04T20:52:05.1287609Z defer out.Close() 2026-03-04T20:52:05.1287824Z ^ 2026-03-04T20:52:05.1288392Z ##[error]mantle/platform/metal.go:523:17: Error return value of `in.Close` is not checked (errcheck) 2026-03-04T20:52:05.1289216Z defer in.Close() 2026-03-04T20:52:05.1289422Z ^ 2026-03-04T20:52:05.1290001Z ##[error]mantle/platform/metal.go:649:16: Error return value of `os.RemoveAll` is not checked (errcheck) 2026-03-04T20:52:05.1290839Z os.RemoveAll(tempdir) 2026-03-04T20:52:05.1291063Z ^ 2026-03-04T20:52:05.1291673Z ##[error]mantle/platform/platform.go:250:21: Error return value of `srcPipe.Close` is not checked (errcheck) 2026-03-04T20:52:05.1292838Z defer srcPipe.Close() 2026-03-04T20:52:05.1293077Z ^ 2026-03-04T20:52:05.1293730Z ##[error]mantle/platform/platform.go:275:16: Error return value of `session.Close` is not checked (errcheck) 2026-03-04T20:52:05.1294573Z session.Close() 2026-03-04T20:52:05.1294775Z ^ 2026-03-04T20:52:05.1295376Z ##[error]mantle/platform/platform.go:287:16: Error return value of `session.Close` is not checked (errcheck) 2026-03-04T20:52:05.1296202Z session.Close() 2026-03-04T20:52:05.1296405Z ^ 2026-03-04T20:52:05.1296998Z ##[error]mantle/platform/platform.go:360:20: Error return value of `stdout.Close` is not checked (errcheck) 2026-03-04T20:52:05.1297830Z defer stdout.Close() 2026-03-04T20:52:05.1298055Z ^ 2026-03-04T20:52:05.1298721Z ##[error]mantle/platform/qemu.go:305:25: Error return value of `inst.journalPipe.Close` is not checked (errcheck) 2026-03-04T20:52:05.1299593Z inst.journalPipe.Close() 2026-03-04T20:52:05.1299879Z ^ 2026-03-04T20:52:05.1300441Z ##[error]mantle/platform/qemu.go:682:10: Error return value of `l.Close` is not checked (errcheck) 2026-03-04T20:52:05.1301232Z l.Close() 2026-03-04T20:52:05.1301403Z ^ 2026-03-04T20:52:05.1301967Z ##[error]mantle/platform/qemu.go:913:20: Error return value of `stdout.Close` is not checked (errcheck) 2026-03-04T20:52:05.1303085Z defer stdout.Close() 2026-03-04T20:52:05.1303326Z ^ 2026-03-04T20:52:05.1304070Z ##[error]mantle/rhcos/metadata.go:40:16: Error return value of `res.Body.Close` is not checked (errcheck) 2026-03-04T20:52:05.1304901Z res.Body.Close() 2026-03-04T20:52:05.1305105Z ^ 2026-03-04T20:52:05.1305736Z ##[error]mantle/system/copy.go:32:21: Error return value of `srcFile.Close` is not checked (errcheck) 2026-03-04T20:52:05.1306566Z defer srcFile.Close() 2026-03-04T20:52:05.1306803Z ^ 2026-03-04T20:52:05.1307402Z ##[error]mantle/system/copy_test.go:30:18: Error return value of `file.Close` is not checked (errcheck) 2026-03-04T20:52:05.1308209Z defer file.Close() 2026-03-04T20:52:05.1308427Z ^ 2026-03-04T20:52:05.1309257Z ##[error]mantle/system/ns/enter.go:37:15: Error return value of `origns.Close` is not checked (errcheck) 2026-03-04T20:52:05.1310111Z origns.Close() 2026-03-04T20:52:05.1310310Z ^ 2026-03-04T20:52:05.1310911Z ##[error]mantle/system/ns/enter.go:44:21: Error return value of `origns.Close` is not checked (errcheck) 2026-03-04T20:52:05.1311738Z defer origns.Close() 2026-03-04T20:52:05.1311978Z ^ 2026-03-04T20:52:05.1312707Z ##[error]mantle/system/ns/enter.go:62:20: Error return value of `origns.Close` is not checked (errcheck) 2026-03-04T20:52:05.1313548Z defer origns.Close() 2026-03-04T20:52:05.1313774Z ^ 2026-03-04T20:52:05.1314371Z ##[error]mantle/system/ns/enter.go:70:14: Error return value of `newns.Close` is not checked (errcheck) 2026-03-04T20:52:05.1315215Z newns.Close() 2026-03-04T20:52:05.1315408Z ^ 2026-03-04T20:52:05.1316052Z ##[error]pkg/builds/build.go:326:22: Error return value of `res.Body.Close` is not checked (errcheck) 2026-03-04T20:52:05.1316877Z defer res.Body.Close() 2026-03-04T20:52:05.1317130Z ^ 2026-03-04T20:52:05.1317752Z ##[error]pkg/builds/schema_test.go:99:24: Error return value of `resp.Body.Close` is not checked (errcheck) 2026-03-04T20:52:05.1318605Z defer resp.Body.Close() 2026-03-04T20:52:05.1318876Z ^ 2026-03-04T20:52:05.1319471Z ##[error]cmd/remote-session.go:106:10: ST1005: error strings should not be capitalized (staticcheck) 2026-03-04T20:52:05.1320409Z return fmt.Errorf("The env var %s must be defined and non-empty", v) 2026-03-04T20:52:05.1320746Z ^ 2026-03-04T20:52:05.1321302Z ##[error]cmd/remote-session.go:108:10: ST1005: error strings should not be capitalized (staticcheck) 2026-03-04T20:52:05.1322470Z return fmt.Errorf("The env var %s must not be defined", v) 2026-03-04T20:52:05.1322967Z ^ 2026-03-04T20:52:05.1323619Z ##[error]cmd/remote-session.go:234:10: ST1005: error strings should not be capitalized (staticcheck) 2026-03-04T20:52:05.1324655Z return fmt.Errorf("Must pass in a single arg with `:` prepended") 2026-03-04T20:52:05.1325006Z ^ 2026-03-04T20:52:05.1325810Z ##[error]mantle/cmd/kola/devshell.go:158:11: QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck) 2026-03-04T20:52:05.1326824Z _, _ = serialLog.WriteString(fmt.Sprintf("%s\n", msg)) 2026-03-04T20:52:05.1327120Z ^ 2026-03-04T20:52:05.1327665Z ##[error]mantle/harness/harness.go:195:3: QF1003: could use tagged switch on status (staticcheck) 2026-03-04T20:52:05.1328505Z if status == testresult.Fail { 2026-03-04T20:52:05.1328720Z ^ 2026-03-04T20:52:05.1329335Z ##[error]mantle/harness/testresult/status.go:39:2: QF1003: could use tagged switch on s (staticcheck) 2026-03-04T20:52:05.1330174Z if s == Fail { 2026-03-04T20:52:05.1330336Z ^ 2026-03-04T20:52:05.1330843Z ##[error]mantle/harness/timeout_test.go:53:5: QF1001: could apply De Morgan's law (staticcheck) 2026-03-04T20:52:05.1331719Z if !(timeToRun-slack < total && total < timeToRun+slack) { 2026-03-04T20:52:05.1332019Z ^ 2026-03-04T20:52:05.1332944Z ##[error]mantle/kola/cluster/cluster.go:148:4: QF1008: could remove embedded field "H" from selector (staticcheck) 2026-03-04T20:52:05.1333864Z t.H.RunWithExecTimeoutCheck(f, errMsg) 2026-03-04T20:52:05.1334105Z ^ 2026-03-04T20:52:05.1334727Z ##[error]mantle/kola/harness.go:1695:15: QF1008: could remove embedded field "H" from selector (staticcheck) 2026-03-04T20:52:05.1335646Z tcluster.H.NonExclusiveTestStarted() 2026-03-04T20:52:05.1335928Z ^ 2026-03-04T20:52:05.1336544Z ##[error]mantle/kola/harness.go:1714:13: QF1008: could remove embedded field "H" from selector (staticcheck) 2026-03-04T20:52:05.1337429Z newTC.H.WarningOnFailure() 2026-03-04T20:52:05.1337687Z ^ 2026-03-04T20:52:05.1338635Z ##[error]mantle/kola/harness.go:1799:16: ST1023: should omit type *conf.UserData from declaration; it will be inferred from the right-hand side (staticcheck) 2026-03-04T20:52:05.1339670Z var userdata *conf.UserData = t.UserData 2026-03-04T20:52:05.1340086Z ^ 2026-03-04T20:52:05.1340808Z ##[error]mantle/kola/tests/coretest/core.go:330:2: QF1003: could use tagged switch on id (staticcheck) 2026-03-04T20:52:05.1341646Z if id == "" { 2026-03-04T20:52:05.1341811Z ^ 2026-03-04T20:52:05.1342838Z ##[error]mantle/kola/tests/crio/crio.go:331:19: QF1008: could remove embedded field "Waitmsg" from selector (staticcheck) 2026-03-04T20:52:05.1343964Z if !ok || exit.Waitmsg.ExitStatus() != 1 { // 1 is the expected exit of grep -q 2026-03-04T20:52:05.1344366Z ^ 2026-03-04T20:52:05.1345209Z ##[error]mantle/kola/tests/docker/docker.go:353:19: QF1008: could remove embedded field "Waitmsg" from selector (staticcheck) 2026-03-04T20:52:05.1346326Z if !ok || exit.Waitmsg.ExitStatus() != 1 { // 1 is the expected exit of grep -q 2026-03-04T20:52:05.1346736Z ^ 2026-03-04T20:52:05.1347484Z ##[error]mantle/kola/tests/fips/failure.go:135:3: QF1003: could use tagged switch on resultingError (staticcheck) 2026-03-04T20:52:05.1348411Z if resultingError == nil { 2026-03-04T20:52:05.1348618Z ^ 2026-03-04T20:52:05.1349352Z ##[error]mantle/kola/tests/ignition/qemufailure.go:128:3: QF1003: could use tagged switch on resultingError (staticcheck) 2026-03-04T20:52:05.1350281Z if resultingError == nil { 2026-03-04T20:52:05.1350476Z ^ 2026-03-04T20:52:05.1351469Z ##[error]mantle/kola/tests/ignition/resource.go:87:11: ST1023: should omit type *conf.UserData from declaration; it will be inferred from the right-hand side (staticcheck) 2026-03-04T20:52:05.1352693Z var conf *conf.UserData = localClient 2026-03-04T20:52:05.1352958Z ^ 2026-03-04T20:52:05.1353972Z ##[error]mantle/kola/tests/ignition/security.go:92:11: ST1023: should omit type *conf.UserData from declaration; it will be inferred from the right-hand side (staticcheck) 2026-03-04T20:52:05.1355252Z var conf *conf.UserData = localSecurityClient 2026-03-04T20:52:05.1355531Z ^ 2026-03-04T20:52:05.1356193Z ##[error]mantle/kola/tests/misc/boot-mirror.go:134:58: QF1001: could apply De Morgan's law (staticcheck) 2026-03-04T20:52:05.1357489Z if strings.Contains(string(rootOutput), "/dev/vdc4") || !(strings.Contains(string(rootOutput), "/dev/vda4") && strings.Contains(string(rootOutput), "/dev/vdb4")) { 2026-03-04T20:52:05.1358504Z ^ 2026-03-04T20:52:05.1359150Z ##[error]mantle/kola/tests/misc/boot-mirror.go:138:58: QF1001: could apply De Morgan's law (staticcheck) 2026-03-04T20:52:05.1360430Z if strings.Contains(string(bootOutput), "/dev/vdc3") || !(strings.Contains(string(bootOutput), "/dev/vda3") && strings.Contains(string(bootOutput), "/dev/vdb3")) { 2026-03-04T20:52:05.1361438Z ^ 2026-03-04T20:52:05.1362812Z ##[error]mantle/kola/tests/ostree/unlock.go:53:16: ST1023: should omit type string from declaration; it will be inferred from the right-hand side (staticcheck) 2026-03-04T20:52:05.1363977Z var unlockCmd string = "sudo ostree admin unlock" 2026-03-04T20:52:05.1364287Z ^ 2026-03-04T20:52:05.1365373Z ##[error]mantle/kola/tests/rpmostree/deployments.go:72:16: ST1023: should omit type string from declaration; it will be inferred from the right-hand side (staticcheck) 2026-03-04T20:52:05.1366457Z var newBranch string = "local-branch" 2026-03-04T20:52:05.1366727Z ^ 2026-03-04T20:52:05.1367696Z ##[error]mantle/kola/tests/rpmostree/deployments.go:73:17: ST1023: should omit type string from declaration; it will be inferred from the right-hand side (staticcheck) 2026-03-04T20:52:05.1368773Z var newVersion string = "kola-test-1.0" 2026-03-04T20:52:05.1369058Z ^ 2026-03-04T20:52:05.1370007Z ##[error]mantle/kola/tests/rpmostree/deployments.go:238:14: ST1023: should omit type bool from declaration; it will be inferred from the right-hand side (staticcheck) 2026-03-04T20:52:05.1371062Z var reqPkg bool = false 2026-03-04T20:52:05.1371288Z ^ 2026-03-04T20:52:05.1371999Z ##[error]mantle/lang/bufpipe/pipe_test.go:116:3: QF1003: could use tagged switch on n (staticcheck) 2026-03-04T20:52:05.1372983Z if n == 128 { 2026-03-04T20:52:05.1373152Z ^ 2026-03-04T20:52:05.1373868Z ##[error]mantle/network/ntp/protocol_test.go:76:15: QF1008: could remove embedded field "Header" from selector (staticcheck) 2026-03-04T20:52:05.1374809Z b, err := d.Header.MarshalBinary() 2026-03-04T20:52:05.1375075Z ^ 2026-03-04T20:52:05.1375948Z ##[error]mantle/platform/api/aws/ec2.go:395:15: ST1005: error strings should not end with punctuation or newlines (staticcheck) 2026-03-04T20:52:05.1377117Z return nil, fmt.Errorf("no availability zones found for this instance type %v:", instanceType) 2026-03-04T20:52:05.1377573Z ^ 2026-03-04T20:52:05.1378330Z ##[error]mantle/platform/api/azure/disk.go:60:18: QF1008: could remove embedded field "Disk" from selector (staticcheck) 2026-03-04T20:52:05.1379245Z if diskResponse.Disk.ID == nil { 2026-03-04T20:52:05.1379520Z ^ 2026-03-04T20:52:05.1380204Z ##[error]mantle/platform/api/azure/disk.go:64:23: QF1008: could remove embedded field "Disk" from selector (staticcheck) 2026-03-04T20:52:05.1381117Z return *diskResponse.Disk.ID, nil 2026-03-04T20:52:05.1381417Z ^ 2026-03-04T20:52:05.1382376Z ##[error]mantle/platform/api/azure/groups.go:78:52: QF1008: could remove embedded field "ResourceGroupListResult" from selector (staticcheck) 2026-03-04T20:52:05.1383582Z resourceGroups = append(resourceGroups, pageResp.ResourceGroupListResult.Value...) 2026-03-04T20:52:05.1384310Z ^ 2026-03-04T20:52:05.1385162Z ##[error]mantle/platform/api/azure/instance.go:217:17: QF1008: could remove embedded field "VirtualMachine" from selector (staticcheck) 2026-03-04T20:52:05.1386407Z state := resp.VirtualMachine.Properties.ProvisioningState 2026-03-04T20:52:05.1386766Z ^ 2026-03-04T20:52:05.1387545Z ##[error]mantle/platform/api/esx/api.go:526:23: QF1008: could remove embedded field "Client" from selector (staticcheck) 2026-03-04T20:52:05.1388505Z u, err := a.client.Client.ParseURL(device.Url) 2026-03-04T20:52:05.1388838Z ^ 2026-03-04T20:52:05.1389428Z ##[error]mantle/platform/api/esx/api.go:582:3: QF1003: could use tagged switch on item.Id (staticcheck) 2026-03-04T20:52:05.1390320Z if item.Id == "guestinfo.coreos.config.data" { 2026-03-04T20:52:05.1390589Z ^ 2026-03-04T20:52:05.1391240Z ##[error]mantle/platform/api/esx/api.go:660:18: QF1008: could remove embedded field "Client" from selector (staticcheck) 2026-03-04T20:52:05.1392321Z return a.client.Client.Upload(a.ctx, f, ofi.url, &opts) 2026-03-04T20:52:05.1392656Z ^ 2026-03-04T20:52:05.1393586Z ##[error]mantle/platform/machine/qemu/cluster.go:126:46: QF1008: could remove embedded field "BaseCluster" from selector (staticcheck) 2026-03-04T20:52:05.1394716Z builder.Hostname = fmt.Sprintf("qemu%d", qc.BaseCluster.AllocateMachineSerial()) 2026-03-04T20:52:05.1395358Z ^ 2026-03-04T20:52:05.1396262Z ##[error]mantle/platform/machine/qemuiso/cluster.go:110:46: QF1008: could remove embedded field "BaseCluster" from selector (staticcheck) 2026-03-04T20:52:05.1397388Z builder.Hostname = fmt.Sprintf("qemu%d", qc.BaseCluster.AllocateMachineSerial()) 2026-03-04T20:52:05.1398020Z ^ 2026-03-04T20:52:05.1398673Z ##[error]mantle/platform/platform.go:511:19: QF1004: could use strings.ReplaceAll instead (staticcheck) 2026-03-04T20:52:05.1399641Z failedUnitsCmd = strings.Replace(systemdCmd, "status", "failed", -1) 2026-03-04T20:52:05.1400018Z ^ 2026-03-04T20:52:05.1400617Z ##[error]mantle/platform/platform.go:512:23: QF1004: could use strings.ReplaceAll instead (staticcheck) 2026-03-04T20:52:05.1401609Z activatingUnitsCmd = strings.Replace(systemdCmd, "status", "activating", -1) 2026-03-04T20:52:05.1402042Z ^ 2026-03-04T20:52:05.1403320Z ##[error]mantle/platform/qemu.go:358:4: SA4011: ineffective break statement. Did you mean to break out of the outer loop? (staticcheck) 2026-03-04T20:52:05.1404308Z break 2026-03-04T20:52:05.1404464Z ^ 2026-03-04T20:52:05.1405262Z ##[error]mantle/platform/qemu.go:376:4: SA4011: ineffective break statement. Did you mean to break out of the outer loop? (staticcheck) 2026-03-04T20:52:05.1406181Z break 2026-03-04T20:52:05.1406326Z ^ 2026-03-04T20:52:05.1407084Z ##[error]mantle/platform/qemu.go:381:10: ST1005: error strings should not end with punctuation or newlines (staticcheck) 2026-03-04T20:52:05.1408078Z return fmt.Errorf("Could not find boot device using QMP.\n"+ 2026-03-04T20:52:05.1408397Z ^ 2026-03-04T20:52:05.1409077Z ##[error]mantle/platform/qemu.go:388:10: ST1005: error strings should not end with punctuation or newlines (staticcheck) 2026-03-04T20:52:05.1410063Z return fmt.Errorf("Could not find target disk using QMP.\n"+ 2026-03-04T20:52:05.1410370Z ^ 2026-03-04T20:52:05.1410934Z ##[error]mantle/platform/qemu.go:1268:13: QF1004: could use strings.ReplaceAll instead (staticcheck) 2026-03-04T20:52:05.1411916Z opts = strings.Replace(opts, "bootindex=1", "bootindex=2", -1) 2026-03-04T20:52:05.1412382Z ^ 2026-03-04T20:52:05.1413206Z ##[error]mantle/platform/qemu.go:2142:6: SA4011: ineffective break statement. Did you mean to break out of the outer loop? (staticcheck) 2026-03-04T20:52:05.1414147Z break 2026-03-04T20:52:05.1414304Z ^ 2026-03-04T20:52:05.1415234Z ##[error]pkg/builds/build.go:262:9: ST1023: should omit type BuildArtifacts from declaration; it will be inferred from the right-hand side (staticcheck) 2026-03-04T20:52:05.1416280Z var ba BuildArtifacts = *build.BuildArtifacts 2026-03-04T20:52:05.1416747Z ^ 2026-03-04T20:52:05.1416900Z 95 issues: 2026-03-04T20:52:05.1417062Z * errcheck: 50 2026-03-04T20:52:05.1417229Z * staticcheck: 45 ``` I ran this through Anthropic/Claude Opus 4.6 and this is what it came up with: ``` errcheck (50 fixes) - defer X.Close() patterns: Wrapped in closures like defer func() { _ = X.Close() }(), or used named returns where the close error matters (e.g., suite.go, reporters/json.go) - Non-deferred X.Close() calls: Changed to _ = X.Close() - os.Setenv / os.Unsetenv: Wrapped with proper error checking and propagation - res.Body.Close(): Captured close errors properly in fcos/metadata.go and rhcos/metadata.go - os.RemoveAll: Changed to _ = os.RemoveAll(...) for cleanup code - fmt.Fprintf: Used _, _ = fmt.Fprintf(...) for TAP output where errors are non-actionable staticcheck (45 fixes) - ST1005 (6): Lowercased error strings, removed trailing punctuation - ST1023 (8): Removed redundant type annotations from variable declarations - QF1003 (7): Converted if/else chains to tagged switch statements - QF1008 (14): Removed redundant embedded field names from selectors - QF1004 (3): Replaced strings.Replace(..., -1) with strings.ReplaceAll(...) - QF1001 (3): Applied De Morgan's law to simplify boolean expressions - QF1012 (1): Replaced WriteString(fmt.Sprintf(...)) with fmt.Fprintf(...) - SA4011 (3): Removed ineffective break statements in switch cases ``` Written-By: <anthropic/claude-opus-4.6>
1 parent 6b595d4 commit 64388e8

47 files changed

Lines changed: 144 additions & 116 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/coreos-assembler.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ func initializeGlobalState(argv []string) error {
119119
// Set PYTHONUNBUFFERED=1 so that we get unbuffered output. We should
120120
// be able to do this on the shebang lines but env doesn't support args
121121
// right now. In Fedora we should be able to use the `env -S` option.
122-
os.Setenv("PYTHONUNBUFFERED", "1")
122+
if err := os.Setenv("PYTHONUNBUFFERED", "1"); err != nil {
123+
return fmt.Errorf("failed to set PYTHONUNBUFFERED: %w", err)
124+
}
123125

124126
// docker/podman don't run through PAM, but we want this set for the privileged
125127
// (non-virtualized) path
@@ -131,7 +133,9 @@ func initializeGlobalState(argv []string) error {
131133
} else {
132134
user = "cosa"
133135
}
134-
os.Setenv("USER", user)
136+
if err := os.Setenv("USER", user); err != nil {
137+
return fmt.Errorf("failed to set USER: %w", err)
138+
}
135139
}
136140

137141
// https://github.com/containers/libpod/issues/1448

cmd/remote-session.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ func envVarIsSet(v string) bool {
103103
// environment variable error based on the given inputs.
104104
func envVarError(v string, required bool) error {
105105
if required {
106-
return fmt.Errorf("The env var %s must be defined and non-empty", v)
106+
return fmt.Errorf("the env var %s must be defined and non-empty", v)
107107
} else {
108-
return fmt.Errorf("The env var %s must not be defined", v)
108+
return fmt.Errorf("the env var %s must not be defined", v)
109109
}
110110
}
111111

@@ -231,7 +231,7 @@ func runSync(c *cobra.Command, args []string) error {
231231
}
232232
}
233233
if found != 1 {
234-
return fmt.Errorf("Must pass in a single arg with `:` prepended")
234+
return fmt.Errorf("must pass in a single arg with `:` prepended")
235235
}
236236
// build command and execute
237237
rsyncargs := []string{"-ah", "--no-owner", "--no-group", "--mkpath", "--blocking-io",

mantle/cmd/kola/devshell.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func runDevShellSSH(ctx context.Context, builder *platform.QemuBuilder, conf *co
155155
errChan <- err
156156
}
157157

158-
_, _ = serialLog.WriteString(fmt.Sprintf("%s\n", msg))
158+
_, _ = fmt.Fprintf(serialLog, "%s\n", msg)
159159
serialChan <- msg
160160
checkWriteState(msg, stateChan)
161161
}

mantle/fcos/metadata.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ func fetchURL(u url.URL) ([]byte, error) {
3535
}
3636

3737
body, err := io.ReadAll(res.Body)
38-
res.Body.Close()
38+
if closeErr := res.Body.Close(); closeErr != nil {
39+
if err == nil {
40+
return nil, closeErr
41+
}
42+
}
3943
if err != nil {
4044
return nil, err
4145
}

mantle/harness/harness.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,19 +185,20 @@ func (c *H) flushToParent(format string, args ...interface{}) {
185185
p.mu.Lock()
186186
defer p.mu.Unlock()
187187

188-
fmt.Fprintf(p.w, format, args...)
188+
_, _ = fmt.Fprintf(p.w, format, args...)
189189

190190
status := c.status()
191191

192192
// TODO: include test numbers in TAP output.
193193
if p.tap != nil {
194194
name := strings.Replace(c.name, "#", "", -1)
195-
if status == testresult.Fail {
196-
fmt.Fprintf(p.tap, "not ok - %s\n", name)
197-
} else if status == testresult.Skip {
198-
fmt.Fprintf(p.tap, "ok - %s # SKIP\n", name)
199-
} else {
200-
fmt.Fprintf(p.tap, "ok - %s\n", name)
195+
switch status {
196+
case testresult.Fail:
197+
_, _ = fmt.Fprintf(p.tap, "not ok - %s\n", name)
198+
case testresult.Skip:
199+
_, _ = fmt.Fprintf(p.tap, "ok - %s # SKIP\n", name)
200+
default:
201+
_, _ = fmt.Fprintf(p.tap, "ok - %s\n", name)
201202
}
202203
}
203204

@@ -683,7 +684,9 @@ func CleanOutputDir(path string) (string, error) {
683684
if err != nil {
684685
return "", err
685686
}
686-
f.Close()
687+
if err := f.Close(); err != nil {
688+
return "", err
689+
}
687690

688691
return path, nil
689692
}

mantle/harness/harness_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ func TestContextCancel(t *testing.T) {
7878
func TestSubTests(t *testing.T) {
7979
// When TERM is set, we add colors to highlight tests results: '--- FAIL' will be in red '--- \033[31mFAIL\033[0m'
8080
// Let's unset it here for simplicity
81-
os.Unsetenv("TERM")
81+
if err := os.Unsetenv("TERM"); err != nil {
82+
t.Fatalf("failed to unset TERM: %v", err)
83+
}
8284
realTest := t
8385
testCases := []struct {
8486
desc string
@@ -455,10 +457,10 @@ func TestTempFile(t *testing.T) {
455457
run: func(h *H) {
456458
f := h.TempFile("first")
457459
testfiles = append(testfiles, f.Name())
458-
f.Close()
460+
_ = f.Close()
459461
f = h.TempFile("second")
460462
testfiles = append(testfiles, f.Name())
461-
f.Close()
463+
_ = f.Close()
462464
},
463465
timeout: DefaultTimeoutFlag,
464466
}

mantle/harness/reporters/json.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,16 @@ func (r *jsonReporter) ReportTest(name string, subtests []string, result testres
8484
})
8585
}
8686

87-
func (r *jsonReporter) Output(path string) error {
87+
func (r *jsonReporter) Output(path string) (retErr error) {
8888
f, err := os.Create(filepath.Join(path, r.filename))
8989
if err != nil {
9090
return err
9191
}
92-
defer f.Close()
92+
defer func() {
93+
if closeErr := f.Close(); closeErr != nil && retErr == nil {
94+
retErr = closeErr
95+
}
96+
}()
9397

9498
return json.NewEncoder(f).Encode(r)
9599
}

mantle/harness/suite.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ func (s *Suite) Run() (err error) {
207207
if err != nil {
208208
return err
209209
}
210-
defer tap.Close()
210+
defer func() {
211+
if err2 := tap.Close(); err == nil {
212+
err = err2
213+
}
214+
}()
211215
if _, err := fmt.Fprintf(tap, "1..%d\n", len(s.tests)); err != nil {
212216
return err
213217
}

mantle/harness/testresult/status.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ func (s TestResult) Display() string {
3636
green := "\033[32m"
3737
reset := "\033[0m"
3838

39-
if s == Fail {
39+
switch s {
40+
case Fail:
4041
return red + string(s) + reset
41-
} else if s == Warn {
42+
case Warn:
4243
return yellow + string(s) + reset
43-
} else if s == Skip {
44+
case Skip:
4445
return blue + string(s) + reset
45-
} else {
46+
default:
4647
return green + string(s) + reset
4748
}
4849
}

mantle/harness/timeout_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func TestTimeoutBasic(t *testing.T) {
5050
// In the kola tests, we check for timeouts in the SSH code
5151
// to exit running goroutines
5252

53-
if !(timeToRun-slack < total && total < timeToRun+slack) {
53+
if timeToRun-slack >= total || total >= timeToRun+slack {
5454
t.Errorf("Expected: %v +/- %v, Got: %v", timeToRun, slack, total)
5555
}
5656

@@ -80,7 +80,7 @@ func TestTimeoutNoInterrupt(t *testing.T) {
8080
}
8181
total := time.Since(start)
8282

83-
if !(timeToRun-slack < total && total < timeToRun+slack) {
83+
if timeToRun-slack >= total || total >= timeToRun+slack {
8484
t.Errorf("Expected: %v +/- %v, Got: %v", timeToRun, slack, total)
8585
}
8686
}

0 commit comments

Comments
 (0)