Skip to content

Commit 4fb3d38

Browse files
rockdabootkruskall
andauthored
Update linter to 1.64.8 (#222)
## What does this PR do? Update golangci-lint to 1.64.8, the latest version before v2, which requires fundamental changes to the config file (for a follow-up PR). <!-- Mandatory Explain here the changes you made on the PR. Please explain the WHAT: patterns used, algorithms implemented, design architecture, message processing, etc. --> ## Why is it important? PR #220 requires a newer version of the linter in order to allow Go 1.23 iterators. ## Checklist - [x] My code follows the style guidelines of this project - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added tests that prove my fix is effective or that my feature works --------- Co-authored-by: kruskall <[email protected]>
1 parent 6017d32 commit 4fb3d38

File tree

5 files changed

+15
-29
lines changed

5 files changed

+15
-29
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ jobs:
3434
- name: golangci-lint
3535
env:
3636
GOOS: ${{ matrix.GOOS }}
37-
uses: golangci/golangci-lint-action@v3
37+
uses: golangci/golangci-lint-action@v6
3838
with:
3939
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
40-
version: v1.55.2
40+
version: v1.64.8
4141

4242
# Give the job more time to execute.
4343
# Regarding `--whole-files`, the linter is supposed to support linting of changed a patch only but,
@@ -69,10 +69,10 @@ jobs:
6969
- name: golangci-lint
7070
env:
7171
CGO_ENABLED: 1
72-
uses: golangci/golangci-lint-action@v3
72+
uses: golangci/golangci-lint-action@v6
7373
with:
7474
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
75-
version: v1.55.2
75+
version: v1.64.8
7676

7777
# Give the job more time to execute.
7878
# Regarding `--whole-files`, the linter is supposed to support linting of changed a patch only but,

.golangci.yml

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ issues:
1212
# Set to 0 to disable.
1313
# Default: 50
1414
max-issues-per-linter: 0
15+
exclude-rules:
16+
# Exclude some linters from running on tests files.
17+
- path: _test\.go
18+
linters:
19+
- errcheck
1520

1621
output:
1722
sort-results: true
@@ -36,7 +41,7 @@ linters:
3641
- asciicheck # simple linter to check that your code does not contain non-ASCII identifiers
3742
- bodyclose # checks whether HTTP response body is closed successfully
3843
- durationcheck # check for two durations multiplied together
39-
- exportloopref # checks for pointers to enclosing loop variables
44+
- copyloopvar # checks for pointers to enclosing loop variables
4045
- goimports # Goimports does everything that gofmt does. Additionally it checks unused imports
4146
- gosec # inspects source code for security problems
4247
- importas # enforces consistent import aliases
@@ -71,8 +76,6 @@ linters-settings:
7176
# Forbid the following identifiers
7277
forbid:
7378
- fmt.Print.* # too much log noise
74-
# Exclude godoc examples from forbidigo checks. Default is true.
75-
exclude_godoc_examples: true
7679

7780
goimports:
7881
local-prefixes: github.com/elastic
@@ -91,20 +94,13 @@ linters-settings:
9194
- github.com/elastic/beats/v7:
9295
reason: "There must be no Beats dependency"
9396

94-
gosimple:
95-
# Select the Go version to target. The default is '1.13'.
96-
go: "1.23.9"
97-
98-
9997
nakedret:
10098
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
10199
max-func-lines: 0
102100

103101
nolintlint:
104102
# Enable to ensure that nolint directives are all used. Default is true.
105103
allow-unused: true
106-
# Disable to ensure that nolint directives don't have a leading space. Default is true.
107-
allow-leading-space: false
108104
# Exclude following linters from requiring an explanation. Default is [].
109105
allow-no-explanation: []
110106
# Enable to require an explanation of nonzero length after each nolint directive. Default is false.
@@ -113,21 +109,11 @@ linters-settings:
113109
require-specific: true
114110

115111
staticcheck:
116-
# Select the Go version to target. The default is '1.13'.
117-
go: "1.23.9"
118112
checks: ["all"]
119113

120-
stylecheck:
121-
# Select the Go version to target. The default is '1.13'.
122-
go: "1.23.9"
123-
checks: ["all"]
124-
125-
unused:
126-
# Select the Go version to target. The default is '1.13'.
127-
go: "1.23.9"
128-
129114
gosec:
130115
excludes:
116+
- G115 # Integer overflow conversion
131117
- G306 # Expect WriteFile permissions to be 0600 or less
132118
- G404 # Use of weak random number generator
133119
- G401 # Detect the usage of DES, RC4, MD5 or SHA1: Used in non-crypto contexts.

metric/system/cgroup/cgcommon/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func ParseUint(value []byte) (uint64, error) {
5757
intValue, intErr := strconv.ParseInt(strValue, 10, 64)
5858
if intErr == nil && intValue < 0 {
5959
return 0, nil
60-
} else if intErr != nil && intErr.(*strconv.NumError).Err == strconv.ErrRange && intValue < 0 { //nolint: errorlint // keep old behaviour
60+
} else if intErr != nil && intErr.(*strconv.NumError).Err == strconv.ErrRange && intValue < 0 { //nolint: errorlint,errcheck // keep old behaviour
6161
return 0, nil
6262
}
6363

metric/system/cgroup/cgv2/io_helper_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func fetchDeviceName(major uint64, minor uint64) (bool, string, error) {
5151
if !ok {
5252
return nil
5353
}
54-
devID = uint64(infoT.Rdev)
54+
devID = infoT.Rdev
5555

5656
// do some bitmapping to extract the major and minor device values
5757
// The odd duplicated logic here is to deal with 32 and 64 bit values.

metric/system/process/process.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func (procStats *Stats) Get() ([]mapstr.M, []mapstr.M, error) {
126126
rootEvents := make([]mapstr.M, 0, len(plist))
127127

128128
for _, process := range plist {
129-
process := process
129+
130130
// Add the RSS pct memory first
131131
process.Memory.Rss.Pct = GetProcMemPercentage(process, totalPhyMem)
132132
// Create the root event
@@ -402,7 +402,7 @@ func (procStats *Stats) includeTopProcesses(processes []ProcState) []ProcState {
402402
return processes[i].Memory.Rss.Bytes.ValueOr(0) > processes[j].Memory.Rss.Bytes.ValueOr(0)
403403
})
404404
for _, proc := range processes[:numProcs] {
405-
proc := proc
405+
406406
if !isProcessInSlice(result, &proc) {
407407
result = append(result, proc)
408408
}

0 commit comments

Comments
 (0)