From f79193c22ccdaa8eeecba90fb8136243ad34fb7b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 17 Feb 2025 13:37:39 +0100 Subject: [PATCH] opts: fix "unused-receiver", line-length-limit linting opts/port.go:124:7: unused-receiver: method receiver 'p' is not referenced in method's body, consider removing or renaming it as _ (revive) func (p *PortOpt) Type() string { ^ opts/mount.go:218:7: unused-receiver: method receiver 'm' is not referenced in method's body, consider removing or renaming it as _ (revive) func (m *MountOpt) Type() string { ^ opts/quotedstring.go:16:7: unused-receiver: method receiver 's' is not referenced in method's body, consider removing or renaming it as _ (revive) func (s *QuotedString) Type() string { ^ opts/secret.go:82:7: unused-receiver: method receiver 'o' is not referenced in method's body, consider removing or renaming it as _ (revive) func (o *SecretOpt) Type() string { ^ opts/opts_test.go:235: line-length-limit: line is 283 characters, out of limit 200 (revive) `foo.bar.baz.this.should.fail.on.long.name.because.it.is.longer.thanisshouldbethis.should.fail.on.long.name.because.it.is.longer.thanisshouldbethis.should.fail.on.long.name.because.it.is.longer.thanisshouldbethis.should.fail.on.long.name.because.it.is.longer.thanisshouldbe`, opts/ulimit.go:61:7: unused-receiver: method receiver 'o' is not referenced in method's body, consider removing or renaming it as _ (revive) func (o *UlimitOpt) Type() string { ^ opts/weightdevice.go:82:7: unused-receiver: method receiver 'opt' is not referenced in method's body, consider removing or renaming it as _ (revive) func (opt *WeightdeviceOpt) Type() string { ^ opts/throttledevice.go:103:7: unused-receiver: method receiver 'opt' is not referenced in method's body, consider removing or renaming it as _ (revive) func (opt *ThrottledeviceOpt) Type() string { ^ opts/duration.go:49:7: unused-receiver: method receiver 'd' is not referenced in method's body, consider removing or renaming it as _ (revive) func (d *DurationOpt) Type() string { ^ opts/network.go:109:7: unused-receiver: method receiver 'n' is not referenced in method's body, consider removing or renaming it as _ (revive) func (n *NetworkOpt) Type() string { ^ opts/network.go:119:7: unused-receiver: method receiver 'n' is not referenced in method's body, consider removing or renaming it as _ (revive) func (n *NetworkOpt) String() string { ^ opts/opts.go:113:7: unused-receiver: method receiver 'opts' is not referenced in method's body, consider removing or renaming it as _ (revive) func (opts *ListOpts) Type() string { ^ opts/pull_behavior.go:13:7: unused-receiver: method receiver 'p' is not referenced in method's body, consider removing or renaming it as _ (revive) func (p *PullOpt) Type() string { ^ opts/config.go:83:7: unused-receiver: method receiver 'o' is not referenced in method's body, consider removing or renaming it as _ (revive) func (o *ConfigOpt) Type() string { ^ opts/gpus.go:95:7: unused-receiver: method receiver 'o' is not referenced in method's body, consider removing or renaming it as _ (revive) func (o *GpuOpts) Type() string { ^ opts/pull_behavior.go:23:7: unused-receiver: method receiver 'p' is not referenced in method's body, consider removing or renaming it as _ (revive) func (p *PullOpt) IsBoolFlag() bool { ^ opts/opts.go:183:7: unused-receiver: method receiver 'opts' is not referenced in method's body, consider removing or renaming it as _ (revive) func (opts *MapOpts) Type() string { ^ opts/opts.go:361:7: unused-receiver: method receiver 'o' is not referenced in method's body, consider removing or renaming it as _ (revive) func (o *FilterOpt) Type() string { ^ opts/opts.go:389:7: unused-receiver: method receiver 'c' is not referenced in method's body, consider removing or renaming it as _ (revive) func (c *NanoCPUs) Type() string { ^ opts/opts.go:466:7: unused-receiver: method receiver 'm' is not referenced in method's body, consider removing or renaming it as _ (revive) func (m *MemBytes) Type() string { ^ opts/opts.go:501:7: unused-receiver: method receiver 'm' is not referenced in method's body, consider removing or renaming it as _ (revive) func (m *MemSwapBytes) Type() string { ^ Signed-off-by: Sebastiaan van Stijn --- opts/config.go | 2 +- opts/duration.go | 2 +- opts/gpus.go | 2 +- opts/mount.go | 2 +- opts/network.go | 4 ++-- opts/opts.go | 12 ++++++------ opts/opts_test.go | 7 +++++-- opts/port.go | 2 +- opts/quotedstring.go | 2 +- opts/secret.go | 2 +- opts/throttledevice.go | 2 +- opts/ulimit.go | 2 +- opts/weightdevice.go | 2 +- 13 files changed, 23 insertions(+), 20 deletions(-) diff --git a/opts/config.go b/opts/config.go index 1423ae3be5..1fc0eb356b 100644 --- a/opts/config.go +++ b/opts/config.go @@ -80,7 +80,7 @@ func (o *ConfigOpt) Set(value string) error { } // Type returns the type of this option -func (o *ConfigOpt) Type() string { +func (*ConfigOpt) Type() string { return "config" } diff --git a/opts/duration.go b/opts/duration.go index 5dc6eeaa73..d55c51e622 100644 --- a/opts/duration.go +++ b/opts/duration.go @@ -46,7 +46,7 @@ func (d *DurationOpt) Set(s string) error { } // Type returns the type of this option, which will be displayed in `--help` output -func (d *DurationOpt) Type() string { +func (*DurationOpt) Type() string { return "duration" } diff --git a/opts/gpus.go b/opts/gpus.go index 93bf939786..993f6da9ae 100644 --- a/opts/gpus.go +++ b/opts/gpus.go @@ -92,7 +92,7 @@ func (o *GpuOpts) Set(value string) error { } // Type returns the type of this option -func (o *GpuOpts) Type() string { +func (*GpuOpts) Type() string { return "gpu-request" } diff --git a/opts/mount.go b/opts/mount.go index 5e23a51394..275a4d7f87 100644 --- a/opts/mount.go +++ b/opts/mount.go @@ -215,7 +215,7 @@ func (m *MountOpt) Set(value string) error { } // Type returns the type of this option -func (m *MountOpt) Type() string { +func (*MountOpt) Type() string { return "mount" } diff --git a/opts/network.go b/opts/network.go index 2ce5dff1f8..c3510870e7 100644 --- a/opts/network.go +++ b/opts/network.go @@ -106,7 +106,7 @@ func (n *NetworkOpt) Set(value string) error { //nolint:gocyclo } // Type returns the type of this option -func (n *NetworkOpt) Type() string { +func (*NetworkOpt) Type() string { return "network" } @@ -116,7 +116,7 @@ func (n *NetworkOpt) Value() []NetworkAttachmentOpts { } // String returns the network opts as a string -func (n *NetworkOpt) String() string { +func (*NetworkOpt) String() string { return "" } diff --git a/opts/opts.go b/opts/opts.go index 157b30f34b..061fda57c5 100644 --- a/opts/opts.go +++ b/opts/opts.go @@ -110,7 +110,7 @@ func (opts *ListOpts) Len() int { } // Type returns a string name for this Option type -func (opts *ListOpts) Type() string { +func (*ListOpts) Type() string { return "list" } @@ -180,7 +180,7 @@ func (opts *MapOpts) String() string { } // Type returns a string name for this Option type -func (opts *MapOpts) Type() string { +func (*MapOpts) Type() string { return "map" } @@ -358,7 +358,7 @@ func (o *FilterOpt) Set(value string) error { } // Type returns the option type -func (o *FilterOpt) Type() string { +func (*FilterOpt) Type() string { return "filter" } @@ -386,7 +386,7 @@ func (c *NanoCPUs) Set(value string) error { } // Type returns the type -func (c *NanoCPUs) Type() string { +func (*NanoCPUs) Type() string { return "decimal" } @@ -463,7 +463,7 @@ func (m *MemBytes) Set(value string) error { } // Type returns the type -func (m *MemBytes) Type() string { +func (*MemBytes) Type() string { return "bytes" } @@ -498,7 +498,7 @@ func (m *MemSwapBytes) Set(value string) error { } // Type returns the type -func (m *MemSwapBytes) Type() string { +func (*MemSwapBytes) Type() string { return "bytes" } diff --git a/opts/opts_test.go b/opts/opts_test.go index 14a36825a2..a69153ca25 100644 --- a/opts/opts_test.go +++ b/opts/opts_test.go @@ -190,7 +190,6 @@ func TestListOptsWithValidator(t *testing.T) { } } -//nolint:lll func TestValidateDNSSearch(t *testing.T) { valid := []string{ `.`, @@ -232,7 +231,11 @@ func TestValidateDNSSearch(t *testing.T) { `foo.bar-.baz`, `foo.-bar`, `foo.-bar.baz`, - `foo.bar.baz.this.should.fail.on.long.name.because.it.is.longer.thanisshouldbethis.should.fail.on.long.name.because.it.is.longer.thanisshouldbethis.should.fail.on.long.name.because.it.is.longer.thanisshouldbethis.should.fail.on.long.name.because.it.is.longer.thanisshouldbe`, + `foo.bar.baz.` + + `this.should.fail.on.long.name.because.it.is.longer.thanisshouldbe` + + `this.should.fail.on.long.name.because.it.is.longer.thanisshouldbe` + + `this.should.fail.on.long.name.because.it.is.longer.thanisshouldbe` + + `this.should.fail.on.long.name.because.it.is.longer.thanisshouldbe`, } for _, domain := range valid { diff --git a/opts/port.go b/opts/port.go index 099aae3534..0407355e65 100644 --- a/opts/port.go +++ b/opts/port.go @@ -121,7 +121,7 @@ func (p *PortOpt) Set(value string) error { } // Type returns the type of this option -func (p *PortOpt) Type() string { +func (*PortOpt) Type() string { return "port" } diff --git a/opts/quotedstring.go b/opts/quotedstring.go index 741f450b14..eb2ac7fbc8 100644 --- a/opts/quotedstring.go +++ b/opts/quotedstring.go @@ -13,7 +13,7 @@ func (s *QuotedString) Set(val string) error { } // Type returns the type of the value -func (s *QuotedString) Type() string { +func (*QuotedString) Type() string { return "string" } diff --git a/opts/secret.go b/opts/secret.go index 09d2b2b3be..bdf232de63 100644 --- a/opts/secret.go +++ b/opts/secret.go @@ -79,7 +79,7 @@ func (o *SecretOpt) Set(value string) error { } // Type returns the type of this option -func (o *SecretOpt) Type() string { +func (*SecretOpt) Type() string { return "secret" } diff --git a/opts/throttledevice.go b/opts/throttledevice.go index 8bf1288047..46b09185c7 100644 --- a/opts/throttledevice.go +++ b/opts/throttledevice.go @@ -100,6 +100,6 @@ func (opt *ThrottledeviceOpt) GetList() []*blkiodev.ThrottleDevice { } // Type returns the option type -func (opt *ThrottledeviceOpt) Type() string { +func (*ThrottledeviceOpt) Type() string { return "list" } diff --git a/opts/ulimit.go b/opts/ulimit.go index 1409a109bc..48052c887c 100644 --- a/opts/ulimit.go +++ b/opts/ulimit.go @@ -58,6 +58,6 @@ func (o *UlimitOpt) GetList() []*container.Ulimit { } // Type returns the option type -func (o *UlimitOpt) Type() string { +func (*UlimitOpt) Type() string { return "ulimit" } diff --git a/opts/weightdevice.go b/opts/weightdevice.go index ee377fc33a..036c7c8c50 100644 --- a/opts/weightdevice.go +++ b/opts/weightdevice.go @@ -79,6 +79,6 @@ func (opt *WeightdeviceOpt) GetList() []*blkiodev.WeightDevice { } // Type returns the option type -func (opt *WeightdeviceOpt) Type() string { +func (*WeightdeviceOpt) Type() string { return "list" }