chore: bump golangci-lint

Bump golangci-lint and fixup new warnings. Ignore check that checks for
used function parameters, it's kind of noisy and makes it confusing to
read interface implementations.

Signed-off-by: Noel Georgi <git@frezbo.dev>
This commit is contained in:
Noel Georgi 2023-03-22 19:55:38 +05:30
parent 36a9a208ec
commit d1a61fd343
No known key found for this signature in database
GPG Key ID: 21A9F444075C9E36
23 changed files with 29 additions and 71 deletions

View File

@ -190,6 +190,7 @@ issues:
exclude:
- package comment should be of the form "Package services ..." # revive
- ^ST1000 # ST1000: at least one file in a package should have a package comment (stylecheck)
- parameter '\w+' seems to be unused, consider removing or renaming it as _ # noisy check, especially when the usage is an interface implementation
exclude-rules:
- path: cmd/talosctl/cmd

View File

@ -23,7 +23,7 @@ GOIMPORTS_VERSION ?= v0.7.0
# renovate: datasource=go depName=mvdan.cc/gofumpt
GOFUMPT_VERSION ?= v0.4.0
# renovate: datasource=go depName=github.com/golangci/golangci-lint
GOLANGCILINT_VERSION ?= v1.51.2
GOLANGCILINT_VERSION ?= v1.52.1
# renovate: datasource=go depName=golang.org/x/tools
STRINGER_VERSION ?= v0.7.0
# renovate: datasource=go depName=github.com/alvaroloes/enumer

View File

