diff --git a/common/.golangci.yml b/common/.golangci.yml index db2be8ee64..a53814c324 100644 --- a/common/.golangci.yml +++ b/common/.golangci.yml @@ -44,6 +44,7 @@ linters: - mirror - misspell - nilnesserr + - nolintlint - nosprintfhostport - perfsprint - prealloc diff --git a/common/libimage/corrupted_test.go b/common/libimage/corrupted_test.go index 0275b550d4..ada09bff27 100644 --- a/common/libimage/corrupted_test.go +++ b/common/libimage/corrupted_test.go @@ -58,7 +58,7 @@ func TestCorruptedLayers(t *testing.T) { // Now write back the layers without the first layer! data, err = json.Marshal(layers[1:]) require.NoError(t, err, "unmarshaling layers.json") - err = ioutils.AtomicWriteFile(indexPath, data, 0o600) // nolint + err = ioutils.AtomicWriteFile(indexPath, data, 0o600) require.NoError(t, err, "writing back layers.json") err = image.reload() // clear the cached data diff --git a/common/libimage/image_config.go b/common/libimage/image_config.go index a34bc3be92..952d87c59e 100644 --- a/common/libimage/image_config.go +++ b/common/libimage/image_config.go @@ -34,7 +34,7 @@ type ImageConfig struct { // * LABEL // * STOPSIGNAL // * ONBUILD. -func ImageConfigFromChanges(changes []string) (*ImageConfig, error) { // nolint:gocyclo +func ImageConfigFromChanges(changes []string) (*ImageConfig, error) { config := &ImageConfig{} for _, change := range changes { diff --git a/common/libimage/load.go b/common/libimage/load.go index 598bf39cdc..43342a190b 100644 --- a/common/libimage/load.go +++ b/common/libimage/load.go @@ -114,8 +114,7 @@ func (r *Runtime) Load(ctx context.Context, path string, options *LoadOptions) ( } // Give a decent error message if nothing above worked. - // we want the colon here for the multiline error - //nolint:revive,staticcheck + //nolint:staticcheck // We want the colon here for the multiline error. loadError := errors.New("payload does not match any of the supported image formats:") for _, err := range loadErrors { loadError = fmt.Errorf("%v\n * %v", loadError, err) diff --git a/common/libimage/manifests/manifests.go b/common/libimage/manifests/manifests.go index 3caff540dd..921e25da60 100644 --- a/common/libimage/manifests/manifests.go +++ b/common/libimage/manifests/manifests.go @@ -957,7 +957,7 @@ func (l *list) Remove(instanceDigest digest.Digest) error { // then use that list's SaveToImage() method to save a modified version of the // list to that image record use this lock to avoid accidentally wiping out // changes that another process is also attempting to make. -func LockerForImage(store storage.Store, image string) (lockfile.Locker, error) { // nolint:staticcheck +func LockerForImage(store storage.Store, image string) (lockfile.Locker, error) { //nolint:staticcheck // suppress "lockfile.Locker is deprecated". img, err := store.Image(image) if err != nil { return nil, fmt.Errorf("locating image %q for locating lock: %w", image, err) diff --git a/common/libnetwork/netavark/run_test.go b/common/libnetwork/netavark/run_test.go index 072a8f1275..7e35c74c3e 100644 --- a/common/libnetwork/netavark/run_test.go +++ b/common/libnetwork/netavark/run_test.go @@ -293,7 +293,7 @@ var _ = Describe("run netavark", func() { netNSContainer2, err := netns.NewNS() Expect(err).ToNot(HaveOccurred()) defer netns.UnmountNS(netNSContainer2.Path()) //nolint:errcheck - defer netNSContainer2.Close() //nolint:errcheck + defer netNSContainer2.Close() res, err = libpodNet.Setup(netNSContainer2.Path(), setupOpts2) Expect(err).ToNot(HaveOccurred()) diff --git a/common/libnetwork/network/interface.go b/common/libnetwork/network/interface.go index 4a08e85339..e7eb0e71b8 100644 --- a/common/libnetwork/network/interface.go +++ b/common/libnetwork/network/interface.go @@ -23,10 +23,6 @@ const ( // NetworkBackend returns the network backend name and interface. // It returns the netavark backend. If no backend is set in the config, // it defaults to netavark. Any other backend value is an error. -// -// revive does not like the name because the package is already called network -// -//nolint:revive func NetworkBackend(store storage.Store, conf *config.Config, syslog bool) (types.NetworkBackend, types.ContainerNetwork, error) { backend := types.NetworkBackend(conf.Network.NetworkBackend) if backend != "" && backend != types.Netavark { diff --git a/common/pkg/config/config.go b/common/pkg/config/config.go index e53dcce63b..7aa070c955 100644 --- a/common/pkg/config/config.go +++ b/common/pkg/config/config.go @@ -663,11 +663,7 @@ type SecretConfig struct { Opts map[string]string `toml:"opts,omitempty"` } -// ConfigMapConfig represents the "configmap" TOML config table -// -// revive does not like the name because the package is already called config -// -//nolint:revive +// ConfigMapConfig represents the "configmap" TOML config table. type ConfigMapConfig struct { // Driver specifies the configmap driver to use. // Current valid value: diff --git a/common/pkg/config/default.go b/common/pkg/config/default.go index 1fd30e21cf..fcd20b3003 100644 --- a/common/pkg/config/default.go +++ b/common/pkg/config/default.go @@ -138,8 +138,7 @@ var ( defaultContainerEnv = []string{"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"} ) -// nolint:unparam -func parseSubnetPool(subnet string, size int) SubnetPool { +func parseSubnetPool(subnet string, size int) SubnetPool { //nolint:unparam // Suppress "size always receives 24". _, n, _ := net.ParseCIDR(subnet) return SubnetPool{ Base: &nettypes.IPNet{IPNet: *n}, diff --git a/common/pkg/configmaps/configmaps.go b/common/pkg/configmaps/configmaps.go index f58b65ba33..b90afd5242 100644 --- a/common/pkg/configmaps/configmaps.go +++ b/common/pkg/configmaps/configmaps.go @@ -82,10 +82,6 @@ type ConfigMap struct { // ConfigMapsDriver interfaces with the configMaps data store. // The driver stores the actual bytes of configMap data, as opposed to // the configMap metadata. -// -// revive does not like the name because the package is already called configmaps -// -//nolint:revive type ConfigMapsDriver interface { // List lists all configMap ids in the configMaps data store List() ([]string, error) diff --git a/common/pkg/filters/filters.go b/common/pkg/filters/filters.go index 385a9d73d9..6e6953e4f1 100644 --- a/common/pkg/filters/filters.go +++ b/common/pkg/filters/filters.go @@ -39,10 +39,6 @@ func ComputeUntilTimestamp(filterValues []string) (time.Time, error) { // // Please refer to https://github.com/containers/podman/issues/6899 for some // background. -// -// revive does not like the name because the package is already called filters -// -//nolint:revive func FiltersFromRequest(r *http.Request) ([]string, error) { var ( compatFilters map[string]map[string]bool diff --git a/common/pkg/flag/flag_test.go b/common/pkg/flag/flag_test.go index 147bcd7e15..0f5dce7e89 100644 --- a/common/pkg/flag/flag_test.go +++ b/common/pkg/flag/flag_test.go @@ -111,8 +111,8 @@ func TestOptionalBoolIsBoolFlag(t *testing.T) { cmd := &cobra.Command{ Use: "cmd", RunE: func(_ *cobra.Command, args []string) error { - assert.Equal(t, c.expectedOB, ob) // nolint - assert.Equal(t, c.expectedArgs, args) //nolint + assert.Equal(t, c.expectedOB, ob) + assert.Equal(t, c.expectedArgs, args) actionRun = true return nil }, @@ -206,8 +206,8 @@ func TestOptionalStringIsBoolFlag(t *testing.T) { cmd := &cobra.Command{ Use: "cmd", RunE: func(cmd *cobra.Command, args []string) error { - assert.Equal(t, c.expectedOS, os) // nolint - assert.Equal(t, c.expectedArgs, args) // nolint + assert.Equal(t, c.expectedOS, os) + assert.Equal(t, c.expectedArgs, args) actionRun = true return nil }, diff --git a/common/pkg/manifests/manifests.go b/common/pkg/manifests/manifests.go index 7ae1f41f49..0b6911fb98 100644 --- a/common/pkg/manifests/manifests.go +++ b/common/pkg/manifests/manifests.go @@ -95,7 +95,7 @@ func sliceToMap(s []string) map[string]string { // AddInstance adds an entry for the specified manifest digest, with assorted // additional information specified in parameters, to the list or index. -func (l *list) AddInstance(manifestDigest digest.Digest, manifestSize int64, manifestType, osName, architecture, osVersion string, osFeatures []string, variant string, features, annotations []string) error { // nolint:revive +func (l *list) AddInstance(manifestDigest digest.Digest, manifestSize int64, manifestType, osName, architecture, osVersion string, osFeatures []string, variant string, features, annotations []string) error { if err := l.Remove(manifestDigest); err != nil && !errors.Is(err, os.ErrNotExist) { return err } diff --git a/common/pkg/parse/parse_test.go b/common/pkg/parse/parse_test.go index e071184094..e1993bd23a 100644 --- a/common/pkg/parse/parse_test.go +++ b/common/pkg/parse/parse_test.go @@ -45,16 +45,16 @@ func TestDeviceParser(t *testing.T) { assert.Equal(t, permissions, "rm") // test bogus permissions - _, _, _, err = Device("/dev/fuse1:BOGUS") //nolint + _, _, _, err = Device("/dev/fuse1:BOGUS") assert.Error(t, err) - _, _, _, err = Device("") //nolint + _, _, _, err = Device("") assert.Error(t, err) - _, _, _, err = Device("/dev/foo:/dev/bar:rm:") //nolint + _, _, _, err = Device("/dev/foo:/dev/bar:rm:") assert.Error(t, err) - _, _, _, err = Device("/dev/foo::rm") //nolint + _, _, _, err = Device("/dev/foo::rm") assert.Error(t, err) } diff --git a/common/pkg/report/formatter_test.go b/common/pkg/report/formatter_test.go index 34f02a91b8..60d1619b69 100644 --- a/common/pkg/report/formatter_test.go +++ b/common/pkg/report/formatter_test.go @@ -33,8 +33,9 @@ func TestFormatter_HasTable(t *testing.T) { type testFormatterStruct struct { FieldA bool // camel case test Fieldb bool // no camel case - fieldC bool // nolint // private field - fieldd bool // nolint // private field + // Private fields. + fieldC bool //nolint:unused + fieldd bool //nolint:unused } func TestFormatter_HeadersNoOverrides(t *testing.T) { diff --git a/common/pkg/report/template_test.go b/common/pkg/report/template_test.go index 5cba5e1400..a221215494 100644 --- a/common/pkg/report/template_test.go +++ b/common/pkg/report/template_test.go @@ -16,8 +16,9 @@ func TestNewTemplate(t *testing.T) { type testStruct struct { FieldA bool // camel case test Fieldb bool // no camel case - fieldC bool // nolint // private field - fieldd bool // nolint // private field + // Private fields. + fieldC bool //nolint:unused + fieldd bool //nolint:unused } func TestHeadersSimple(t *testing.T) { diff --git a/common/pkg/retry/retry.go b/common/pkg/retry/retry.go index 457dbaf6bc..ad0b067235 100644 --- a/common/pkg/retry/retry.go +++ b/common/pkg/retry/retry.go @@ -26,10 +26,10 @@ type Options struct { } // RetryOptions is deprecated, use Options. -type RetryOptions = Options // nolint:revive +type RetryOptions = Options // RetryIfNecessary deprecated function use IfNecessary. -func RetryIfNecessary(ctx context.Context, operation func() error, options *Options) error { // nolint:revive +func RetryIfNecessary(ctx context.Context, operation func() error, options *Options) error { return IfNecessary(ctx, operation, options) } diff --git a/common/pkg/secrets/secrets.go b/common/pkg/secrets/secrets.go index 1edf766168..880c419714 100644 --- a/common/pkg/secrets/secrets.go +++ b/common/pkg/secrets/secrets.go @@ -54,11 +54,7 @@ var errIgnoreIfExistsAndReplace = errors.New("ignoreIfExists and replace cannot // secretsFile is the name of the file that the secrets database will be stored in. var secretsFile = "secrets.json" -// SecretsManager holds information on handling secrets -// -// revive does not like the name because the package is already called secrets -// -//nolint:revive +// SecretsManager holds information on handling secrets. type SecretsManager struct { // secretsPath is the path to the db file where secrets are stored secretsDBPath string @@ -92,10 +88,6 @@ type Secret struct { // The driver stores the actual bytes of secret data, as opposed to // the secret metadata. // Currently only the unencrypted filedriver is implemented. -// -// revive does not like the name because the package is already called secrets -// -//nolint:revive type SecretsDriver interface { // List lists all secret ids in the secrets data store List() ([]string, error) diff --git a/common/pkg/umask/umask_unix.go b/common/pkg/umask/umask_unix.go index caa60c8e68..950e45901c 100644 --- a/common/pkg/umask/umask_unix.go +++ b/common/pkg/umask/umask_unix.go @@ -9,7 +9,7 @@ import ( ) func Check() { - oldUmask := syscall.Umask(0o022) //nolint + oldUmask := syscall.Umask(0o022) if (oldUmask & ^0o022) != 0 { logrus.Debugf("umask value too restrictive. Forcing it to 022") }