Skip to content

Commit 3c9f7a7

Browse files
committed
chore: re-enable nolintlint and typecheck linters
Drop startup/rand.go, as since Go 1.20 `rand.Seed` is done automatically. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 parent c51e2c9 commit 3c9f7a7

File tree

135 files changed

+72
-265
lines changed

Some content is hidden

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

135 files changed

+72
-265
lines changed

.golangci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,11 @@ linters:
156156
- nestif
157157
- nilnil # we return "nil, nil"
158158
- nonamedreturns
159-
- nolintlint
160159
- nosnakecase
161160
- paralleltest
162161
- promlinter # https://github.com/golangci/golangci-lint/issues/2222
163162
- tagliatelle # we have many different conventions
164163
- thelper
165-
- typecheck
166164
- varnamelen # too annoying
167165
- wrapcheck
168166
- contextcheck # enable once golangci-lint 1.50.1 or 1.51 lands

cmd/installer/pkg/install/extensions.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/siderolabs/talos/pkg/machinery/constants"
1414
)
1515

16-
// nolint:gocyclo
1716
func (i *Installer) installExtensions() error {
1817
builder := extensions.Builder{
1918
InitramfsPath: fmt.Sprintf(constants.InitramfsAssetPath, i.options.Arch),

cmd/talosctl/cmd/mgmt/gen/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ func validateFlags() error {
287287
return err
288288
}
289289

290-
// nolint:gocyclo
291290
func writeConfigBundle(configBundle *bundle.Bundle, outputPaths configOutputPaths, commentsFlags encoder.CommentsFlags) error {
292291
outputTypesSet := slices.ToSet(genConfigCmdFlags.outputTypes)
293292

cmd/talosctl/main.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@ import (
99
"os"
1010

1111
"github.com/siderolabs/talos/cmd/talosctl/cmd"
12-
"github.com/siderolabs/talos/pkg/cli"
13-
"github.com/siderolabs/talos/pkg/startup"
1412
)
1513

1614
func main() {
17-
cli.Should(startup.RandSeed())
18-
1915
if err := cmd.Execute(); err != nil {
2016
os.Exit(1)
2117
}

hack/cloud-image-uploader/main.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ package main
88
import (
99
"context"
1010
cryptorand "crypto/rand"
11-
"encoding/binary"
1211
"encoding/json"
1312
"fmt"
1413
"io"
1514
"log"
16-
"math/rand"
1715
"os"
1816
"path/filepath"
1917
"sync"
@@ -77,8 +75,6 @@ func run() error {
7775
log.Fatalf("error seeding rand: %s", err)
7876
}
7977

80-
rand.Seed(int64(binary.LittleEndian.Uint64(seed))) //nolint:staticcheck
81-
8278
ctx, cancel := context.WithCancel(context.Background())
8379
defer cancel()
8480

internal/app/apid/main.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ func apidMain() error {
7272

7373
startup.LimitMaxProcs(constants.ApidMaxProcs)
7474

75-
if err := startup.RandSeed(); err != nil {
76-
return fmt.Errorf("failed to seed RNG: %w", err)
77-
}
78-
7975
runtimeConn, err := grpc.Dial("unix://"+constants.APIRuntimeSocketPath, grpc.WithTransportCredentials(insecure.NewCredentials()))
8076
if err != nil {
8177
return fmt.Errorf("failed to dial runtime connection: %w", err)

internal/app/machined/internal/server/v1alpha1/v1alpha1_cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (cl *clusterState) String() string {
117117
}))
118118
}
119119

120-
//nolint:gocyclo,cyclop
120+
//nolint:gocyclo
121121
func buildClusterInfo(ctx context.Context,
122122
req *clusterapi.HealthCheckRequest,
123123
r runtime.Runtime,

internal/app/machined/internal/server/v1alpha1/v1alpha1_server.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,6 @@ func (s *Server) GenerateConfiguration(ctx context.Context, in *machine.Generate
297297
}
298298

299299
// Reboot implements the machine.MachineServer interface.
300-
//
301-
//nolint:dupl
302300
func (s *Server) Reboot(ctx context.Context, in *machine.RebootRequest) (reply *machine.RebootResponse, err error) {
303301
actorID := uuid.New().String()
304302

@@ -330,8 +328,6 @@ func (s *Server) Reboot(ctx context.Context, in *machine.RebootRequest) (reply *
330328
}
331329

332330
// Rollback implements the machine.MachineServer interface.
333-
//
334-
//nolint:gocyclo
335331
func (s *Server) Rollback(ctx context.Context, in *machine.RollbackRequest) (*machine.RollbackResponse, error) {
336332
log.Printf("rollback via API received")
337333

@@ -407,8 +403,6 @@ func (s *Server) Bootstrap(ctx context.Context, in *machine.BootstrapRequest) (r
407403
}
408404

409405
// Shutdown implements the machine.MachineServer interface.
410-
//
411-
//nolint:dupl
412406
func (s *Server) Shutdown(ctx context.Context, in *machine.ShutdownRequest) (reply *machine.ShutdownResponse, err error) {
413407
actorID := uuid.New().String()
414408

@@ -563,7 +557,7 @@ func (opt *ResetOptions) GetSystemDiskTargets() []runtime.PartitionTarget {
563557

564558
// Reset resets the node.
565559
//
566-
//nolint:gocyclo,cyclop
560+
//nolint:gocyclo
567561
func (s *Server) Reset(ctx context.Context, in *machine.ResetRequest) (reply *machine.ResetResponse, err error) {
568562
actorID := uuid.New().String()
569563

@@ -2229,7 +2223,7 @@ func (s *Server) PacketCapture(in *machine.PacketCaptureRequest, srv machine.Mac
22292223
if err = srv.SendMsg(&common.Data{Bytes: data}); err != nil {
22302224
cancel()
22312225

2232-
pr.CloseWithError(err) //nolint:errcheck
2226+
pr.CloseWithError(err)
22332227
}
22342228
}
22352229

@@ -2244,7 +2238,7 @@ func capturePackets(pw *io.PipeWriter, handle *pcapgo.EthernetHandle, snapLen ui
22442238
pcapw := pcapgo.NewWriterNanos(pw)
22452239

22462240
if err := pcapw.WriteFileHeader(snapLen, linkType); err != nil {
2247-
pw.CloseWithError(err) //nolint:errcheck
2241+
pw.CloseWithError(err)
22482242

22492243
return
22502244
}
@@ -2263,7 +2257,7 @@ func capturePackets(pw *io.PipeWriter, handle *pcapgo.EthernetHandle, snapLen ui
22632257
packet, err := pkgsrc.NextPacket()
22642258
if err == nil {
22652259
if err = pcapw.WritePacket(packet.Metadata().CaptureInfo, packet.Data()); err != nil {
2266-
pw.CloseWithError(err) //nolint:errcheck
2260+
pw.CloseWithError(err)
22672261

22682262
return
22692263
}
@@ -2286,7 +2280,7 @@ func capturePackets(pw *io.PipeWriter, handle *pcapgo.EthernetHandle, snapLen ui
22862280
errors.Is(err, io.ErrNoProgress) || errors.Is(err, io.ErrClosedPipe) || errors.Is(err, io.ErrShortBuffer) ||
22872281
errors.Is(err, syscall.EBADF) ||
22882282
strings.Contains(err.Error(), "use of closed file") {
2289-
pw.CloseWithError(err) //nolint:errcheck
2283+
pw.CloseWithError(err)
22902284

22912285
return
22922286
}

internal/app/machined/main.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,6 @@ func run() error {
167167
// Limit GOMAXPROCS.
168168
startup.LimitMaxProcs(constants.MachinedMaxProcs)
169169

170-
// Ensure RNG is seeded.
171-
if err := startup.RandSeed(); err != nil {
172-
return err
173-
}
174-
175170
// Set the PATH env var.
176171
if err := os.Setenv("PATH", constants.PATH); err != nil {
177172
return errors.New("error setting PATH")

internal/app/machined/pkg/controllers/cluster/discovery_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func (ctrl *DiscoveryServiceController) Run(ctx context.Context, r controller.Ru
273273
Affiliate: localData,
274274
Endpoints: localEndpoints,
275275
}, otherEndpoints); err != nil {
276-
return fmt.Errorf("error setting local affiliate data: %w", err) //nolint:govet
276+
return fmt.Errorf("error setting local affiliate data: %w", err)
277277
}
278278

279279
prevLocalData = localData
@@ -312,7 +312,7 @@ func (ctrl *DiscoveryServiceController) Run(ctx context.Context, r controller.Ru
312312

313313
return nil
314314
}); err != nil {
315-
return err //nolint:govet
315+
return err
316316
}
317317

318318
touchedIDs[id] = struct{}{}

internal/app/machined/pkg/controllers/cri/seccomp_profile.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ func (ctrl *SeccompProfileController) Outputs() []controller.Output {
4949
}
5050

5151
// Run implements controller.StatsController interface.
52-
//
53-
//nolint:gocyclo,cyclop
5452
func (ctrl *SeccompProfileController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
5553
for {
5654
select {

internal/app/machined/pkg/controllers/ctest/ctest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
)
2727

2828
// DefaultSuite is a base suite for controller testing.
29-
type DefaultSuite struct { //nolint:govet
29+
type DefaultSuite struct {
3030
suite.Suite
3131

3232
state state.State

internal/app/machined/pkg/controllers/etcd/member.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (ctrl *MemberController) Outputs() []controller.Output {
5656

5757
// Run implements controller.Controller interface.
5858
//
59-
//nolint:gocyclo,cyclop
59+
//nolint:gocyclo
6060
func (ctrl *MemberController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
6161
for {
6262
select {

internal/app/machined/pkg/controllers/etcd/member_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (suite *MemberSuite) assertInexistentEtcdMember(member *etcd.Member) func()
7676
}
7777
}
7878

79-
func (suite *MemberSuite) TestEtcdRunning() { //nolint:dupl
79+
func (suite *MemberSuite) TestEtcdRunning() {
8080
// given
8181
suite.ctrl.GetLocalMemberIDFunc = func(ctx context.Context) (uint64, error) {
8282
return 123, nil
@@ -98,7 +98,7 @@ func (suite *MemberSuite) TestEtcdRunning() { //nolint:dupl
9898
)
9999
}
100100

101-
func (suite *MemberSuite) TestEtcdNotRunning() { //nolint:dupl
101+
func (suite *MemberSuite) TestEtcdNotRunning() {
102102
// given
103103
suite.ctrl.GetLocalMemberIDFunc = func(ctx context.Context) (uint64, error) {
104104
return 123, nil

internal/app/machined/pkg/controllers/k8s/control_plane_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5-
//nolint:dupl
65
package k8s_test
76

87
import (

internal/app/machined/pkg/controllers/k8s/endpoint.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ func (ctrl *EndpointController) Run(ctx context.Context, r controller.Runtime, l
106106
}
107107
}
108108

109-
//nolint:gocyclo
110109
func (ctrl *EndpointController) watchEndpointsOnWorker(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
111110
logger.Debug("waiting for kubelet client config", zap.String("file", constants.KubeletKubeconfig))
112111

@@ -144,7 +143,6 @@ func (ctrl *EndpointController) watchEndpointsOnWorker(ctx context.Context, r co
144143
}
145144
}
146145

147-
//nolint:gocyclo
148146
func (ctrl *EndpointController) watchEndpointsOnControlPlane(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
149147
if err := r.UpdateInputs([]controller.Input{
150148
{

internal/app/machined/pkg/controllers/k8s/kubelet_static_pod.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (ctrl *KubeletStaticPodController) Outputs() []controller.Output {
7373

7474
// Run implements controller.Controller interface.
7575
//
76-
//nolint:gocyclo,cyclop
76+
//nolint:gocyclo
7777
func (ctrl *KubeletStaticPodController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
7878
var kubeletClient *kubelet.Client
7979

internal/app/machined/pkg/controllers/k8s/render_secrets_static_pod.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (ctrl *RenderSecretsStaticPodController) Name() string {
3434
}
3535

3636
// Inputs implements controller.Controller interface.
37-
func (ctrl *RenderSecretsStaticPodController) Inputs() []controller.Input { //nolint:dupl
37+
func (ctrl *RenderSecretsStaticPodController) Inputs() []controller.Input {
3838
return []controller.Input{
3939
{
4040
Namespace: secrets.NamespaceName,

internal/app/machined/pkg/controllers/k8s/static_pod_server.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ type podList struct {
6565
}
6666

6767
// Run implements controller.Controller interface.
68-
//
69-
//nolint:gocyclo,cyclop
7068
func (ctrl *StaticPodServerController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
7169
ctrl.staticPodVersions = map[string]string{}
7270

internal/app/machined/pkg/controllers/kubeaccess/serviceaccount.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (ctrl *CRDController) Outputs() []controller.Output {
6767

6868
// Run implements controller.Controller interface.
6969
//
70-
//nolint:gocyclo,cyclop
70+
//nolint:gocyclo
7171
func (ctrl *CRDController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
7272
var crdControllerCtxCancel context.CancelFunc
7373

internal/app/machined/pkg/controllers/kubeaccess/serviceaccount/crd_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func (t *CRDController) Run(ctx context.Context, workers int) error {
248248
}
249249

250250
func (t *CRDController) runWorker(ctx context.Context) {
251-
for t.processNextWorkItem(ctx) { //nolint:revive
251+
for t.processNextWorkItem(ctx) {
252252
}
253253
}
254254

@@ -293,7 +293,7 @@ func (t *CRDController) processNextWorkItem(ctx context.Context) bool {
293293
return true
294294
}
295295

296-
//nolint:gocyclo,cyclop,dupl
296+
//nolint:gocyclo,cyclop
297297
func (t *CRDController) syncHandler(ctx context.Context, key string) error {
298298
namespace, name, err := cache.SplitMetaNamespaceKey(key)
299299
if err != nil {

internal/app/machined/pkg/controllers/network/address_config_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5-
//nolint:dupl
65
package network_test
76

87
import (

internal/app/machined/pkg/controllers/network/address_merge_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ func (suite *AddressMergeSuite) TestMerge() {
166166
)
167167
}
168168

169-
//nolint:gocyclo
170169
func (suite *AddressMergeSuite) TestMergeFlapping() {
171170
// simulate two conflicting address definitions which are getting removed/added constantly
172171
dhcp := network.NewAddressSpec(network.ConfigNamespaceName, "dhcp/eth0/10.0.0.1/8")

internal/app/machined/pkg/controllers/network/device_config_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5-
//nolint:dupl
65
package network_test
76

87
import (

internal/app/machined/pkg/controllers/network/etcfile_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5-
//nolint:dupl
65
package network_test
76

87
import (
@@ -199,7 +198,7 @@ func (suite *EtcFileConfigSuite) TestNoSearchDomain() {
199198
suite.testFiles(
200199
[]resource.Resource{cfg, suite.defaultAddress, suite.hostnameStatus, suite.resolverStatus},
201200
"nameserver 1.1.1.1\nnameserver 2.2.2.2\nnameserver 3.3.3.3\n",
202-
"127.0.0.1 localhost\n33.11.22.44 foo.example.com foo\n::1 localhost ip6-localhost ip6-loopback\nff02::1 ip6-allnodes\nff02::2 ip6-allrouters\n", //nolint:lll
201+
"127.0.0.1 localhost\n33.11.22.44 foo.example.com foo\n::1 localhost ip6-localhost ip6-loopback\nff02::1 ip6-allnodes\nff02::2 ip6-allrouters\n",
203202
)
204203
}
205204

internal/app/machined/pkg/controllers/network/hostname_config_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5-
//nolint:dupl
65
package network_test
76

87
import (

internal/app/machined/pkg/controllers/network/link_merge_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ func (suite *LinkMergeSuite) TestMergeLogicalLink() {
192192
)
193193
}
194194

195-
//nolint:gocyclo
196195
func (suite *LinkMergeSuite) TestMergeFlapping() {
197196
// simulate two conflicting link definitions which are getting removed/added constantly
198197
dhcp := network.NewLinkSpec(network.ConfigNamespaceName, "dhcp/eth0")

internal/app/machined/pkg/controllers/network/link_spec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ func (ctrl *LinkSpecController) Run(ctx context.Context, r controller.Runtime, l
143143
// in proper order.
144144
func SortBonds(items []resource.Resource) {
145145
sort.Slice(items, func(i, j int) bool {
146-
left := items[i].(*network.LinkSpec).TypedSpec() //nolint:errcheck
147-
right := items[j].(*network.LinkSpec).TypedSpec() //nolint:errcheck
146+
left := items[i].(*network.LinkSpec).TypedSpec()
147+
right := items[j].(*network.LinkSpec).TypedSpec()
148148

149149
l := ordered.MakeTriple(left.Name, 0, "")
150150
if left.BondSlave.MasterName != "" {

internal/app/machined/pkg/controllers/network/link_status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (ctrl *LinkStatusController) Run(ctx context.Context, r controller.Runtime,
104104
if err != nil {
105105
logger.Warn("error dialing ethtool ioctl socket", zap.Error(err))
106106
} else {
107-
defer ethIoctlClient.Close() //nolint:errcheck
107+
defer ethIoctlClient.Close()
108108
}
109109

110110
wgClient, err := wgctrl.New()

internal/app/machined/pkg/controllers/network/link_status_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (suite *LinkStatusSuite) TestInterfaceHwInfo() {
147147
suite.Require().NoError(err)
148148

149149
for _, res := range resources.Items {
150-
spec := res.(*network.LinkStatus).TypedSpec() //nolint:errcheck,forcetypeassert
150+
spec := res.(*network.LinkStatus).TypedSpec() //nolint:forcetypeassert
151151

152152
if !spec.Physical() {
153153
continue

0 commit comments

Comments
 (0)