Skip to content

chore: enable unused-parameter from revive #1783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ linters-settings:
- name: unnecessary-stmt
- 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
6 changes: 3 additions & 3 deletions cpu/cpu_dragonfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,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 {
buf, err := unix.SysctlRaw("kern.cp_times")
if err != nil {
Expand Down Expand Up @@ -92,7 +92,7 @@ func Info() ([]InfoStat, error) {
return InfoWithContext(context.Background())
}

func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
func InfoWithContext(_ context.Context) ([]InfoStat, error) {
const dmesgBoot = "/var/run/dmesg.boot"

c, err := parseDmesgBoot(dmesgBoot)
Expand Down Expand Up @@ -153,6 +153,6 @@ func parseDmesgBoot(fileName string) (InfoStat, error) {
return c, nil
}

func CountsWithContext(ctx context.Context, logical bool) (int, error) {
func CountsWithContext(_ context.Context, _ bool) (int, error) {
return runtime.NumCPU(), nil
}
6 changes: 3 additions & 3 deletions cpu/cpu_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,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 {
buf, err := unix.SysctlRaw("kern.cp_times")
if err != nil {
Expand Down Expand Up @@ -93,7 +93,7 @@ func Info() ([]InfoStat, error) {
return InfoWithContext(context.Background())
}

func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
func InfoWithContext(_ context.Context) ([]InfoStat, error) {
const dmesgBoot = "/var/run/dmesg.boot"

c, num, err := parseDmesgBoot(dmesgBoot)
Expand Down Expand Up @@ -165,6 +165,6 @@ func parseDmesgBoot(fileName string) (InfoStat, int, error) {
return c, cpuNum, nil
}

func CountsWithContext(ctx context.Context, logical bool) (int, error) {
func CountsWithContext(_ context.Context, _ bool) (int, error) {
return runtime.NumCPU(), nil
}
6 changes: 3 additions & 3 deletions cpu/cpu_netbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func Times(percpu bool) ([]TimesStat, error) {
return TimesWithContext(context.Background(), percpu)
}

func TimesWithContext(ctx context.Context, percpu bool) (ret []TimesStat, err error) {
func TimesWithContext(_ context.Context, percpu bool) (ret []TimesStat, err error) {
if !percpu {
mib := []int32{ctlKern, kernCpTime}
buf, _, err := common.CallSyscall(mib)
Expand Down Expand Up @@ -87,7 +87,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
var err error

Expand Down Expand Up @@ -115,6 +115,6 @@ 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, _ bool) (int, error) {
return runtime.NumCPU(), nil
}
6 changes: 3 additions & 3 deletions cpu/cpu_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func Times(percpu bool) ([]TimesStat, error) {
return TimesWithContext(context.Background(), percpu)
}

func TimesWithContext(ctx context.Context, percpu bool) (ret []TimesStat, err error) {
func TimesWithContext(_ context.Context, percpu bool) (ret []TimesStat, err error) {
if !percpu {
mib := []int32{ctlKern, kernCpTime}
buf, _, err := common.CallSyscall(mib)
Expand Down Expand Up @@ -108,7 +108,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
var err error

Expand All @@ -133,6 +133,6 @@ 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, _ bool) (int, error) {
return runtime.NumCPU(), nil
}
6 changes: 3 additions & 3 deletions cpu/cpu_plan9.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func Times(percpu bool) ([]TimesStat, error) {
return TimesWithContext(context.Background(), percpu)
}

func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
func TimesWithContext(ctx context.Context, _ bool) ([]TimesStat, error) {
// BUG: percpu flag is not supported yet.
root := os.Getenv("HOST_ROOT")
c, err := stats.ReadCPUType(ctx, stats.WithRootDir(root))
Expand All @@ -42,10 +42,10 @@ func Info() ([]InfoStat, error) {
return InfoWithContext(context.Background())
}

func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
func InfoWithContext(_ context.Context) ([]InfoStat, error) {
return []InfoStat{}, common.ErrNotImplementedError
}

func CountsWithContext(ctx context.Context, logical bool) (int, error) {
func CountsWithContext(_ context.Context, _ bool) (int, error) {
return runtime.NumCPU(), nil
}
2 changes: 1 addition & 1 deletion cpu/cpu_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,6 @@ func parseProcessorInfo(cmdOutput string) ([]InfoStat, error) {
return result, nil
}

func CountsWithContext(ctx context.Context, logical bool) (int, error) {
func CountsWithContext(_ context.Context, _ bool) (int, error) {
return runtime.NumCPU(), nil
}
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
10 changes: 5 additions & 5 deletions disk/disk_fallback.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ import (
"github.com/shirou/gopsutil/v4/internal/common"
)

func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) {
func IOCountersWithContext(_ context.Context, _ ...string) (map[string]IOCountersStat, error) {
return nil, common.ErrNotImplementedError
}

func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
func PartitionsWithContext(_ context.Context, _ bool) ([]PartitionStat, error) {
return []PartitionStat{}, common.ErrNotImplementedError
}

func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) {
func UsageWithContext(_ context.Context, _ string) (*UsageStat, error) {
return nil, common.ErrNotImplementedError
}

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 disk/disk_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,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

// get length
Expand Down Expand Up @@ -188,6 +188,6 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) {
return serial, nil
}

func LabelWithContext(ctx context.Context, name string) (string, error) {
func LabelWithContext(_ context.Context, _ string) (string, error) {
return "", common.ErrNotImplementedError
}
10 changes: 5 additions & 5 deletions disk/disk_netbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
MNT_SOFTDEP = 0x80000000 /* Use soft dependencies */
)

func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
func PartitionsWithContext(_ context.Context, _ bool) ([]PartitionStat, error) {
var ret []PartitionStat

flag := uint64(1) // ST_WAIT/MNT_WAIT, see sys/fstypes.h
Expand Down Expand Up @@ -97,12 +97,12 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
return ret, nil
}

func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) {
func IOCountersWithContext(_ context.Context, _ ...string) (map[string]IOCountersStat, error) {
ret := make(map[string]IOCountersStat)
return ret, common.ErrNotImplementedError
}

func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) {
func UsageWithContext(_ context.Context, path string) (*UsageStat, error) {
stat := Statvfs{}
flag := uint64(1) // ST_WAIT/MNT_WAIT, see sys/fstypes.h

Expand Down Expand Up @@ -144,10 +144,10 @@ func getFsType(stat Statvfs) 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
}
10 changes: 5 additions & 5 deletions disk/disk_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/shirou/gopsutil/v4/internal/common"
)

func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
func PartitionsWithContext(_ context.Context, _ bool) ([]PartitionStat, error) {
var ret []PartitionStat

// get length
Expand Down Expand Up @@ -70,7 +70,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
return ret, nil
}

func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) {
func IOCountersWithContext(_ context.Context, names ...string) (map[string]IOCountersStat, error) {
ret := make(map[string]IOCountersStat)

r, err := unix.SysctlRaw("hw.diskstats")
Expand Down Expand Up @@ -122,7 +122,7 @@ func parseDiskstats(buf []byte) (Diskstats, error) {
return ds, nil
}

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 Expand Up @@ -151,10 +151,10 @@ func getFsType(stat unix.Statfs_t) string {
return common.ByteToString(stat.F_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
}
6 changes: 3 additions & 3 deletions disk/disk_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var fsTypeBlacklist = map[string]struct{}{
"proc": {},
}

func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
func PartitionsWithContext(_ context.Context, _ bool) ([]PartitionStat, error) {
ret := make([]PartitionStat, 0, _DEFAULT_NUM_MOUNTS)

// Scan mnttab(4)
Expand Down Expand Up @@ -199,7 +199,7 @@ func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOC
return ret, nil
}

func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) {
func UsageWithContext(_ context.Context, path string) (*UsageStat, error) {
statvfs := unix.Statvfs_t{}
if err := unix.Statvfs(path, &statvfs); err != nil {
return nil, fmt.Errorf("unable to call statvfs(2) on %q: %w", path, err)
Expand Down Expand Up @@ -258,6 +258,6 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) {
return "", nil
}

func LabelWithContext(ctx context.Context, name string) (string, error) {
func LabelWithContext(_ context.Context, _ string) (string, error) {
return "", common.ErrNotImplementedError
}
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
Loading