From 9a6814deff52b989e348c5a085156abe5b5c5769 Mon Sep 17 00:00:00 2001 From: Maycon Santos Date: Thu, 29 Feb 2024 16:05:31 +0100 Subject: [PATCH] Enable review linter with exported docs check (#1647) Exported function and methods should have comments. This warns on undocumented exported functions and methods. --- .golangci.yaml | 9 +++++++++ client/internal/auth/oauth.go | 2 +- iface/netstack/tun.go | 2 +- management/server/activity/event.go | 2 +- management/server/peer/peer.go | 4 ++-- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 757a60a39..3c5f4d5b8 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -63,6 +63,14 @@ linters-settings: enable: - nilness + revive: + rules: + - name: exported + severity: warning + disabled: false + arguments: + - "checkPrivateReceivers" + - "sayRepetitiveInsteadOfStutters" tenv: # The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures. # Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked. @@ -93,6 +101,7 @@ linters: - nilerr # finds the code that returns nil even if it checks that the error is not nil - nilnil # checks that there is no simultaneous return of nil error and an invalid value - predeclared # predeclared finds code that shadows one of Go's predeclared identifiers + - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. - sqlclosecheck # checks that sql.Rows and sql.Stmt are closed - thelper # thelper detects Go test helpers without t.Helper() call and checks the consistency of test helpers. - wastedassign # wastedassign finds wasted assignment statements diff --git a/client/internal/auth/oauth.go b/client/internal/auth/oauth.go index 23bde2be2..7467584a3 100644 --- a/client/internal/auth/oauth.go +++ b/client/internal/auth/oauth.go @@ -26,7 +26,7 @@ type HTTPClient interface { } // AuthFlowInfo holds information for the OAuth 2.0 authorization flow -type AuthFlowInfo struct { +type AuthFlowInfo struct { //nolint:revive DeviceCode string `json:"device_code"` UserCode string `json:"user_code"` VerificationURI string `json:"verification_uri"` diff --git a/iface/netstack/tun.go b/iface/netstack/tun.go index 8c7c3a8ff..c180e4ef5 100644 --- a/iface/netstack/tun.go +++ b/iface/netstack/tun.go @@ -8,7 +8,7 @@ import ( "golang.zx2c4.com/wireguard/tun/netstack" ) -type NetStackTun struct { +type NetStackTun struct { //nolint:revive address string mtu int listenAddress string diff --git a/management/server/activity/event.go b/management/server/activity/event.go index 249547122..0e819c3a7 100644 --- a/management/server/activity/event.go +++ b/management/server/activity/event.go @@ -9,7 +9,7 @@ const ( ) // ActivityDescriber is an interface that describes an activity -type ActivityDescriber interface { +type ActivityDescriber interface { //nolint:revive StringCode() string Message() string } diff --git a/management/server/peer/peer.go b/management/server/peer/peer.go index f45c1cb9e..62f921b2d 100644 --- a/management/server/peer/peer.go +++ b/management/server/peer/peer.go @@ -46,7 +46,7 @@ type Peer struct { Location Location `gorm:"embedded;embeddedPrefix:location_"` } -type PeerStatus struct { +type PeerStatus struct { //nolint:revive // LastSeen is the last time peer was connected to the management service LastSeen time.Time // Connected indicates whether peer is connected to the management service or not @@ -72,7 +72,7 @@ type NetworkAddress struct { } // PeerSystemMeta is a metadata of a Peer machine system -type PeerSystemMeta struct { +type PeerSystemMeta struct { //nolint:revive Hostname string GoOS string Kernel string