Skip to content

Commit da292b2

Browse files
authored
task: make golangci-lint on gh action match local (#9)
1 parent 4f67755 commit da292b2

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

.github/workflows/pr.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ jobs:
1919
- name: lint
2020
uses: golangci/[email protected]
2121
with:
22-
version: v1.41.1
22+
version: v1.62.2
2323

2424
tests-on-unix:
2525
needs: golangci-lint # run after golangci-lint action to not produce duplicated errors
2626
runs-on: ubuntu-latest
2727
strategy:
2828
matrix:
2929
golang:
30-
- 1.23
30+
- 'stable'
31+
- 'oldstable'
3132

3233
steps:
3334
- name: Checkout repository

.golangci.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ linters-settings:
1010
- octalLiteral
1111
gocyclo:
1212
min-complexity: 15
13-
govet:
14-
check-shadowing: true
15-
maligned:
16-
suggest-new: true
1713
revive:
1814
# see https://github.com/mgechev/revive#available-rules for details.
1915
ignore-generated-header: true
@@ -26,7 +22,9 @@ linters-settings:
2622
- name: error-return
2723
- name: error-strings
2824
- name: error-naming
25+
- name: errorf
2926
- name: exported
27+
- name: indent-error-flow
3028
- name: if-return
3129
- name: increment-decrement
3230
- name: var-naming
@@ -40,7 +38,9 @@ linters-settings:
4038
- name: errorf
4139
- name: empty-block
4240
- name: superfluous-else
41+
- name: struct-tag
4342
- name: unused-parameter
43+
- name: unused-receiver
4444
- name: unreachable-code
4545
- name: redefines-builtin-id
4646
linters:
@@ -49,46 +49,39 @@ linters:
4949
disable-all: true
5050
enable:
5151
- bodyclose # checks whether HTTP response body is closed successfully [fast: false, auto-fix: false]
52-
- deadcode # Finds unused code [fast: false, auto-fix: false]
53-
- depguard # Go linter that checks if package imports are in a list of acceptable packages [fast: false, auto-fix: false]
5452
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) [fast: true, auto-fix: false]
5553
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: false, auto-fix: false]
5654
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. [fast: false, auto-fix: false]
5755
- exhaustive # check exhaustiveness of enum switch statements [fast: false, auto-fix: false]
58-
- exportloopref # checks for pointers to enclosing loop variables [fast: false, auto-fix: false]
5956
- gochecknoinits # Checks that no init functions are present in Go code [fast: true, auto-fix: false]
60-
- goconst # Finds repeated strings that could be replaced by a constant [fast: true, auto-fix: false]
6157
- gocritic # Provides many diagnostics that check for bugs, performance and style issues. [fast: false, auto-fix: false]
6258
- gocyclo # Computes and checks the cyclomatic complexity of functions [fast: true, auto-fix: false]
6359
- godot # Check if comments end in a period [fast: true, auto-fix: true]
6460
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true]
6561
- goimports # Goimports does everything that gofmt does. Additionally it checks unused imports [fast: true, auto-fix: true]
66-
- gomnd # An analyzer to detect magic numbers. [fast: true, auto-fix: false]
6762
- goprintffuncname # Checks that printf-like functions are named with `f` at the end [fast: true, auto-fix: false]
6863
- gosec # Inspects source code for security problems [fast: false, auto-fix: false]
6964
- gosimple # Linter for Go source code that specializes in simplifying a code [fast: false, auto-fix: false]
7065
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: false, auto-fix: false]
71-
- ifshort # Checks that your code uses short syntax for if-statements whenever possible [fast: true, auto-fix: false]
7266
- ineffassign # Detects when assignments to existing variables are not used [fast: true, auto-fix: false]
7367
- misspell # Finds commonly misspelled English words in comments [fast: true, auto-fix: true]
7468
- nakedret # Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false]
7569
- nolintlint # Reports ill-formed or insufficient nolint directives [fast: true, auto-fix: false]
7670
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [fast: false, auto-fix: false]
7771
- rowserrcheck # checks whether Err of rows is checked successfully [fast: false, auto-fix: false]
78-
- staticcheck #megacheck): Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false, auto-fix: false]
79-
- structcheck # Finds unused struct fields [fast: false, auto-fix: false]
72+
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false, auto-fix: false]
8073
- stylecheck # Stylecheck is a replacement for golint [fast: false, auto-fix: false]
8174
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers [fast: false, auto-fix: false]
8275
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code [fast: false, auto-fix: false]
8376
- unconvert # Remove unnecessary type conversions [fast: false, auto-fix: false]
8477
- unparam # Reports unused function parameters [fast: false, auto-fix: false]
8578
- unused # Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
86-
- varcheck # Finds unused global variables and constants [fast: false, auto-fix: false]
8779
- whitespace # Tool for detection of leading and trailing whitespace [fast: true, auto-fix: true]
8880

