Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@e7fa5ac41e1cf5b7d48e45e42232ce7ada589601 # v9.1.0
with:
version: v2.5
version: v2.6
args: --issues-exit-code=1 --timeout 10m
only-new-issues: false
75 changes: 30 additions & 45 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ linters:
disable:
- ireturn
- nilnil
- forbidigo
- funcorder
- mnd # An analyzer to detect magic numbers.
- inamedparam # reports interfaces with unnamed method parameters
- wrapcheck # Checks that errors returned from external packages are wrapped
- err113 # Go linter to check the errors handling expressions
- mnd
- wrapcheck
- err113
- noinlineerr
- paralleltest # Detects missing usage of t.Parallel() method in your Go test
- testpackage # linter that makes you use a separate _test package
- exhaustruct # Checks if all structure fields are initialized
- gochecknoglobals # Check that no global variables exist.
- goconst # Finds repeated strings that could be replaced by a constant
- tagliatelle # Checks the struct tags.
- varnamelen # checks that the length of a variable's name matches its scope
- paralleltest
- testpackage
- exhaustruct
- goconst
- varnamelen
- nonamedreturns
- nlreturn
- wsl_v5

#
# Redundant
Expand All @@ -30,13 +28,6 @@ linters:
- lll # revive
- wsl # wsl_v5

#
# Formatting only, useful in IDE but should not be forced on CI?
#

- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
- wsl_v5 # add or remove empty lines

settings:

depguard:
Expand All @@ -49,19 +40,17 @@ linters:
desc: yaml.v2 is deprecated for new code in favor of yaml.v3

errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default.
check-type-assertions: false
# List of functions to exclude from checking, where each entry is a single function to exclude.
# See https://github.com/kisielk/errcheck#excluding-functions for details.
check-type-assertions: true

funcorder:
struct-method: false

gocritic:
enable-all: true
disabled-checks:
- paramTypeCombine
- sloppyReassign
- commentedOutCode
- unnamedResult
- whyNoLint

govet:
Expand All @@ -84,6 +73,18 @@ linters:
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
allow-unused: false # report any unused nolint directives

recvcheck:
exclusions:
# methods from time.Duration and pflag.Value don't use the same type of receiver.
- DurationWithDays.Set
- DurationWithDays.String
- DurationWithDays.Type
- DurationWithDays.Hours
- DurationWithDays.Minutes
- DurationWithDays.Seconds
- DurationWithDays.Milliseconds
- DurationWithDays.Nanoseconds

revive:
severity: error
enable-all-rules: true
Expand All @@ -94,18 +95,10 @@ linters:
arguments:
# lower this after refactoring
- 46
- name: comment-spacings
disabled: true
- name: confusing-results
disabled: true
- name: cyclomatic
arguments:
# lower this after refactoring
- 43
- name: defer
disabled: true
- name: enforce-switch-style
disabled: true
- name: flag-parameter
disabled: true
- name: function-length
Expand All @@ -126,10 +119,6 @@ linters:
checks:
- all

wsl:
# Allow blocks to end with comments
allow-trailing-comment: true

exclusions:
presets:
- comments
Expand All @@ -138,27 +127,23 @@ linters:
- std-error-handling
rules:

# `err` is often shadowed, we may continue to do it
- linters:
- govet
text: 'shadow: declaration of "(err|ctx)" shadows declaration'
text: 'shadow: declaration of "err" shadows declaration'

# tolerate long functions in tests
- linters:
- revive
path: (.+)/(.+)_test.go
text: 'function-length: .*'

# tolerate long lines in tests
- linters:
- revive
path: (.+)/(.+)_test.go
text: 'line-length-limit: .*'

- linters:
- recvcheck
path: cstime/duration.go
text: the methods of "DurationWithDays" use pointer receiver and non-pointer receiver.
- forbidigo
path: downloader/examples/

paths:
- yamlpatch/merge.go
Expand Down
27 changes: 0 additions & 27 deletions coalesce/coalesce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,30 +75,3 @@ func TestNotNil(t *testing.T) {
})
}
}

/*
func TestNotEmptyOrNil(t *testing.T) {
tests := []struct{have []*int; want *int}{
{[]*int{}, nil},
{[]*int{nil, nil, nil}, nil},
{[]*int{nil, nil, ptr.Of(3)}, ptr.Of(3)},
{[]*int{nil, ptr.Of(0), ptr.Of(3)}, ptr.Of(3)},
{[]*int{nil, ptr.Of(2), nil}, ptr.Of(2)},
{[]*int{ptr.Of(1), nil, nil}, ptr.Of(1)},
{[]*int{ptr.Of(1), ptr.Of(2), ptr.Of(3)}, ptr.Of(1)},
}

for _, tc := range tests {
tc := tc
t.Run(fmt.Sprintf("%v", tc.have), func(t *testing.T) {
got := NotEmptyOrNil(tc.have...)
if tc.want == nil {
require.Nil(t, got)
return
}
require.NotNil(t, got)
assert.Equal(t, *tc.want, *got)
})
}
}
*/ //nolint: dupword
2 changes: 1 addition & 1 deletion csyaml/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func TestBooleanNoCoercion(t *testing.T) {
// assert.Equal(t, tt.out, buf.String())
// })
// }
//}
// }

func TestExplicitNilOverride(t *testing.T) {
base := []byte("foo: {one: two}\n")
Expand Down
5 changes: 3 additions & 2 deletions trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func Init(dir string) error {
return nil
}

// CatchPanic should be called from all go-routines to ensure proper stack trace reporting.
// CatchPanic should be deferred from all go-routines to ensure proper stack trace reporting.
func CatchPanic(component string) {
if r := recover(); r != nil {
if r := recover(); r != nil { //nolint:revive
keeper.handlePanic(component, r)
}
}
Expand All @@ -57,6 +57,7 @@ type traceKeeper struct {
keepMaxFiles int // delete oldest files if there are more than this
}

//nolint:gochecknoglobals
var keeper = &traceKeeper{
mutex: &sync.Mutex{},
dir: os.TempDir(),
Expand Down
8 changes: 4 additions & 4 deletions version/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import (
"github.com/shirou/gopsutil/v4/host"
)

func DetectOS() (string, string, string) {
func DetectOS() (platform, family, version string) {
info, err := host.Info()
if err != nil {
return System, "???", "???"
}

platform := info.Platform
family := info.PlatformFamily
version := info.PlatformVersion
platform = info.Platform
family = info.PlatformFamily
version = info.PlatformVersion

if platform != "" && System == "docker" {
return platform + " (docker)", family, version
Expand Down
1 change: 1 addition & 0 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"
)

//nolint:gochecknoglobals
var (
Version string // = "v0.0.0"
BuildDate string // = "2023-03-06_09:55:34"
Expand Down