Update linter config and apply suggestions

- remove copyright years (they are in git)
- remove outdated linter bug workarounds
- update .golangci.yml to match current schema (as of golangci-lint 1.59.0)
main
Jan Dittberner 3 weeks ago
parent 3d16034c44
commit 11582d3590

@ -1,7 +1,9 @@
--- ---
run: run:
go: "1.17" go: "1.19"
skip-files:
issues:
exclude-files:
- boardvoting/assets.go - boardvoting/assets.go
output: output:
@ -13,7 +15,7 @@ linters-settings:
const: const:
ORGANIZATION: CAcert Inc. ORGANIZATION: CAcert Inc.
template: |- template: |-
Copyright {{ YEAR-RANGE }} {{ ORGANIZATION }} Copyright {{ ORGANIZATION }}
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
@ -27,8 +29,8 @@ linters-settings:
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
gomnd: mnd:
ignore-functions: ignored-functions:
- 'strconv.*' - 'strconv.*'
ignored-numbers: ignored-numbers:
- '-1,0,1,2,8' - '-1,0,1,2,8'
@ -57,7 +59,7 @@ linters:
- gofmt - gofmt
- goheader - goheader
- goimports - goimports
- gomnd - mnd
- gosec - gosec
- lll - lll
- makezero - makezero

@ -1,5 +1,5 @@
/* /*
Copyright 2017-2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2017-2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2017-2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2017-2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2017-2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
@ -62,7 +62,7 @@ func Test_secureHeaders(t *testing.T) {
SecureHeaders(next).ServeHTTP(rr, r) SecureHeaders(next).ServeHTTP(rr, r)
rs := rr.Result() //nolint:bodyclose // linters bug rs := rr.Result()
defer func() { _ = rs.Body.Close() }() defer func() { _ = rs.Body.Close() }()
@ -119,7 +119,7 @@ func TestApplication_tryAuthenticate(t *testing.T) {
mw.TryAuthenticate(next).ServeHTTP(rr, r) mw.TryAuthenticate(next).ServeHTTP(rr, r)
rs := rr.Result() //nolint:bodyclose // linters bug rs := rr.Result()
defer func() { _ = rs.Body.Close() }() defer func() { _ = rs.Body.Close() }()
@ -137,7 +137,7 @@ func TestApplication_tryAuthenticate(t *testing.T) {
mw.TryAuthenticate(next).ServeHTTP(rr, r) mw.TryAuthenticate(next).ServeHTTP(rr, r)
rs := rr.Result() //nolint:bodyclose // linters bug rs := rr.Result()
defer func() { _ = rs.Body.Close() }() defer func() { _ = rs.Body.Close() }()
@ -158,11 +158,12 @@ func TestApplication_tryAuthenticate(t *testing.T) {
mw.TryAuthenticate(next).ServeHTTP(rr, r) mw.TryAuthenticate(next).ServeHTTP(rr, r)
rs := rr.Result() //nolint:bodyclose // linters bug rs := rr.Result()
defer func() { _ = rs.Body.Close() }() defer func() { _ = rs.Body.Close() }()
assert.Equal(t, http.StatusOK, rs.StatusCode) assert.Equal(t, http.StatusOK, rs.StatusCode)
user := nextCtx.Value(ctxUser) user := nextCtx.Value(ctxUser)
assert.NotNil(t, user) assert.NotNil(t, user)

@ -1,5 +1,5 @@
/* /*
Copyright 2017-2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2017-2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2017-2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2017-2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2017-2023 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2017-2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2017-2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2017-2023 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
@ -607,12 +607,12 @@ func (m *MotionModel) List(ctx context.Context, options *MotionListOptions) ([]*
} }
func (m *MotionModel) FillVoteSums(ctx context.Context, decisions []*Motion) error { func (m *MotionModel) FillVoteSums(ctx context.Context, decisions []*Motion) error {
decisionIds := make([]int64, len(decisions)) decisionIDs := make([]int64, len(decisions))
decisionMap := make(map[int64]*Motion, len(decisions)) decisionMap := make(map[int64]*Motion, len(decisions))
for idx, decision := range decisions { for idx, decision := range decisions {
decision.Sums = &VoteSums{} decision.Sums = &VoteSums{}
decisionIds[idx] = decision.ID decisionIDs[idx] = decision.ID
decisionMap[decision.ID] = decision decisionMap[decision.ID] = decision
} }
@ -621,7 +621,7 @@ func (m *MotionModel) FillVoteSums(ctx context.Context, decisions []*Motion) err
FROM votes v FROM votes v
WHERE v.decision IN (?) WHERE v.decision IN (?)
GROUP BY v.decision, v.vote`, GROUP BY v.decision, v.vote`,
decisionIds, decisionIDs,
) )
if err != nil { if err != nil {
return fmt.Errorf("could not create IN query: %w", err) return fmt.Errorf("could not create IN query: %w", err)

@ -1,5 +1,5 @@
/* /*
Copyright 2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2017-2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2017-2024 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

@ -1,5 +1,5 @@
/* /*
Copyright 2022 CAcert Inc. Copyright CAcert Inc.
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

Loading…
Cancel
Save