From e4e5f38eee047bf784f8248ab590a6ff569aba25 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Sun, 9 Mar 2025 11:54:03 +0100 Subject: [PATCH] chore: enable var-naming from revive Signed-off-by: Matthieu MOREL --- .golangci.yml | 5 ++++- cpu/cpu_aix_nocgo.go | 4 ++-- cpu/cpu_darwin.go | 4 ++-- cpu/cpu_windows.go | 8 ++++---- disk/disk_freebsd.go | 4 ++-- disk/disk_linux.go | 6 +++--- host/host_aix.go | 2 +- host/host_darwin.go | 2 +- host/host_linux.go | 2 +- host/host_linux_386.go | 16 ++++++++-------- internal/common/common_windows.go | 6 +++--- load/load_bsd.go | 2 +- load/load_linux.go | 8 ++++---- net/net_linux.go | 16 ++++++++-------- net/net_windows.go | 16 ++++++++-------- process/process.go | 12 ++++++------ process/process_darwin.go | 2 +- process/process_windows.go | 2 +- process/process_windows_32bit.go | 2 +- process/process_windows_64bit.go | 2 +- sensors/sensors_windows.go | 2 +- 21 files changed, 63 insertions(+), 60 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 96d9ddd..39afc63 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -99,7 +99,10 @@ linters-settings: - name: use-any - name: var-declaration - name: var-naming - disabled: true + arguments: + - ["ID"] # AllowList + - ["VM"] # DenyList + - - upperCaseConst: true # Extra parameter (upperCaseConst|skipPackageNameChecks) testifylint: enable-all: true thelper: diff --git a/cpu/cpu_aix_nocgo.go b/cpu/cpu_aix_nocgo.go index 783e968..f65b452 100644 --- a/cpu/cpu_aix_nocgo.go +++ b/cpu/cpu_aix_nocgo.go @@ -14,11 +14,11 @@ import ( func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) { var ret []TimesStat if percpu { - per_out, err := invoke.CommandWithContext(ctx, "sar", "-u", "-P", "ALL", "10", "1") + perOut, err := invoke.CommandWithContext(ctx, "sar", "-u", "-P", "ALL", "10", "1") if err != nil { return nil, err } - lines := strings.Split(string(per_out), "\n") + lines := strings.Split(string(perOut), "\n") if len(lines) < 6 { return []TimesStat{}, common.ErrNotImplementedError } diff --git a/cpu/cpu_darwin.go b/cpu/cpu_darwin.go index b3e3a66..48db37c 100644 --- a/cpu/cpu_darwin.go +++ b/cpu/cpu_darwin.go @@ -37,10 +37,10 @@ const ( // mach/processor_info.h const ( - processorCpuLoadInfo = 2 + processorCpuLoadInfo = 2 //nolint:revive //FIXME ) -type hostCpuLoadInfoData struct { +type hostCpuLoadInfoData struct { //nolint:revive //FIXME cpuTicks [cpuStateMax]uint32 } diff --git a/cpu/cpu_windows.go b/cpu/cpu_windows.go index a71df97..9b87d71 100644 --- a/cpu/cpu_windows.go +++ b/cpu/cpu_windows.go @@ -17,7 +17,7 @@ import ( var procGetNativeSystemInfo = common.Modkernel32.NewProc("GetNativeSystemInfo") -type win32_Processor struct { +type win32_Processor struct { //nolint:revive //FIXME Family uint16 Manufacturer string Name string @@ -33,7 +33,7 @@ type win32_Processor struct { // https://docs.microsoft.com/en-us/windows/desktop/api/winternl/nf-winternl-ntquerysysteminformation#system_processor_performance_information // additional fields documented here // https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/sysinfo/processor_performance.htm -type win32_SystemProcessorPerformanceInformation struct { +type win32_SystemProcessorPerformanceInformation struct { //nolint:revive //FIXME IdleTime int64 // idle time in 100ns (this is not a filetime). KernelTime int64 // kernel time in 100ns. kernel time includes idle time. (this is not a filetime). UserTime int64 // usertime in 100ns (this is not a filetime). @@ -47,10 +47,10 @@ const ( // systemProcessorPerformanceInformationClass information class to query with NTQuerySystemInformation // https://processhacker.sourceforge.io/doc/ntexapi_8h.html#ad5d815b48e8f4da1ef2eb7a2f18a54e0 - win32_SystemProcessorPerformanceInformationClass = 8 + win32_SystemProcessorPerformanceInformationClass = 8 //nolint:revive //FIXME // size of systemProcessorPerformanceInfoSize in memory - win32_SystemProcessorPerformanceInfoSize = uint32(unsafe.Sizeof(win32_SystemProcessorPerformanceInformation{})) + win32_SystemProcessorPerformanceInfoSize = uint32(unsafe.Sizeof(win32_SystemProcessorPerformanceInformation{})) //nolint:revive //FIXME ) // Times returns times stat per cpu and combined for all CPUs diff --git a/disk/disk_freebsd.go b/disk/disk_freebsd.go index 9715d76..2274ef3 100644 --- a/disk/disk_freebsd.go +++ b/disk/disk_freebsd.go @@ -144,8 +144,8 @@ func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOC } func (b bintime) Compute() float64 { - BINTIME_SCALE := 5.42101086242752217003726400434970855712890625e-20 - return float64(b.Sec) + float64(b.Frac)*BINTIME_SCALE + bintimeScale := 5.42101086242752217003726400434970855712890625e-20 + return float64(b.Sec) + float64(b.Frac)*bintimeScale } // BT2LD(time) ((long double)(time).sec + (time).frac * BINTIME_SCALE) diff --git a/disk/disk_linux.go b/disk/disk_linux.go index e94d212..222056b 100644 --- a/disk/disk_linux.go +++ b/disk/disk_linux.go @@ -528,10 +528,10 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) { func LabelWithContext(ctx context.Context, name string) (string, error) { // Try label based on devicemapper name - dmname_filename := common.HostSysWithContext(ctx, fmt.Sprintf("block/%s/dm/name", name)) + dmnameFilename := common.HostSysWithContext(ctx, fmt.Sprintf("block/%s/dm/name", name)) // Could errors.Join errs with Go >= 1.20 - if common.PathExists(dmname_filename) { - dmname, err := os.ReadFile(dmname_filename) + if common.PathExists(dmnameFilename) { + dmname, err := os.ReadFile(dmnameFilename) if err == nil { return strings.TrimSpace(string(dmname)), nil } diff --git a/host/host_aix.go b/host/host_aix.go index 2785bec..35f7be7 100644 --- a/host/host_aix.go +++ b/host/host_aix.go @@ -14,7 +14,7 @@ import ( // from https://www.ibm.com/docs/en/aix/7.2?topic=files-utmph-file const ( - user_PROCESS = 7 + user_PROCESS = 7 //nolint:revive //FIXME ) func HostIDWithContext(ctx context.Context) (string, error) { diff --git a/host/host_darwin.go b/host/host_darwin.go index 068f106..aced257 100644 --- a/host/host_darwin.go +++ b/host/host_darwin.go @@ -20,7 +20,7 @@ import ( ) // from utmpx.h -const user_PROCESS = 7 +const user_PROCESS = 7 //nolint:revive //FIXME func HostIDWithContext(ctx context.Context) (string, error) { out, err := invoke.CommandWithContext(ctx, "ioreg", "-rd1", "-c", "IOPlatformExpertDevice") diff --git a/host/host_linux.go b/host/host_linux.go index dd03f15..8cb6f01 100644 --- a/host/host_linux.go +++ b/host/host_linux.go @@ -27,7 +27,7 @@ type lsbStruct struct { // from utmp.h const ( - user_PROCESS = 7 + user_PROCESS = 7 //nolint:revive //FIXME ) func HostIDWithContext(ctx context.Context) (string, error) { diff --git a/host/host_linux_386.go b/host/host_linux_386.go index 3e241b1..b7e9301 100644 --- a/host/host_linux_386.go +++ b/host/host_linux_386.go @@ -16,15 +16,15 @@ const ( ) type ( - _C_short int16 - _C_int int32 - _C_long int32 - _C_long_long int64 + _C_short int16 //nolint:revive //FIXME + _C_int int32 //nolint:revive //FIXME + _C_long int32 //nolint:revive //FIXME + _C_long_long int64 //nolint:revive //FIXME ) type utmp struct { Type int16 - Pad_cgo_0 [2]byte + Pad_cgo_0 [2]byte //nolint:revive //FIXME Pid int32 Line [32]int8 ID [4]int8 @@ -33,11 +33,11 @@ type utmp struct { Exit exit_status Session int32 Tv UtTv - Addr_v6 [4]int32 - X__unused [20]int8 + Addr_v6 [4]int32 //nolint:revive //FIXME + X__unused [20]int8 //nolint:revive //FIXME } -type exit_status struct { +type exit_status struct { //nolint:revive //FIXME Termination int16 Exit int16 } diff --git a/internal/common/common_windows.go b/internal/common/common_windows.go index 09ecf59..6c74700 100644 --- a/internal/common/common_windows.go +++ b/internal/common/common_windows.go @@ -17,19 +17,19 @@ import ( ) // for double values -type PDH_FMT_COUNTERVALUE_DOUBLE struct { +type PDH_FMT_COUNTERVALUE_DOUBLE struct { //nolint:revive //FIXME CStatus uint32 DoubleValue float64 } // for 64 bit integer values -type PDH_FMT_COUNTERVALUE_LARGE struct { +type PDH_FMT_COUNTERVALUE_LARGE struct { //nolint:revive //FIXME CStatus uint32 LargeValue int64 } // for long values -type PDH_FMT_COUNTERVALUE_LONG struct { +type PDH_FMT_COUNTERVALUE_LONG struct { //nolint:revive //FIXME CStatus uint32 LongValue int32 padding [4]byte diff --git a/load/load_bsd.go b/load/load_bsd.go index 97001f3..c41f62c 100644 --- a/load/load_bsd.go +++ b/load/load_bsd.go @@ -40,7 +40,7 @@ func AvgWithContext(ctx context.Context) (*AvgStat, error) { type forkstat struct { forks int vforks int - __tforks int + __tforks int //nolint:revive //FIXME } // Misc returns miscellaneous host-wide statistics. diff --git a/load/load_linux.go b/load/load_linux.go index e964b69..2636a3d 100644 --- a/load/load_linux.go +++ b/load/load_linux.go @@ -32,11 +32,11 @@ func sysinfoAvgWithContext() (*AvgStat, error) { return nil, err } - const si_load_shift = 16 + const siLoadShift = 16 return &AvgStat{ - Load1: float64(info.Loads[0]) / float64(1<