From 77e4b1939707eaeccca5ff58bb98d0e28643ecb6 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 7 Feb 2023 13:54:46 +0100 Subject: [PATCH 1/2] update golangci-lint to version 1.51.1 The new version contains the ginkgolinter, which makes sure the assertions are more helpful. Also replace the deprecated os.SEEK_END with io.SeekEnd. There is also a new `musttag` linter which checks if struct that are un/marshalled all have json tags. This results in many warnings so I disabled the check for now. We can reenable it if we think it is worth it but for now it way to much work to fix all report problems. Signed-off-by: Paul Holzinger --- .golangci.yml | 1 + Makefile | 2 +- libpod/events/logfile.go | 2 +- test/e2e/play_kube_test.go | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 3f04f1af10..3db83c8474 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -47,6 +47,7 @@ linters: - lll - gosec - maligned + - musttag # way to many warnings to fix for now, also some false positives - gomoddirectives - containedctx - contextcheck diff --git a/Makefile b/Makefile index be69c46d6b..cccaebe0d4 100644 --- a/Makefile +++ b/Makefile @@ -929,7 +929,7 @@ install.tools: .install.golangci-lint ## Install needed tools .PHONY: .install.golangci-lint .install.golangci-lint: - VERSION=1.50.1 ./hack/install_golangci.sh + VERSION=1.51.1 ./hack/install_golangci.sh .PHONY: .install.swagger .install.swagger: diff --git a/libpod/events/logfile.go b/libpod/events/logfile.go index b0872bf4cf..0b59d87f19 100644 --- a/libpod/events/logfile.go +++ b/libpod/events/logfile.go @@ -91,7 +91,7 @@ func (e EventLogFile) writeString(s string) error { func (e EventLogFile) getTail(options ReadOptions) (*tail.Tail, error) { reopen := true - seek := tail.SeekInfo{Offset: 0, Whence: os.SEEK_END} + seek := tail.SeekInfo{Offset: 0, Whence: io.SeekEnd} if options.FromStart || !options.Stream { seek.Whence = 0 reopen = false diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index e32522ea87..d9bb63c204 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -1702,10 +1702,10 @@ func testHTTPServer(port string, shouldErr bool, expectedResponse string) { time.Sleep(interval) interval *= 2 } - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) body, err := io.ReadAll(resp.Body) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(string(body)).Should(Equal(expectedResponse)) } From 93c35a703876063e181c18d9239a1bd5c7dcc578 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 7 Feb 2023 14:17:30 +0100 Subject: [PATCH 2/2] golangci-lint: show all errors at once When golangci-lint it will only report 3 errors fromt he same linter by default. This is annoying when a new linter is added and you think only 3 three errors lets fix it real quick only to notice when you rerun it there again new 3 errors and so on. In CI and local I want to see all issues at once so I can fix them and know how much work it is before starting to fix them. With `max-issues-per-linter: 0` and `max-same-issues: 0` it will show us all errors because 0 means unlimted. By default it will only show 50 per linter and 3 from the same issue. Signed-off-by: Paul Holzinger --- .golangci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 3db83c8474..56b551ca31 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -74,3 +74,13 @@ linters-settings: nolintlint: allow-leading-space: false require-specific: true + +issues: + # Maximum issues count per one linter. + # Set to 0 to disable. + # Default: 50 + max-issues-per-linter: 0 + # Maximum count of issues with the same text. + # Set to 0 to disable. + # Default: 3 + max-same-issues: 0