Skip to content

Commit e4e5f38

Browse files
committed
chore: enable var-naming from revive
Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 62da883 commit e4e5f38

21 files changed

+63
-60
lines changed

.golangci.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ linters-settings:
9999
- name: use-any
100100
- name: var-declaration
101101
- name: var-naming
102-
disabled: true
102+
arguments:
103+
- ["ID"] # AllowList
104+
- ["VM"] # DenyList
105+
- - upperCaseConst: true # Extra parameter (upperCaseConst|skipPackageNameChecks)
103106
testifylint:
104107
enable-all: true
105108
thelper:

cpu/cpu_aix_nocgo.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import (
1414
func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
1515
var ret []TimesStat
1616
if percpu {
17-
per_out, err := invoke.CommandWithContext(ctx, "sar", "-u", "-P", "ALL", "10", "1")
17+
perOut, err := invoke.CommandWithContext(ctx, "sar", "-u", "-P", "ALL", "10", "1")
1818
if err != nil {
1919
return nil, err
2020
}
21-
lines := strings.Split(string(per_out), "\n")
21+
lines := strings.Split(string(perOut), "\n")
2222
if len(lines) < 6 {
2323
return []TimesStat{}, common.ErrNotImplementedError
2424
}

cpu/cpu_darwin.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ const (
3737

3838
// mach/processor_info.h
3939
const (
40-
processorCpuLoadInfo = 2
40+
processorCpuLoadInfo = 2 //nolint:revive //FIXME
4141
)
4242

43-
type hostCpuLoadInfoData struct {
43+
type hostCpuLoadInfoData struct { //nolint:revive //FIXME
4444
cpuTicks [cpuStateMax]uint32
4545
}
4646

cpu/cpu_windows.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717

1818
var procGetNativeSystemInfo = common.Modkernel32.NewProc("GetNativeSystemInfo")
1919

20-
type win32_Processor struct {
20+
type win32_Processor struct { //nolint:revive //FIXME
2121
Family uint16
2222
Manufacturer string
2323
Name string
@@ -33,7 +33,7 @@ type win32_Processor struct {
3333
// https://docs.microsoft.com/en-us/windows/desktop/api/winternl/nf-winternl-ntquerysysteminformation#system_processor_performance_information
3434
// additional fields documented here
3535
// https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/sysinfo/processor_performance.htm
36-
type win32_SystemProcessorPerformanceInformation struct {
36+
type win32_SystemProcessorPerformanceInformation struct { //nolint:revive //FIXME
3737
IdleTime int64 // idle time in 100ns (this is not a filetime).
3838
KernelTime int64 // kernel time in 100ns. kernel time includes idle time. (this is not a filetime).
3939
UserTime int64 // usertime in 100ns (this is not a filetime).
@@ -47,10 +47,10 @@ const (
4747

4848
// systemProcessorPerformanceInformationClass information class to query with NTQuerySystemInformation
4949
// https://processhacker.sourceforge.io/doc/ntexapi_8h.html#ad5d815b48e8f4da1ef2eb7a2f18a54e0
50-
win32_SystemProcessorPerformanceInformationClass = 8
50+
win32_SystemProcessorPerformanceInformationClass = 8 //nolint:revive //FIXME
5151

5252
// size of systemProcessorPerformanceInfoSize in memory
53-
win32_SystemProcessorPerformanceInfoSize = uint32(unsafe.Sizeof(win32_SystemProcessorPerformanceInformation{}))
53+
win32_SystemProcessorPerformanceInfoSize = uint32(unsafe.Sizeof(win32_SystemProcessorPerformanceInformation{})) //nolint:revive //FIXME
5454
)
5555

5656
// Times returns times stat per cpu and combined for all CPUs

disk/disk_freebsd.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOC
144144
}
145145

146146
func (b bintime) Compute() float64 {
147-
BINTIME_SCALE := 5.42101086242752217003726400434970855712890625e-20
148-
return float64(b.Sec) + float64(b.Frac)*BINTIME_SCALE
147+
bintimeScale := 5.42101086242752217003726400434970855712890625e-20
148+
return float64(b.Sec) + float64(b.Frac)*bintimeScale
149149
}
150150

151151
// BT2LD(time) ((long double)(time).sec + (time).frac * BINTIME_SCALE)

disk/disk_linux.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,10 @@ func SerialNumberWithContext(ctx context.Context, name string) (string, error) {
528528

529529
func LabelWithContext(ctx context.Context, name string) (string, error) {
530530
// Try label based on devicemapper name
531-
dmname_filename := common.HostSysWithContext(ctx, fmt.Sprintf("block/%s/dm/name", name))
531+
dmnameFilename := common.HostSysWithContext(ctx, fmt.Sprintf("block/%s/dm/name", name))
532532
// Could errors.Join errs with Go >= 1.20
533-
if common.PathExists(dmname_filename) {
534-
dmname, err := os.ReadFile(dmname_filename)
533+
if common.PathExists(dmnameFilename) {
534+
dmname, err := os.ReadFile(dmnameFilename)
535535
if err == nil {
536536
return strings.TrimSpace(string(dmname)), nil
537537
}

host/host_aix.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
// from https://www.ibm.com/docs/en/aix/7.2?topic=files-utmph-file
1616
const (
17-
user_PROCESS = 7
17+
user_PROCESS = 7 //nolint:revive //FIXME
1818
)
1919

2020
func HostIDWithContext(ctx context.Context) (string, error) {

host/host_darwin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
)
2121

2222
// from utmpx.h
23-
const user_PROCESS = 7
23+
const user_PROCESS = 7 //nolint:revive //FIXME
2424

2525
func HostIDWithContext(ctx context.Context) (string, error) {
2626
out, err := invoke.CommandWithContext(ctx, "ioreg", "-rd1", "-c", "IOPlatformExpertDevice")

host/host_linux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type lsbStruct struct {
2727

2828
// from utmp.h
2929
const (
30-
user_PROCESS = 7
30+
user_PROCESS = 7 //nolint:revive //FIXME
3131
)
3232

3333
func HostIDWithContext(ctx context.Context) (string, error) {

host/host_linux_386.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ const (
1616
)
1717

1818
type (
19-
_C_short int16
20-
_C_int int32
21-
_C_long int32
22-
_C_long_long int64
19+
_C_short int16 //nolint:revive //FIXME
20+
_C_int int32 //nolint:revive //FIXME
21+
_C_long int32 //nolint:revive //FIXME
22+
_C_long_long int64 //nolint:revive //FIXME
2323
)
2424

2525
type utmp struct {
2626
Type int16
27-
Pad_cgo_0 [2]byte
27+
Pad_cgo_0 [2]byte //nolint:revive //FIXME
2828
Pid int32
2929
Line [32]int8
3030
ID [4]int8
@@ -33,11 +33,11 @@ type utmp struct {
3333
Exit exit_status
3434
Session int32
3535
Tv UtTv
36-
Addr_v6 [4]int32
37-
X__unused [20]int8
36+
Addr_v6 [4]int32 //nolint:revive //FIXME
37+
X__unused [20]int8 //nolint:revive //FIXME
3838
}
3939

40-
type exit_status struct {
40+
type exit_status struct { //nolint:revive //FIXME
4141
Termination int16
4242
Exit int16
4343
}

internal/common/common_windows.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ import (
1717
)
1818

1919
// for double values
20-
type PDH_FMT_COUNTERVALUE_DOUBLE struct {
20+
type PDH_FMT_COUNTERVALUE_DOUBLE struct { //nolint:revive //FIXME
2121
CStatus uint32
2222
DoubleValue float64
2323
}
2424

2525
// for 64 bit integer values
26-
type PDH_FMT_COUNTERVALUE_LARGE struct {
26+
type PDH_FMT_COUNTERVALUE_LARGE struct { //nolint:revive //FIXME
2727
CStatus uint32
2828
LargeValue int64
2929
}
3030

3131
// for long values
32-
type PDH_FMT_COUNTERVALUE_LONG struct {
32+
type PDH_FMT_COUNTERVALUE_LONG struct { //nolint:revive //FIXME
3333
CStatus uint32
3434
LongValue int32
3535
padding [4]byte

load/load_bsd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func AvgWithContext(ctx context.Context) (*AvgStat, error) {
4040
type forkstat struct {
4141
forks int
4242
vforks int
43-
__tforks int
43+
__tforks int //nolint:revive //FIXME
4444
}
4545

4646
// Misc returns miscellaneous host-wide statistics.

load/load_linux.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ func sysinfoAvgWithContext() (*AvgStat, error) {
3232
return nil, err
3333
}
3434

35-
const si_load_shift = 16
35+
const siLoadShift = 16
3636
return &AvgStat{
37-
Load1: float64(info.Loads[0]) / float64(1<<si_load_shift),
38-
Load5: float64(info.Loads[1]) / float64(1<<si_load_shift),
39-
Load15: float64(info.Loads[2]) / float64(1<<si_load_shift),
37+
Load1: float64(info.Loads[0]) / float64(1<<siLoadShift),
38+
Load5: float64(info.Loads[1]) / float64(1<<siLoadShift),
39+
Load15: float64(info.Loads[2]) / float64(1<<siLoadShift),
4040
}, nil
4141
}
4242

net/net_linux.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ const ( // Conntrack Column numbers
2727
ctINVALID
2828
ctIGNORE
2929
ctDELETE
30-
ctDELETE_LIST
30+
ctDELETE_LIST //nolint:revive //FIXME
3131
ctINSERT
32-
ctINSERT_FAILED
32+
ctINSERT_FAILED //nolint:revive //FIXME
3333
ctDROP
34-
ctEARLY_DROP
35-
ctICMP_ERROR
36-
CT_EXPEctNEW
37-
ctEXPECT_CREATE
38-
CT_EXPEctDELETE
39-
ctSEARCH_RESTART
34+
ctEARLY_DROP //nolint:revive //FIXME
35+
ctICMP_ERROR //nolint:revive //FIXME
36+
CT_EXPEctNEW //nolint:revive //FIXME
37+
ctEXPECT_CREATE //nolint:revive //FIXME
38+
CT_EXPEctDELETE //nolint:revive //FIXME
39+
ctSEARCH_RESTART //nolint:revive //FIXME
4040
)
4141

4242
func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, error) {

net/net_windows.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const (
9696
type mibIfRow2 struct {
9797
InterfaceLuid uint64
9898
InterfaceIndex uint32
99-
InterfaceGuid guid
99+
InterfaceGuid guid //nolint:revive //FIXME
100100
Alias [maxStringSize + 1]uint16
101101
Description [maxStringSize + 1]uint16
102102
PhysicalAddressLength uint32
@@ -113,7 +113,7 @@ type mibIfRow2 struct {
113113
OperStatus uint32
114114
AdminStatus uint32
115115
MediaConnectState uint32
116-
NetworkGuid guid
116+
NetworkGuid guid //nolint:revive //FIXME
117117
ConnectionType uint32
118118
padding1 [pad0for64_4for32]byte
119119
TransmitLinkSpeed uint64
@@ -383,7 +383,7 @@ func getTCPConnections(family uint32) ([]ConnectionStat, error) {
383383
}
384384
}
385385

386-
err := getExtendedTcpTable(p,
386+
err := getExtendedTCPTable(p,
387387
&size,
388388
true,
389389
family,
@@ -464,7 +464,7 @@ func getUDPConnections(family uint32) ([]ConnectionStat, error) {
464464
}
465465
}
466466

467-
err := getExtendedUdpTable(
467+
err := getExtendedUDPTable(
468468
p,
469469
&size,
470470
true,
@@ -528,16 +528,16 @@ var tcpStatuses = map[mibTCPState]string{
528528
12: "DELETE",
529529
}
530530

531-
func getExtendedTcpTable(pTcpTable uintptr, pdwSize *uint32, bOrder bool, ulAf uint32, tableClass tcpTableClass, reserved uint32) (errcode error) {
532-
r1, _, _ := syscall.Syscall6(procGetExtendedTCPTable.Addr(), 6, pTcpTable, uintptr(unsafe.Pointer(pdwSize)), getUintptrFromBool(bOrder), uintptr(ulAf), uintptr(tableClass), uintptr(reserved))
531+
func getExtendedTCPTable(pTCPTable uintptr, pdwSize *uint32, bOrder bool, ulAf uint32, tableClass tcpTableClass, reserved uint32) (errcode error) {
532+
r1, _, _ := syscall.Syscall6(procGetExtendedTCPTable.Addr(), 6, pTCPTable, uintptr(unsafe.Pointer(pdwSize)), getUintptrFromBool(bOrder), uintptr(ulAf), uintptr(tableClass), uintptr(reserved))
533533
if r1 != 0 {
534534
errcode = syscall.Errno(r1)
535535
}
536536
return
537537
}
538538

539-
func getExtendedUdpTable(pUdpTable uintptr, pdwSize *uint32, bOrder bool, ulAf uint32, tableClass udpTableClass, reserved uint32) (errcode error) {
540-
r1, _, _ := syscall.Syscall6(procGetExtendedUDPTable.Addr(), 6, pUdpTable, uintptr(unsafe.Pointer(pdwSize)), getUintptrFromBool(bOrder), uintptr(ulAf), uintptr(tableClass), uintptr(reserved))
539+
func getExtendedUDPTable(pUDPTable uintptr, pdwSize *uint32, bOrder bool, ulAf uint32, tableClass udpTableClass, reserved uint32) (errcode error) {
540+
r1, _, _ := syscall.Syscall6(procGetExtendedUDPTable.Addr(), 6, pUDPTable, uintptr(unsafe.Pointer(pdwSize)), getUintptrFromBool(bOrder), uintptr(ulAf), uintptr(tableClass), uintptr(reserved))
541541
if r1 != 0 {
542542
errcode = syscall.Errno(r1)
543543
}

process/process.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,12 @@ func calculatePercent(t1, t2 *cpu.TimesStat, delta float64, numcpu int) float64
326326
return 0
327327
}
328328
// https://github.com/giampaolo/psutil/blob/c034e6692cf736b5e87d14418a8153bb03f6cf42/psutil/__init__.py#L1064
329-
delta_proc := (t2.User - t1.User) + (t2.System - t1.System)
330-
if delta_proc <= 0 {
329+
deltaProc := (t2.User - t1.User) + (t2.System - t1.System)
330+
if deltaProc <= 0 {
331331
return 0
332332
}
333-
overall_percent := ((delta_proc / delta) * 100) * float64(numcpu)
334-
return overall_percent
333+
overallPercent := ((deltaProc / delta) * 100) * float64(numcpu)
334+
return overallPercent
335335
}
336336

337337
// MemoryPercent returns how many percent of the total RAM this process uses
@@ -361,7 +361,7 @@ func (p *Process) CPUPercent() (float64, error) {
361361
}
362362

363363
func (p *Process) CPUPercentWithContext(ctx context.Context) (float64, error) {
364-
crt_time, err := p.createTimeWithContext(ctx)
364+
createTime, err := p.createTimeWithContext(ctx)
365365
if err != nil {
366366
return 0, err
367367
}
@@ -371,7 +371,7 @@ func (p *Process) CPUPercentWithContext(ctx context.Context) (float64, error) {
371371
return 0, err
372372
}
373373

374-
created := time.Unix(0, crt_time*int64(time.Millisecond))
374+
created := time.Unix(0, createTime*int64(time.Millisecond))
375375
totalTime := time.Since(created).Seconds()
376376
if totalTime <= 0 {
377377
return 0, nil

process/process_darwin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const (
3333
KernProcPathname = 12 // path to executable
3434
)
3535

36-
type _Ctype_struct___0 struct {
36+
type _Ctype_struct___0 struct { //nolint:revive //FIXME
3737
Pad uint64
3838
}
3939

process/process_windows.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ func getProcessMemoryInfo(h windows.Handle, mem *PROCESS_MEMORY_COUNTERS) (err e
958958
return
959959
}
960960

961-
type SYSTEM_TIMES struct {
961+
type SYSTEM_TIMES struct { //nolint:revive //FIXME
962962
CreateTime syscall.Filetime
963963
ExitTime syscall.Filetime
964964
KernelTime syscall.Filetime

process/process_windows_32bit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/shirou/gopsutil/v4/internal/common"
1414
)
1515

16-
type PROCESS_MEMORY_COUNTERS struct {
16+
type PROCESS_MEMORY_COUNTERS struct { //nolint:revive //FIXME
1717
CB uint32
1818
PageFaultCount uint32
1919
PeakWorkingSetSize uint32

process/process_windows_64bit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/shirou/gopsutil/v4/internal/common"
1313
)
1414

15-
type PROCESS_MEMORY_COUNTERS struct {
15+
type PROCESS_MEMORY_COUNTERS struct { //nolint:revive //FIXME
1616
CB uint32
1717
PageFaultCount uint32
1818
PeakWorkingSetSize uint64

sensors/sensors_windows.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/shirou/gopsutil/v4/internal/common"
1313
)
1414

15-
type msAcpi_ThermalZoneTemperature struct {
15+
type msAcpi_ThermalZoneTemperature struct { //nolint:revive //FIXME
1616
Active bool
1717
CriticalTripPoint uint32
1818
CurrentTemperature uint32

0 commit comments

Comments
 (0)