89-
# don't enable:
81+
# don't enable:
9082
# - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers [fast: true, auto-fix: false]
9183
# - cyclop # checks function and package cyclomatic complexity [fast: false, auto-fix: false]
84+
# - deadcode # Finds unused code [fast: false, auto-fix: false]
9285
# - dupl # Tool for code clone detection [fast: true, auto-fix: false]
9386
# - durationcheck # check for two durations multiplied together [fast: false, auto-fix: false]
9487
# - exhaustivestruct # Checks if all struct's fields are initialized [fast: false, auto-fix: false]
@@ -98,7 +91,9 @@ linters:
9891
# - gci # Gci control golang package import order and make it always deterministic. [fast: true, auto-fix: true]
9992
# - gochecknoglobals # check that no global variables exist [fast: true, auto-fix: false]
10093
# - gocognit # Computes and checks the cognitive complexity of functions [fast: true, auto-fix: false]
94+
# - goconst # Finds repeated strings that could be replaced by a constant [fast: true, auto-fix: false]
10195
# - godox # Tool for detection of FIXME, TODO and other comment keywords [fast: true, auto-fix: false]
96+
# - gomnd # An analyzer to detect magic numbers. [fast: true, auto-fix: false]
10297
# - goerr113 # Golang linter to check the errors handling expressions [fast: false, auto-fix: false]
10398
# - gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true]
10499
# - goheader # Checks is file header matches to pattern [fast: true, auto-fix: false]
@@ -119,9 +114,11 @@ linters:
119114
# - promlinter # Check Prometheus metrics naming via promlint [fast: true, auto-fix: false]
120115
# - scopelint # Scopelint checks for unpinned variables in go programs [fast: true, auto-fix: false]
121116
# - sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. [fast: false, auto-fix: false]
122-
# - tagliatelle # Checks the struct tags. [fast: true, auto-fix: false]
117+
# - structcheck # Finds unused struct fields [fast: false, auto-fix: false]
123118
# - testpackage # linter that makes you use a separate _test package [fast: true, auto-fix: false]
124119
# - tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes [fast: false, auto-fix: false]
125120
# - wastedassign # wastedassign finds wasted assignment statements. [fast: false, auto-fix: false]
126121
# - wrapcheck # Checks that errors returned from external packages are wrapped [fast: false, auto-fix: false]
127122
# - wsl # Whitespace Linter - Forces you to use empty lines! [fast: true, auto-fix: false]
123+
# - varcheck # Finds unused global variables and constants [fast: false, auto-fix: false]
124+
# - ifshort # Checks that your code uses short syntax for if-statements whenever possible [fast: true, auto-fix: false]

appservices/appservices_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func TestDo_noContent(t *testing.T) {
258258
client, mux, teardown := setup()
259259
defer teardown()
260260

261-
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
261+
mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
262262
w.WriteHeader(http.StatusNoContent)
263263
})
264264

@@ -275,7 +275,7 @@ func TestClient_Do_httpError(t *testing.T) {
275275
client, mux, teardown := setup()
276276
defer teardown()
277277

278-
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
278+
mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
279279
http.Error(w, "Bad Request", 400)
280280
})
281281

appservices/event_triggers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ func TestEventTriggers_Delete(t *testing.T) {
634634

635635
path := fmt.Sprintf("/groups/%s/apps/%s/triggers/%s", groupID, appID, triggerID)
636636

637-
mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
637+
mux.HandleFunc(path, func(_ http.ResponseWriter, r *http.Request) {
638638
testMethod(t, r, http.MethodDelete)
639639
})
640640

0 commit comments

Comments
 (0)