Skip to content

Commit

Permalink
chore: enable unused-parameter from revive
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 committed Feb 20, 2025
1 parent 23ceac3 commit 051a2fe
Show file tree
Hide file tree
Showing 30 changed files with 124 additions and 125 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ linters-settings:
disabled: true
- name: unreachable-code
- name: unused-parameter
disabled: true
- name: use-any
- name: var-declaration
- name: var-naming
Expand Down
6 changes: 3 additions & 3 deletions cpu/cpu_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func Times(percpu bool) ([]TimesStat, error) {
return TimesWithContext(context.Background(), percpu)
}

func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
func TimesWithContext(_ context.Context, percpu bool) ([]TimesStat, error) {
lib, err := common.NewLibrary(common.System)
if err != nil {
return nil, err
Expand All @@ -78,7 +78,7 @@ func Info() ([]InfoStat, error) {
return InfoWithContext(context.Background())
}

func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
func InfoWithContext(_ context.Context) ([]InfoStat, error) {
var ret []InfoStat

c := InfoStat{}
Expand Down Expand Up @@ -121,7 +121,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
return append(ret, c), nil
}

func CountsWithContext(ctx context.Context, logical bool) (int, error) {
func CountsWithContext(_ context.Context, logical bool) (int, error) {
var cpuArgument string
if logical {
cpuArgument = "hw.logicalcpu"
Expand Down
2 changes: 1 addition & 1 deletion cpu/cpu_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func Times(percpu bool) ([]TimesStat, error) {
return TimesWithContext(context.Background(), percpu)
}

func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
func TimesWithContext(_ context.Context, percpu bool) ([]TimesStat, error) {
if percpu {
return perCPUTimes()
}
Expand Down
8 changes: 4 additions & 4 deletions disk/disk_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

// PartitionsWithContext returns disk partition.
// 'all' argument is ignored, see: https://github.com/giampaolo/psutil/issues/906
func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
func PartitionsWithContext(_ context.Context, _ bool) ([]PartitionStat, error) {
var ret []PartitionStat

count, err := unix.Getfsstat(nil, unix.MNT_WAIT)
Expand Down Expand Up @@ -88,15 +88,15 @@ func getFsType(stat unix.Statfs_t) string {
return common.ByteToString(stat.Fstypename[:])
}

func SerialNumberWithContext(ctx context.Context, name string) (string, error) {
func SerialNumberWithContext(_ context.Context, _ string) (string, error) {
return "", common.ErrNotImplementedError
}

func LabelWithContext(ctx context.Context, name string) (string, error) {
func LabelWithContext(_ context.Context, _ string) (string, error) {
return "", common.ErrNotImplementedError
}

func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) {
func IOCountersWithContext(_ context.Context, names ...string) (map[string]IOCountersStat, error) {
ioKit, err := common.NewLibrary(common.IOKit)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion disk/disk_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"golang.org/x/sys/unix"
)

func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) {
func UsageWithContext(_ context.Context, path string) (*UsageStat, error) {
stat := unix.Statfs_t{}
err := unix.Statfs(path, &stat)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions disk/disk_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func init() {
}
}

func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) {
func UsageWithContext(_ context.Context, path string) (*UsageStat, error) {
lpFreeBytesAvailable := int64(0)
lpTotalNumberOfBytes := int64(0)
lpTotalNumberOfFreeBytes := int64(0)
Expand Down Expand Up @@ -83,7 +83,7 @@ func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) {

// PartitionsWithContext returns disk partitions.
// Since GetVolumeInformation doesn't have a timeout, this method uses context to set deadline by users.
func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
func PartitionsWithContext(ctx context.Context, _ bool) ([]PartitionStat, error) {
warnings := Warnings{
Verbose: true,
}
Expand Down Expand Up @@ -182,7 +182,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
}
}

func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) {
func IOCountersWithContext(_ context.Context, names ...string) (map[string]IOCountersStat, error) {
// https://github.com/giampaolo/psutil/blob/544e9daa4f66a9f80d7bf6c7886d693ee42f0a13/psutil/arch/windows/disk.c#L83
drivemap := make(map[string]IOCountersStat, 0)
var diskPerformance diskPerformance
Expand Down Expand Up @@ -236,10 +236,10 @@ func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOC
return drivemap, nil
}

func SerialNumberWithContext(ctx context.Context, name string) (string, error) {
func SerialNumberWithContext(_ context.Context, _ string) (string, error) {
return "", common.ErrNotImplementedError
}

func LabelWithContext(ctx context.Context, name string) (string, error) {
func LabelWithContext(_ context.Context, _ string) (string, error) {
return "", common.ErrNotImplementedError
}
4 changes: 2 additions & 2 deletions docker/docker_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
)

func TestGetDockerIDList(t *testing.T) {
func TestGetDockerIDList(_ *testing.T) {
// If there is not docker environment, this test always fail.
// not tested here
/*
Expand All @@ -19,7 +19,7 @@ func TestGetDockerIDList(t *testing.T) {
*/
}

func TestGetDockerStat(t *testing.T) {
func TestGetDockerStat(_ *testing.T) {
// If there is not docker environment, this test always fail.
// not tested here

Expand Down
8 changes: 4 additions & 4 deletions docker/docker_notlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func GetDockerStat() ([]CgroupDockerStat, error) {
return GetDockerStatWithContext(context.Background())
}

func GetDockerStatWithContext(ctx context.Context) ([]CgroupDockerStat, error) {
func GetDockerStatWithContext(_ context.Context) ([]CgroupDockerStat, error) {
return nil, ErrDockerNotAvailable
}

Expand All @@ -25,7 +25,7 @@ func GetDockerIDList() ([]string, error) {
return GetDockerIDListWithContext(context.Background())
}

func GetDockerIDListWithContext(ctx context.Context) ([]string, error) {
func GetDockerIDListWithContext(_ context.Context) ([]string, error) {
return nil, ErrDockerNotAvailable
}

Expand All @@ -37,7 +37,7 @@ func CgroupCPU(containerid string, base string) (*CgroupCPUStat, error) {
return CgroupCPUWithContext(context.Background(), containerid, base)
}

func CgroupCPUWithContext(ctx context.Context, containerid string, base string) (*CgroupCPUStat, error) {
func CgroupCPUWithContext(_ context.Context, _ string, _ string) (*CgroupCPUStat, error) {
return nil, ErrCgroupNotAvailable
}

Expand All @@ -53,7 +53,7 @@ func CgroupMem(containerid string, base string) (*CgroupMemStat, error) {
return CgroupMemWithContext(context.Background(), containerid, base)
}

func CgroupMemWithContext(ctx context.Context, containerid string, base string) (*CgroupMemStat, error) {
func CgroupMemWithContext(_ context.Context, _ string, _ string) (*CgroupMemStat, error) {
return nil, ErrCgroupNotAvailable
}

Expand Down
2 changes: 1 addition & 1 deletion docker/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
)

func TestSysAdvancedDockerInfo(t *testing.T) {
func TestSysAdvancedDockerInfo(_ *testing.T) {
list, err := GetDockerIDList()
if err != nil {
fmt.Println(err)
Expand Down
2 changes: 1 addition & 1 deletion host/host_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// cachedBootTime must be accessed via atomic.Load/StoreUint64
var cachedBootTime uint64

func BootTimeWithContext(ctx context.Context) (uint64, error) {
func BootTimeWithContext(_ context.Context) (uint64, error) {
if enableBootTimeCache {
t := atomic.LoadUint64(&cachedBootTime)
if t != 0 {
Expand Down
6 changes: 3 additions & 3 deletions host/host_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func numProcs(ctx context.Context) (uint64, error) {
return uint64(len(procs)), nil
}

func UsersWithContext(ctx context.Context) ([]UserStat, error) {
func UsersWithContext(_ context.Context) ([]UserStat, error) {
utmpfile := "/var/run/utmpx"
var ret []UserStat

Expand Down Expand Up @@ -123,11 +123,11 @@ func PlatformInformationWithContext(ctx context.Context) (string, string, string
return platform, family, pver, nil
}

func VirtualizationWithContext(ctx context.Context) (string, string, error) {
func VirtualizationWithContext(_ context.Context) (string, string, error) {
return "", "", common.ErrNotImplementedError
}

func KernelVersionWithContext(ctx context.Context) (string, error) {
func KernelVersionWithContext(_ context.Context) (string, error) {
version, err := unix.Sysctl("kern.osrelease")
return strings.ToLower(version), err
}
4 changes: 2 additions & 2 deletions host/host_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) {
return common.BootTimeWithContext(ctx, enableBootTimeCache)
}

func UptimeWithContext(ctx context.Context) (uint64, error) {
func UptimeWithContext(_ context.Context) (uint64, error) {
sysinfo := &unix.Sysinfo_t{}
if err := unix.Sysinfo(sysinfo); err != nil {
return 0, err
Expand Down Expand Up @@ -322,7 +322,7 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil
return platform, family, version, nil
}

func KernelVersionWithContext(ctx context.Context) (version string, err error) {
func KernelVersionWithContext(_ context.Context) (version string, err error) {
var utsname unix.Utsname
err = unix.Uname(&utsname)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions host/host_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type systemInfo struct {
wProcessorRevision uint16
}

func HostIDWithContext(ctx context.Context) (string, error) {
func HostIDWithContext(_ context.Context) (string, error) {
// there has been reports of issues on 32bit using golang.org/x/sys/windows/registry, see https://github.com/shirou/gopsutil/pull/312#issuecomment-277422612
// for rationale of using windows.RegOpenKeyEx/RegQueryValueEx instead of registry.OpenKey/GetStringValue
var h windows.Handle
Expand Down Expand Up @@ -94,7 +94,7 @@ func numProcs(ctx context.Context) (uint64, error) {
return uint64(len(procs)), nil
}

func UptimeWithContext(ctx context.Context) (uint64, error) {
func UptimeWithContext(_ context.Context) (uint64, error) {
up, err := uptimeMillis()
if err != nil {
return 0, err
Expand All @@ -118,7 +118,7 @@ func uptimeMillis() (uint64, error) {
// cachedBootTime must be accessed via atomic.Load/StoreUint64
var cachedBootTime uint64

func BootTimeWithContext(ctx context.Context) (uint64, error) {
func BootTimeWithContext(_ context.Context) (uint64, error) {
if enableBootTimeCache {
t := atomic.LoadUint64(&cachedBootTime)
if t != 0 {
Expand Down Expand Up @@ -234,13 +234,13 @@ func platformInformation() (platform, family, version, displayVersion string, er
return platform, family, version, displayVersion, nil
}

func UsersWithContext(ctx context.Context) ([]UserStat, error) {
func UsersWithContext(_ context.Context) ([]UserStat, error) {
var ret []UserStat

return ret, common.ErrNotImplementedError
}

func VirtualizationWithContext(ctx context.Context) (string, string, error) {
func VirtualizationWithContext(_ context.Context) (string, string, error) {
return "", "", common.ErrNotImplementedError
}

Expand Down
2 changes: 1 addition & 1 deletion internal/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (i FakeInvoke) Command(name string, arg ...string) ([]byte, error) {
return []byte{}, fmt.Errorf("could not find testdata: %s", fpath)
}

func (i FakeInvoke) CommandWithContext(ctx context.Context, name string, arg ...string) ([]byte, error) {
func (i FakeInvoke) CommandWithContext(_ context.Context, name string, arg ...string) ([]byte, error) {
return i.Command(name, arg...)
}

Expand Down
2 changes: 1 addition & 1 deletion load/load_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func Avg() (*AvgStat, error) {
return AvgWithContext(context.Background())
}

func AvgWithContext(ctx context.Context) (*AvgStat, error) {
func AvgWithContext(_ context.Context) (*AvgStat, error) {
// This SysctlRaw method borrowed from
// https://github.com/prometheus/node_exporter/blob/master/collector/loadavg_freebsd.go
// this implementation is common with BSDs
Expand Down
2 changes: 1 addition & 1 deletion load/load_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func Misc() (*MiscStat, error) {
return MiscWithContext(context.Background())
}

func MiscWithContext(ctx context.Context) (*MiscStat, error) {
func MiscWithContext(_ context.Context) (*MiscStat, error) {
ret := MiscStat{}

return &ret, common.ErrNotImplementedError
Expand Down
6 changes: 3 additions & 3 deletions mem/mem_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func SwapMemory() (*SwapMemoryStat, error) {
return SwapMemoryWithContext(context.Background())
}

func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
func SwapMemoryWithContext(_ context.Context) (*SwapMemoryStat, error) {
// https://github.com/yanllearnn/go-osstat/blob/ae8a279d26f52ec946a03698c7f50a26cfb427e3/memory/memory_darwin.go
var ret *SwapMemoryStat

Expand Down Expand Up @@ -67,7 +67,7 @@ func SwapDevices() ([]*SwapDevice, error) {
return SwapDevicesWithContext(context.Background())
}

func SwapDevicesWithContext(ctx context.Context) ([]*SwapDevice, error) {
func SwapDevicesWithContext(_ context.Context) ([]*SwapDevice, error) {
return nil, common.ErrNotImplementedError
}

Expand All @@ -84,7 +84,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
return VirtualMemoryWithContext(context.Background())
}

func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
func VirtualMemoryWithContext(_ context.Context) (*VirtualMemoryStat, error) {
machLib, err := common.NewLibrary(common.System)
if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions mem/mem_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
return VirtualMemoryWithContext(context.Background())
}

func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
func VirtualMemoryWithContext(_ context.Context) (*VirtualMemoryStat, error) {
var memInfo memoryStatusEx
memInfo.cbSize = uint32(unsafe.Sizeof(memInfo))
mem, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memInfo)))
Expand Down Expand Up @@ -77,7 +77,7 @@ func SwapMemory() (*SwapMemoryStat, error) {
return SwapMemoryWithContext(context.Background())
}

func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
func SwapMemoryWithContext(_ context.Context) (*SwapMemoryStat, error) {
// Use the performance counter to get the swap usage percentage
counter, err := common.NewWin32PerformanceCounter("swap_percentage", `\Paging File(_Total)\% Usage`)
if err != nil {
Expand Down Expand Up @@ -151,7 +151,7 @@ func SwapDevices() ([]*SwapDevice, error) {
return SwapDevicesWithContext(context.Background())
}

func SwapDevicesWithContext(ctx context.Context) ([]*SwapDevice, error) {
func SwapDevicesWithContext(_ context.Context) ([]*SwapDevice, error) {
pageSizeOnce.Do(func() {
var sysInfo systemInfo
procGetNativeSystemInfo.Call(uintptr(unsafe.Pointer(&sysInfo)))
Expand Down
2 changes: 1 addition & 1 deletion net/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func Interfaces() (InterfaceStatList, error) {
return InterfacesWithContext(context.Background())
}

func InterfacesWithContext(ctx context.Context) (InterfaceStatList, error) {
func InterfacesWithContext(_ context.Context) (InterfaceStatList, error) {
is, err := net.Interfaces()
if err != nil {
return nil, err
Expand Down
10 changes: 5 additions & 5 deletions net/net_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (mapi mapInterfaceNameUsage) notTruncated() []string {
}

// Deprecated: use process.PidsWithContext instead
func PidsWithContext(ctx context.Context) ([]int32, error) {
func PidsWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}

Expand Down Expand Up @@ -254,18 +254,18 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
return ret, nil
}

func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
func IOCountersByFileWithContext(ctx context.Context, pernic bool, _ string) ([]IOCountersStat, error) {
return IOCountersWithContext(ctx, pernic)
}

func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
func FilterCountersWithContext(_ context.Context) ([]FilterStat, error) {
return nil, common.ErrNotImplementedError
}

func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackStat, error) {
func ConntrackStatsWithContext(_ context.Context, _ bool) ([]ConntrackStat, error) {
return nil, common.ErrNotImplementedError
}

func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error) {
func ProtoCountersWithContext(_ context.Context, _ []string) ([]ProtoCountersStat, error) {
return nil, common.ErrNotImplementedError
}
Loading

0 comments on commit 051a2fe

Please sign in to comment.