mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-25 01:23:22 +01:00
bb40325977
This PR showcases the implementation of additional linter rules. I've updated the golangci-lint GitHub Actions to the latest available version. This update makes sure that the tool works the same way locally - assuming being updated regularly - and with the GitHub Actions. I've also taken care of keeping all the GitHub Actions up to date, which helps our code stay current. But there's one part, goreleaser that's a bit tricky to test on our computers. So, it's important to take a close look at that. To make it easier to understand what I've done, I've made separate changes for each thing that the new linters found. This should help the people reviewing the changes see what's going on more clearly. Some of the changes might not be obvious at first glance. Things to consider for the future CI runs on Ubuntu so the static analysis only happens for Linux. Consider running it for the rest: Darwin, Windows
54 lines
2.0 KiB
YAML
54 lines
2.0 KiB
YAML
run:
|
|
# Timeout for analysis, e.g. 30s, 5m.
|
|
# Default: 1m
|
|
timeout: 6m
|
|
|
|
# This file contains only configs which differ from defaults.
|
|
# All possible options can be found here https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml
|
|
linters-settings:
|
|
errcheck:
|
|
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
|
|
# Such cases aren't reported by default.
|
|
# Default: false
|
|
check-type-assertions: false
|
|
|
|
govet:
|
|
# Enable all analyzers.
|
|
# Default: false
|
|
enable-all: false
|
|
enable:
|
|
- nilness
|
|
|
|
linters:
|
|
disable-all: true
|
|
enable:
|
|
## enabled by default
|
|
- errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases
|
|
- gosimple # specializes in simplifying a code
|
|
- govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
|
|
- ineffassign # detects when assignments to existing variables are not used
|
|
- staticcheck # is a go vet on steroids, applying a ton of static analysis checks
|
|
- typecheck # like the front-end of a Go compiler, parses and type-checks Go code
|
|
- unused # checks for unused constants, variables, functions and types
|
|
## disable by default but the have interesting results so lets add them
|
|
- bodyclose # checks whether HTTP response body is closed successfully
|
|
- nilerr # finds the code that returns nil even if it checks that the error is not nil
|
|
- nilnil # checks that there is no simultaneous return of nil error and an invalid value
|
|
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
|
|
- wastedassign # wastedassign finds wasted assignment statements
|
|
issues:
|
|
# Maximum count of issues with the same text.
|
|
# Set to 0 to disable.
|
|
# Default: 3
|
|
max-same-issues: 5
|
|
|
|
exclude-rules:
|
|
- path: sharedsock/filter.go
|
|
linters:
|
|
- unused
|
|
- path: client/firewall/iptables/rule.go
|
|
linters:
|
|
- unused
|
|
- path: mock.go
|
|
linters:
|
|
- nilnil |