Skip to content

CI: enable more linters#319

Merged
guelfey merged 5 commits intogodbus:masterfrom
kolyshkin:more-linters
Mar 17, 2022
Merged

CI: enable more linters#319
guelfey merged 5 commits intogodbus:masterfrom
kolyshkin:more-linters

Conversation

@kolyshkin
Copy link
Contributor

This PR enables a few more linters, and fixes warnings found by those. See individual commits for details.

The next linter to add would be errorlint, but the amount of changes requires is a tad too big to include it into this PR.

gofumpt is basically a stricter/better gofmt. It is supported by gopls
(and thus all IDEs), and in general results in a better formatted code.

This commit
 - formats all code with gofumpt (gofumpt -w .)
 - adds gofumpt linter to golangci-lint to ensure future commits

Signed-off-by: Kir Kolyshkin <[email protected]>
No issues found.

Signed-off-by: Kir Kolyshkin <[email protected]>
1. Fix the following warning:

sequential_handler_test.go:224:18: `readSignals` - `t` is unused (unparam)
func readSignals(t *testing.T, channel <-chan *Signal, count int) error {
                 ^

Instead of removing t, let's use it -- since all the callers of
readSignals call t.Error(), we can inline it.

2. Fix this warning:

sequential_handler_test.go:212:56: `readSignals` - `count` always receives `1000` (unparam)
func readSignals(t *testing.T, channel <-chan *Signal, count int) {
                                                       ^
by removing the count argument.

Signed-off-by: Kir Kolyshkin <[email protected]>
Fix the following warning:

conn_test.go:341:51: `waitSignal` - `timeout` always receives `time.Second` (`1000000000`) (unparam)
func waitSignal(sigc <-chan *Signal, name string, timeout time.Duration) *Signal {
                                                  ^

by removing the timeout argument.

Signed-off-by: Kir Kolyshkin <[email protected]>
And fix the last warning from it:

match.go:31:20: `withMatchType` - `typ` always receives `"signal"` (unparam)
func withMatchType(typ string) MatchOption {
                   ^

Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin
Copy link
Contributor Author

Note that these linters are somewhat more opinionated than the default one, so if you don't like any of the changes I've made please let me know and I'll revert (and add directives to ignore particular linters for particular places in the code).

The above won't work for gofumpt, of course, so if you don't like the changes it imposes, we can just drop it.

Copy link
Member

@guelfey guelfey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Only unparam I'd view as possibly "too opinionated", but just for these concrete things in the testing code I'm fine with it.

@guelfey guelfey merged commit fc37d31 into godbus:master Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants