-
Notifications
You must be signed in to change notification settings - Fork 2.3k
ci: enable linting test files #1477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This suppresses the following staticcheck warnings in tests:
hooks/test/test_test.go:76:2: SA4006: this value of assert is never used (staticcheck)
assert := assert.New(t)
^
hooks/test/test_test.go:78:2: SA4006: this value of hook is never used (staticcheck)
logger, hook := NewNullLogger()
^
...and fixes the following staticcheck and unparam warnings in tests:
json_formatter_test.go:232:5: QF1001: could apply De Morgan's law (staticcheck)
if !(strings.Contains(s, "message") && strings.Contains(s, "oh hai")) {
^
json_formatter_test.go:369:5: QF1001: could apply De Morgan's law (staticcheck)
if !(strings.Contains(s, "u0026") && strings.Contains(s, "u003e") && strings.Contains(s, "u003c")) {
^
hooks/test/test_test.go:96:11: TestNewLocal$1 - i is unused (unparam)
go func(i int) {
^
Signed-off-by: Kir Kolyshkin <[email protected]>
Signed-off-by: Kir Kolyshkin <[email protected]>
Mostly generated with golangci-lint run --fix ./... Signed-off-by: Kir Kolyshkin <[email protected]>
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall looks good; left two suggestions; let me know what you think
| if !(strings.Contains(s, "u0026") && strings.Contains(s, "u003e") && strings.Contains(s, "u003c")) { | ||
| if !strings.Contains(s, "u0026") || !strings.Contains(s, "u003e") || !strings.Contains(s, "u003c") { | ||
| t.Error("Message should be HTML escaped", s) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we should have a predictable output here, so we can just match the escaped sequence for & < >;
| if !(strings.Contains(s, "u0026") && strings.Contains(s, "u003e") && strings.Contains(s, "u003c")) { | |
| if !strings.Contains(s, "u0026") || !strings.Contains(s, "u003e") || !strings.Contains(s, "u003c") { | |
| t.Error("Message should be HTML escaped", s) | |
| } | |
| if !strings.Contains(s, `\u0026 \u003c \u003e`) { | |
| t.Error("Message should be HTML escaped", s) | |
| } |
| if !(strings.Contains(s, "message") && strings.Contains(s, "oh hai")) { | ||
| if !strings.Contains(s, "message") || !strings.Contains(s, "oh hai") { | ||
| t.Fatal("Expected JSON to format message key") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for this one; I expect the JSON format to be stable enough;
| if !(strings.Contains(s, "message") && strings.Contains(s, "oh hai")) { | |
| if !strings.Contains(s, "message") || !strings.Contains(s, "oh hai") { | |
| t.Fatal("Expected JSON to format message key") | |
| if !strings.Contains(s, `"message":"oh hai"`) { | |
| t.Fatal("Expected JSON to format message key", s) | |
| } |
FWIW; output here looks to be {"level":"panic","message":"oh hai","time":"0001-01-01T00:00:00Z"} so possibly we could even do a straight compare for the whole message, but either way is probably fine.
This is a followup to #1476, inspired by #1476 (comment).
See individual commits for details.