@ -67,11 +67,7 @@ func (i *Installer) installExtensions() error {
return err
}
if err = i.rebuildInitramfs(tempDir); err != nil {
return err
}
return nil
return i.rebuildInitramfs(tempDir)
}
func printExtensions(extensions []*extensions.Extension) error {

View File

@ -184,11 +184,7 @@ func getResources(args []string) func(ctx context.Context, c *client.Client) err
return nil
}
if err := out.WriteResource(hostname, r, 0); err != nil {
return err
}
return nil
return out.WriteResource(hostname, r, 0)
}
callbackRD := func(definition *meta.ResourceDefinition) error {

View File

@ -81,7 +81,7 @@ var supportCmd = &cobra.Command{
eg.Go(func() error {
if supportCmdFlags.verbose {
for range progress {
for range progress { //nolint:revive
}
} else {
showProgress(progress)

View File

@ -171,11 +171,7 @@ func mountRootFS() error {
return err
}
if err := unix.Mount(constants.ExtensionsConfigFile, filepath.Join(constants.NewRoot, constants.ExtensionsRuntimeConfigFile), "", unix.MS_BIND|unix.MS_RDONLY, ""); err != nil {
return err
}
return nil
return unix.Mount(constants.ExtensionsConfigFile, filepath.Join(constants.NewRoot, constants.ExtensionsRuntimeConfigFile), "", unix.MS_BIND|unix.MS_RDONLY, "")
}
func bindMountFirmware() error {

View File

@ -239,11 +239,7 @@ func (ctrl *KubeletServiceController) writePKI(secretSpec *secrets.KubeletSpec)
return err
}
if err := os.WriteFile(constants.KubernetesCACert, secretSpec.CA.Crt, 0o400); err != nil {
return err
}
return nil
return os.WriteFile(constants.KubernetesCACert, secretSpec.CA.Crt, 0o400)
}
var kubeletKubeConfigTemplate = []byte(`apiVersion: v1

View File

@ -173,7 +173,7 @@ func (suite *NodeLabelsSuite) assertLabel(expectedLabel, oldValue, expectedValue
suite.Assert().NoError(
retry.Constant(3*time.Second, retry.WithUnits(100*time.Millisecond)).Retry(
func() error {
if err := suite.assertResource(
return suite.assertResource(
resource.NewMetadata(
k8s.NamespaceName,
k8s.NodeLabelSpecType,
@ -199,11 +199,7 @@ func (suite *NodeLabelsSuite) assertLabel(expectedLabel, oldValue, expectedValue
return nil
},
)(); err != nil {
return err
}
return nil
)()
},
),
)

View File

@ -248,7 +248,7 @@ func (t *CRDController) Run(ctx context.Context, workers int) error {
}
func (t *CRDController) runWorker(ctx context.Context) {
for t.processNextWorkItem(ctx) {
for t.processNextWorkItem(ctx) { //nolint:revive
}
}

View File

@ -230,9 +230,8 @@ func (suite *AddressMergeSuite) TestMergeFlapping() {
}
continue
} else {
suite.T().Log("finalizer added")
}
suite.T().Log("finalizer added")
time.Sleep(10 * time.Millisecond)

View File

@ -254,9 +254,8 @@ func (suite *LinkMergeSuite) TestMergeFlapping() {
}
continue
} else {
suite.T().Log("finalizer added")
}
suite.T().Log("finalizer added")
time.Sleep(10 * time.Millisecond)

View File

@ -252,9 +252,8 @@ func (suite *OperatorMergeSuite) TestMergeFlapping() {
}
continue
} else {
suite.T().Log("finalizer added")
}
suite.T().Log("finalizer added")
time.Sleep(10 * time.Millisecond)

View File

@ -295,9 +295,8 @@ func (suite *RouteMergeSuite) TestMergeFlapping() {
}
continue
} else {
suite.T().Log("finalizer added")
}
suite.T().Log("finalizer added")
time.Sleep(10 * time.Millisecond)

View File

@ -21,11 +21,7 @@ import (
func Wait(ctx context.Context, r state.State) error {
log.Printf("waiting for network to be ready")
if err := network.NewReadyCondition(r, network.AddressReady).Wait(ctx); err != nil {
return err
}
return nil
return network.NewReadyCondition(r, network.AddressReady).Wait(ctx)
}
// RetryFetch retries fetching from metadata service.

View File

@ -115,9 +115,9 @@ func (v *VMware) ApplyNetworkConfigV2(ctx context.Context, st state.State, confi
macAddressMatched = true
break
} else {
availableMACAddresses = append(availableMACAddresses, macAddress)
}
availableMACAddresses = append(availableMACAddresses, macAddress)
}
if !macAddressMatched {

View File

@ -1727,11 +1727,7 @@ func ResetUserDisks(_ runtime.Sequence, data any) (runtime.TaskExecutionFunc, st
logger.Printf("wiping user disk %s", deviceName)
if err = dev.FastWipe(); err != nil {
return err
}
return nil
return dev.FastWipe()
}
for _, deviceName := range in.GetUserDisksToWipe() {

View File

@ -95,7 +95,7 @@ func (suite *DmesgSuite) TestStreaming() {
defer func() {
suite.ctxCancel()
// drain respCh
for range respCh {
for range respCh { //nolint:revive
}
}()

View File

@ -207,7 +207,7 @@ func (suite *LogsSuite) testStreaming(tailLines int32) {
defer func() {
suite.ctxCancel()
// drain respCh
for range respCh {
for range respCh { //nolint:revive
}
}()

View File

@ -459,7 +459,7 @@ func copyFromReaderWithErrChan(out io.Writer, in io.Reader, errCh <-chan error)
defer wg.Done()
// StreamReader is only singly-buffered, so we need to process any errors as we get them.
for chanErr = range errCh {
for chanErr = range errCh { //nolint:revive
}
}()

View File

@ -183,7 +183,7 @@ func logErr(f func() error) {
func extractRootfsFromInitramfs(input bytes.Buffer, rootfsFilePath string) error {
recReader := cpio.Newc.Reader(bytes.NewReader(input.Bytes()))
if err := cpio.ForEachRecord(recReader, func(r cpio.Record) error {
return cpio.ForEachRecord(recReader, func(r cpio.Record) error {
if r.Name != constants.RootfsAsset {
return nil
}
@ -204,11 +204,7 @@ func extractRootfsFromInitramfs(input bytes.Buffer, rootfsFilePath string) error
}
return f.Close()
}); err != nil {
return err
}
return nil
})
}
func depmod(kernelModulesPath string) error {

View File

@ -23,11 +23,7 @@ func (ext *Extension) Validate() error {
return err
}
if err := ext.validateContents(); err != nil {
return err
}
return nil
return ext.validateContents()
}
func (ext *Extension) validateConstraints() error {

View File

@ -182,11 +182,7 @@ func (c *Config) Save(path string) error {
return err
}
if err = os.WriteFile(c.path.Path, configBytes, 0o600); err != nil {
return err
}
return nil
return os.WriteFile(c.path.Path, configBytes, 0o600)
}
// Bytes gets yaml encoded config data.

View File

@ -120,7 +120,8 @@ func internalCheckUnknownKeys(typ reflect.Type, spec *yaml.Node) (unknown interf
switch typ.Kind() { //nolint:exhaustive
case reflect.Struct:
if fieldIndex, ok := availableKeys[key]; !ok {
fieldIndex, ok := availableKeys[key]
if !ok {
if unknown == nil {
unknown = map[string]interface{}{}
}
@ -128,9 +129,9 @@ func internalCheckUnknownKeys(typ reflect.Type, spec *yaml.Node) (unknown interf
unknown.(map[string]interface{})[key] = spec.Content[i+1]
continue
} else {
elemType = typ.FieldByIndex(fieldIndex).Type
}
elemType = typ.FieldByIndex(fieldIndex).Type
case reflect.Map:
elemType = typ.Elem()
}