Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.
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
4 changes: 2 additions & 2 deletions .github/workflows/push-pr-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
go-version-file: go.mod

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v8
with:
args: --config .golangci.yml --timeout 2m
version: v1.64.5
version: v2.3.0

- name: Test
run: go test ./...
Expand Down
192 changes: 98 additions & 94 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,105 +1,109 @@
# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration

linters-settings:
govet:
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
gocyclo:
min-complexity: 15
dupl:
threshold: 100
goconst:
min-len: 2
min-occurrences: 2
misspell:
locale: US
lll:
line-length: 140
goimports:
local-prefixes: github.com/golangci/golangci-lint
gocritic:
enabled-tags:
- performance
- style
- experimental
disabled-checks:
- wrapperFunc
gofumpt:
extra-rules: true

version: "2"
linters:
default: none
enable:
- errcheck
- gosimple
- govet
- gofmt
- gocyclo
- ineffassign
- stylecheck
- misspell
- staticcheck
- unused
- prealloc
- typecheck
# additional linters
- bodyclose
- gocritic
- err113
- goimports
- revive
- misspell
- noctx
- stylecheck
- gosec
- contextcheck
- durationcheck
- err113
- errcheck
- errchkjson
- errorlint
- gochecksumtype
- gocritic
- gocyclo
- gosec
- govet
- ineffassign
- misspell
- nilerr
- noctx
- prealloc
- reassign
- revive
- staticcheck
- unused
- whitespace
enable-all: false
disable-all: true

issues:
exclude-files:
- "(.*/)*.*_test.go"
exclude-dirs:
- internal/fixtures
exclude-rules:
- linters:
- gosec
text: "weak cryptographic primitive"

- linters:
- stylecheck
text: "ST1016"
exclude:
# Default excludes from `golangci-lint run --help` with EXC0002 removed
# EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
# EXC0002 golint: Annoying issue about not having a comment. The rare codebase has such comments
# - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
# EXC0003 golint: False positive when tests are defined in package 'test'
- func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
# EXC0004 govet: Common false positives
- (possible misuse of unsafe.Pointer|should have signature)
# EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
- ineffective break statement. Did you mean to break out of the outer loop
# EXC0006 gosec: Too many false-positives on 'unsafe' usage
- Use of unsafe calls should be audited
# EXC0007 gosec: Too many false-positives for parametrized shell calls
- Subprocess launch(ed with variable|ing should be audited)
# EXC0008 gosec: Duplicated errcheck checks
- (G104|G307)
# EXC0009 gosec: Too many issues in popular repos
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
# EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
- Potential file inclusion via variable
settings:
dupl:
threshold: 100
goconst:
min-len: 2
min-occurrences: 2
gocritic:
disabled-checks:
- wrapperFunc
enabled-tags:
- performance
- style
- experimental
gocyclo:
min-complexity: 15
govet:
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
lll:
line-length: 140
misspell:
locale: US
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- gosec
text: weak cryptographic primitive
- linters:
- staticcheck
text: ST1016
- path: (.+)\.go$
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
- path: (.+)\.go$
text: func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
- path: (.+)\.go$
text: (possible misuse of unsafe.Pointer|should have signature)
- path: (.+)\.go$
text: ineffective break statement. Did you mean to break out of the outer loop
- path: (.+)\.go$
text: Use of unsafe calls should be audited
- path: (.+)\.go$
text: Subprocess launch(ed with variable|ing should be audited)
- path: (.+)\.go$
text: (G104|G307)
- path: (.+)\.go$
text: (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
- path: (.+)\.go$
text: Potential file inclusion via variable
paths:
- (.*/)*.*_test.go
- internal/fixtures
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
settings:
gofumpt:
extra-rules: true
goimports:
local-prefixes:
- github.com/golangci/golangci-lint
exclusions:
generated: lax
paths:
- (.*/)*.*_test.go
- internal/fixtures
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func enableProfilingEndpoint() {
go func() {
server := &http.Server{
Addr: ProfilingEndpoint,
ReadHeaderTimeout: 2 * time.Second, // nolint:gomnd // time duration value is clear as is.
ReadHeaderTimeout: 2 * time.Second,
}

if err := server.ListenAndServe(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/inband/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (i *ActionHandler) identifyComponent(ctx context.Context, component string,

found := components.ByNameModel(component, models)
if found == nil {
// nolint:goerr113 // its clearer to define this error here
// nolint:err113 // its clearer to define this error here
errComponentMatch := fmt.Errorf(
"unable to identify component '%s' from inventory for given models: %s",
component,
Expand Down
2 changes: 1 addition & 1 deletion internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func ListenAndServe() {

server := &http.Server{
Addr: MetricsEndpoint,
ReadHeaderTimeout: 2 * time.Second, // nolint:gomnd // time duration value is clear as is.
ReadHeaderTimeout: 2 * time.Second,
}

if err := server.ListenAndServe(); err != nil {
Expand Down
1 change: 0 additions & 1 deletion internal/model/firmware.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var (
// FirmwareInstallOrder defines the order in which firmware is installed.
//
// TODO(joel): fix up bmc-toolbox/common slugs to be of lower case instead of upper
// nolint:gomnd // component install order number is clear as is.
FirmwareInstallOrder = map[string]int{
strings.ToLower(common.SlugBMC): 0,
strings.ToLower(common.SlugBIOS): 1,
Expand Down
2 changes: 0 additions & 2 deletions internal/outofband/bmc_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func newHTTPClient() *http.Client {
panic(err)
}

// nolint:gomnd // time duration declarations are clear as is.
return &http.Client{
Timeout: time.Second * 600,
Jar: jar,
Expand Down Expand Up @@ -256,7 +255,6 @@ func (b *bmc) loginWithRetries(ctx context.Context, maxAttempts int, provider st

// method returns nil if a retry is required and an error when a retry cannot proceed
func (b *bmc) retry(ctx context.Context, maxAttempts, attempts int, cause error, provider string) (int, error) {
// nolint:gomnd // time duration definitions are clear as is.
delay := &backoff.Backoff{
Min: 5 * time.Second,
Max: 30 * time.Second,
Expand Down
2 changes: 1 addition & 1 deletion internal/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func (r *Runner) runActionSteps(ctx context.Context, task *model.Task, action *m

if step.Handler == nil {
publish(model.StateFailed, action, step, logger)
// nolint:goerr113 // for this case, its preferable to have the error be defined within its context of use
// nolint:err113 // for this case, its preferable to have the error be defined within its context of use
return false, fmt.Errorf(
"error while running step=%s to install firmware on component=%s, handler was nil",
step.Name,
Expand Down
1 change: 1 addition & 0 deletions types/types.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// nolint:revive // legacy naming
package types

import (
Expand Down
Loading