From a5b54f503bf96829d2979af54ed974159a20387f Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Mon, 20 Nov 2023 14:04:54 +0200 Subject: [PATCH] .golangci: update disabled linters --- .golangci.yml | 25 +++++++++++++++++++++++++ gbn/gbn_client.go | 11 ++++++++--- gbn/gbn_conn.go | 2 +- mailbox/server.go | 2 +- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 46579a63..4a5de605 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -12,26 +12,40 @@ run: - watchtowerrpc linters-settings: + govet: # Don't report about shadowed variables check-shadowing: false + gofmt: # simplify code: gofmt with `-s` option, true by default simplify: true + funlen: # Checks the number of lines in a function. # If lower than 0, disable the check. lines: 200 # Checks the number of statements in a function. statements: 80 + gosec: excludes: - G402 # Look for bad TLS connection settings. - G306 # Poor file permissions used when writing to a new file. + whitespace: + multi-func: true + multi-if: true + linters: enable-all: true disable: + # Allow dynamic errors. + - goerr113 + + # We want to allow short variable names. + - varnamelen + # Init functions are used by loggers throughout the codebase. - gochecknoinits @@ -46,6 +60,17 @@ linters: # instances are created. - exhaustruct + # Disable gofumpt as it has weird behavior regarding formatting multiple + # lines for a function which is in conflict with our contribution + # guidelines. See https://github.com/mvdan/gofumpt/issues/235. + - gofumpt + + # Disable whitespace linter as it has conflict rules against our + # contribution guidelines. See https://github.com/bombsimon/wsl/issues/109. + # + # TODO: bring it back when the above issue is fixed. + - wsl + # Deprecated linters. See https://golangci-lint.run/usage/linters/. - interfacer - golint diff --git a/gbn/gbn_client.go b/gbn/gbn_client.go index 7061194b..cdfa86f6 100644 --- a/gbn/gbn_client.go +++ b/gbn/gbn_client.go @@ -96,7 +96,10 @@ func (g *GoBackNConn) clientHandshake() error { } }() - var resp Message + var ( + resp Message + respSYN *PacketSYN + ) handshake: for { // start Handshake @@ -148,8 +151,10 @@ handshake: g.log.Debugf("Got %T", resp) - switch resp.(type) { + switch r := resp.(type) { case *PacketSYN: + respSYN = r + break handshake default: } @@ -162,7 +167,7 @@ handshake: g.log.Debugf("Got SYN") - if resp.(*PacketSYN).N != g.cfg.n { + if respSYN.N != g.cfg.n { return io.EOF } diff --git a/gbn/gbn_conn.go b/gbn/gbn_conn.go index f76c1ec4..1f8d974a 100644 --- a/gbn/gbn_conn.go +++ b/gbn/gbn_conn.go @@ -67,7 +67,7 @@ type GoBackNConn struct { // remoteClosed is closed if the remote party initiated the FIN sequence. remoteClosed chan struct{} - ctx context.Context + ctx context.Context //nolint:containedctx cancel func() // quit is used to stop the normal operations of the connection. diff --git a/mailbox/server.go b/mailbox/server.go index a0a820b0..f810fbc8 100644 --- a/mailbox/server.go +++ b/mailbox/server.go @@ -26,7 +26,7 @@ type Server struct { sid [64]byte - ctx context.Context + ctx context.Context //nolint:containedctx quit chan struct{} cancel func()