From 34cd611a8befbef9367177da63ea5dabcfa06831 Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Fri, 3 Feb 2023 16:18:25 +0100 Subject: [PATCH] chore: Disable funlen linter --- .golangci.yml | 3 --- internal/app/app.go | 4 ++-- internal/app/bridge.go | 2 +- internal/app/migration.go | 1 - internal/bridge/bridge.go | 4 +--- internal/bridge/bug_report.go | 2 +- internal/bridge/imap.go | 3 --- internal/frontend/cli/accounts.go | 2 +- internal/frontend/cli/frontend.go | 4 ++-- internal/frontend/grpc/service.go | 4 +--- internal/frontend/grpc/service_stream.go | 2 +- internal/updater/sync.go | 2 +- internal/user/events.go | 2 +- internal/user/imap.go | 4 +--- internal/user/send_recorder.go | 2 -- internal/user/smtp.go | 7 ++----- internal/user/sync.go | 3 +-- internal/user/user.go | 6 +----- pkg/message/build.go | 4 ++-- pkg/message/parser.go | 2 +- utils/hasher/main.go | 2 +- utils/versioner/main.go | 2 +- 22 files changed, 22 insertions(+), 45 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 9ac51197..6149b688 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -23,7 +23,6 @@ issues: - path: _test\.go linters: - dupl - - funlen - gochecknoglobals - gochecknoinits - gosec @@ -32,7 +31,6 @@ issues: - path: test linters: - dupl - - funlen - gochecknoglobals - gochecknoinits - gosec @@ -64,7 +62,6 @@ linters: - depguard # Go linter that checks if package imports are in a list of acceptable packages [fast: true, auto-fix: false] - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) [fast: true, auto-fix: false] - dupl # Tool for code clone detection [fast: true, auto-fix: false] - - funlen # Tool for detection of long functions [fast: true, auto-fix: false] - gochecknoglobals # Checks that no globals are present in Go code [fast: true, auto-fix: false] - gochecknoinits # Checks that no init functions are present in Go code [fast: true, auto-fix: false] - goconst # Finds repeated strings that could be replaced by a constant [fast: true, auto-fix: false] diff --git a/internal/app/app.go b/internal/app/app.go index 6663a920..3167456f 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -81,7 +81,7 @@ const ( appUsage = "Proton Mail IMAP and SMTP Bridge" ) -func New() *cli.App { //nolint:funlen +func New() *cli.App { app := cli.NewApp() app.Name = constants.FullAppName @@ -156,7 +156,7 @@ func New() *cli.App { //nolint:funlen return app } -func run(c *cli.Context) error { //nolint:funlen +func run(c *cli.Context) error { // Seed the default RNG from the math/rand package. rand.Seed(time.Now().UnixNano()) diff --git a/internal/app/bridge.go b/internal/app/bridge.go index 38ce3c82..ef42697d 100644 --- a/internal/app/bridge.go +++ b/internal/app/bridge.go @@ -47,7 +47,7 @@ const vaultSecretName = "bridge-vault-key" var deleteOldGoIMAPFiles bool //nolint:gochecknoglobals // withBridge creates creates and tears down the bridge. -func withBridge( //nolint:funlen +func withBridge( c *cli.Context, exe string, locations *locations.Locations, diff --git a/internal/app/migration.go b/internal/app/migration.go index 7f187b1b..4c440e6b 100644 --- a/internal/app/migration.go +++ b/internal/app/migration.go @@ -187,7 +187,6 @@ func migrateOldAccount(userID string, store *credentials.Store, v *vault.Vault) return nil } -// nolint:funlen func migratePrefsToVault(vault *vault.Vault, b []byte) error { var prefs struct { IMAPPort int `json:"user_port_imap,,string"` diff --git a/internal/bridge/bridge.go b/internal/bridge/bridge.go index 699cf551..70cfb590 100644 --- a/internal/bridge/bridge.go +++ b/internal/bridge/bridge.go @@ -128,7 +128,7 @@ type Bridge struct { } // New creates a new bridge. -func New( //nolint:funlen +func New( locator Locator, // the locator to provide paths to store data vault *vault.Vault, // the bridge's encrypted data store autostarter Autostarter, // the autostarter to manage autostart settings @@ -191,7 +191,6 @@ func New( //nolint:funlen return bridge, eventCh, nil } -// nolint:funlen func newBridge( tasks *async.Group, imapEventCh chan imapEvents.Event, @@ -302,7 +301,6 @@ func newBridge( return bridge, nil } -// nolint:funlen func (bridge *Bridge) init(tlsReporter TLSReporter) error { // Enable or disable the proxy at startup. if bridge.vault.GetProxyAllowed() { diff --git a/internal/bridge/bug_report.go b/internal/bridge/bug_report.go index bffc6911..10fb30e0 100644 --- a/internal/bridge/bug_report.go +++ b/internal/bridge/bug_report.go @@ -37,7 +37,7 @@ const ( MaxCompressedFilesCount = 6 ) -func (bridge *Bridge) ReportBug(ctx context.Context, osType, osVersion, description, username, email, client string, attachLogs bool) error { //nolint:funlen +func (bridge *Bridge) ReportBug(ctx context.Context, osType, osVersion, description, username, email, client string, attachLogs bool) error { var account string if info, err := bridge.QueryUserInfo(username); err == nil { diff --git a/internal/bridge/imap.go b/internal/bridge/imap.go index 8141cbf9..dc606e0e 100644 --- a/internal/bridge/imap.go +++ b/internal/bridge/imap.go @@ -123,8 +123,6 @@ func (bridge *Bridge) closeIMAP(ctx context.Context) error { } // addIMAPUser connects the given user to gluon. -// -//nolint:funlen func (bridge *Bridge) addIMAPUser(ctx context.Context, user *user.User) error { if bridge.imapServer == nil { return fmt.Errorf("no imap server instance running") @@ -276,7 +274,6 @@ func ApplyGluonConfigPathSuffix(basePath string) string { return filepath.Join(basePath, "backend", "db") } -// nolint:funlen func newIMAPServer( gluonCacheDir, gluonConfigDir string, version *semver.Version, diff --git a/internal/frontend/cli/accounts.go b/internal/frontend/cli/accounts.go index afacb10c..1cfb44ad 100644 --- a/internal/frontend/cli/accounts.go +++ b/internal/frontend/cli/accounts.go @@ -115,7 +115,7 @@ func (f *frontendCLI) showAccountAddressInfo(user bridge.UserInfo, address strin f.Println("") } -func (f *frontendCLI) loginAccount(c *ishell.Context) { //nolint:funlen +func (f *frontendCLI) loginAccount(c *ishell.Context) { f.ShowPrompt(false) defer f.ShowPrompt(true) diff --git a/internal/frontend/cli/frontend.go b/internal/frontend/cli/frontend.go index 58ee6c4b..e22856ca 100644 --- a/internal/frontend/cli/frontend.go +++ b/internal/frontend/cli/frontend.go @@ -40,7 +40,7 @@ type frontendCLI struct { } // New returns a new CLI frontend configured with the given options. -func New(bridge *bridge.Bridge, restarter *restarter.Restarter, eventCh <-chan events.Event) *frontendCLI { //nolint:funlen,revive +func New(bridge *bridge.Bridge, restarter *restarter.Restarter, eventCh <-chan events.Event) *frontendCLI { //nolint:revive fe := &frontendCLI{ Shell: ishell.New(), bridge: bridge, @@ -261,7 +261,7 @@ func New(bridge *bridge.Bridge, restarter *restarter.Restarter, eventCh <-chan e return fe } -func (f *frontendCLI) watchEvents(eventCh <-chan events.Event) { // nolint:funlen,gocyclo +func (f *frontendCLI) watchEvents(eventCh <-chan events.Event) { // nolint:gocyclo // GODT-1949: Better error events. for _, err := range f.bridge.GetErrors() { switch { diff --git a/internal/frontend/grpc/service.go b/internal/frontend/grpc/service.go index 7d0bdfd4..9c429378 100644 --- a/internal/frontend/grpc/service.go +++ b/internal/frontend/grpc/service.go @@ -94,8 +94,6 @@ type Service struct { // nolint:structcheck } // NewService returns a new instance of the service. -// -// nolint:funlen func NewService( panicHandler CrashHandler, restarter Restarter, @@ -246,7 +244,7 @@ func (s *Service) WaitUntilFrontendIsReady() { s.initializing.Wait() } -// nolint:funlen,gocyclo +// nolint:gocyclo func (s *Service) watchEvents() { // GODT-1949 Better error events. for _, err := range s.bridge.GetErrors() { diff --git a/internal/frontend/grpc/service_stream.go b/internal/frontend/grpc/service_stream.go index 83d6c4d2..c7243523 100644 --- a/internal/frontend/grpc/service_stream.go +++ b/internal/frontend/grpc/service_stream.go @@ -110,7 +110,7 @@ func (s *Service) SendEvent(event *StreamEvent) error { } // StartEventTest sends all the known event via gRPC. -func (s *Service) StartEventTest() error { //nolint:funlen +func (s *Service) StartEventTest() error { const dummyAddress = "dummy@proton.me" events := []*StreamEvent{ // app diff --git a/internal/updater/sync.go b/internal/updater/sync.go index 440cbd5d..8137a93b 100644 --- a/internal/updater/sync.go +++ b/internal/updater/sync.go @@ -142,7 +142,7 @@ func checksum(path string) (hash string) { // srcDir including app folder. // dstDir including app folder. -func copyRecursively(srcDir, dstDir string) error { //nolint:funlen +func copyRecursively(srcDir, dstDir string) error { return filepath.Walk(srcDir, func(srcPath string, srcInfo os.FileInfo, err error) error { if err != nil { return err diff --git a/internal/user/events.go b/internal/user/events.go index b009a2f6..2b0fc314 100644 --- a/internal/user/events.go +++ b/internal/user/events.go @@ -415,7 +415,7 @@ func (user *User) handleDeleteLabelEvent(ctx context.Context, event proton.Label } // handleMessageEvents handles the given message events. -func (user *User) handleMessageEvents(ctx context.Context, messageEvents []proton.MessageEvent) error { //nolint:funlen +func (user *User) handleMessageEvents(ctx context.Context, messageEvents []proton.MessageEvent) error { for _, event := range messageEvents { ctx = logging.WithLogrusField(ctx, "messageID", event.ID) diff --git a/internal/user/imap.go b/internal/user/imap.go index 4b50a305..7fb51981 100644 --- a/internal/user/imap.go +++ b/internal/user/imap.go @@ -264,8 +264,6 @@ func (conn *imapConnector) DeleteMailbox(ctx context.Context, labelID imap.Mailb } // CreateMessage creates a new message on the remote. -// -// nolint:funlen func (conn *imapConnector) CreateMessage( ctx context.Context, mailboxID imap.MailboxID, @@ -589,7 +587,7 @@ func toIMAPMessage(message proton.MessageMetadata) imap.Message { } } -func (conn *imapConnector) createDraft(ctx context.Context, literal []byte, addrKR *crypto.KeyRing, sender proton.Address) (proton.Message, error) { //nolint:funlen +func (conn *imapConnector) createDraft(ctx context.Context, literal []byte, addrKR *crypto.KeyRing, sender proton.Address) (proton.Message, error) { // Create a new message parser from the reader. parser, err := parser.New(bytes.NewReader(literal)) if err != nil { diff --git a/internal/user/send_recorder.go b/internal/user/send_recorder.go index c83c9ef1..283b35eb 100644 --- a/internal/user/send_recorder.go +++ b/internal/user/send_recorder.go @@ -218,8 +218,6 @@ func (h *sendRecorder) getWaitCh(hash string) (<-chan struct{}, bool) { // - the Content-Type header of each (leaf) part, // - the Content-Disposition header of each (leaf) part, // - the (decoded) body of each part. -// -// nolint:funlen func getMessageHash(b []byte) (string, error) { section := rfc822.Parse(b) diff --git a/internal/user/smtp.go b/internal/user/smtp.go index ed6f399b..0fb6fafd 100644 --- a/internal/user/smtp.go +++ b/internal/user/smtp.go @@ -47,8 +47,6 @@ import ( ) // sendMail sends an email from the given address to the given recipients. -// -// nolint:funlen func (user *User) sendMail(authID string, from string, to []string, r io.Reader) error { return safe.RLockRet(func() error { ctx, cancel := context.WithCancel(context.Background()) @@ -165,7 +163,7 @@ func (user *User) sendMail(authID string, from string, to []string, r io.Reader) } // sendWithKey sends the message with the given address key. -func sendWithKey( //nolint:funlen +func sendWithKey( ctx context.Context, client *proton.Client, sentry reporter.Reporter, @@ -247,7 +245,7 @@ func sendWithKey( //nolint:funlen return res, nil } -func getParentID( //nolint:funlen +func getParentID( ctx context.Context, client *proton.Client, authAddrID string, @@ -375,7 +373,6 @@ func createDraft( }) } -// nolint:funlen func createAttachments( ctx context.Context, client *proton.Client, diff --git a/internal/user/sync.go b/internal/user/sync.go index 1bba8b10..f584c662 100644 --- a/internal/user/sync.go +++ b/internal/user/sync.go @@ -87,7 +87,6 @@ func (user *User) doSync(ctx context.Context) error { return nil } -// nolint:funlen func (user *User) sync(ctx context.Context) error { return safe.RLockRet(func() error { return withAddrKRs(user.apiUser, user.apiAddrs, user.vault.KeyPass(), func(_ *crypto.KeyRing, addrKRs map[string]*crypto.KeyRing) error { @@ -218,7 +217,7 @@ func toMB(v uint64) float64 { return float64(v) / float64(Megabyte) } -// nolint:funlen,gocyclo +// nolint:gocyclo func syncMessages( ctx context.Context, userID string, diff --git a/internal/user/user.go b/internal/user/user.go index d7423827..45146a92 100644 --- a/internal/user/user.go +++ b/internal/user/user.go @@ -90,8 +90,6 @@ type User struct { } // New returns a new user. -// -// nolint:funlen func New( ctx context.Context, encVault *vault.User, @@ -101,7 +99,7 @@ func New( crashHandler async.PanicHandler, showAllMail bool, maxSyncMemory uint64, -) (*User, error) { //nolint:funlen +) (*User, error) { logrus.WithField("userID", apiUser.ID).Info("Creating new user") // Get the user's API addresses. @@ -419,8 +417,6 @@ func (user *User) NewIMAPConnectors() (map[string]connector.Connector, error) { } // SendMail sends an email from the given address to the given recipients. -// -// nolint:funlen func (user *User) SendMail(authID string, from string, to []string, r io.Reader) error { defer user.goPollAPIEvents(true) diff --git a/pkg/message/build.go b/pkg/message/build.go index 4811b48e..a6b893f1 100644 --- a/pkg/message/build.go +++ b/pkg/message/build.go @@ -325,7 +325,7 @@ func buildPGPMIMEFallbackRFC822(msg proton.Message, opts JobOptions, buf *bytes. return nil } -func writeMultipartSignedRFC822(header message.Header, body []byte, sig proton.Signature, buf *bytes.Buffer) error { //nolint:funlen +func writeMultipartSignedRFC822(header message.Header, body []byte, sig proton.Signature, buf *bytes.Buffer) error { boundary := newBoundary("").gen() header.SetContentType("multipart/signed", map[string]string{ @@ -427,7 +427,7 @@ func addressEmpty(address *mail.Address) bool { return false } -func getMessageHeader(msg proton.Message, opts JobOptions) message.Header { //nolint:funlen +func getMessageHeader(msg proton.Message, opts JobOptions) message.Header { hdr := toMessageHeader(msg.ParsedHeaders) // SetText will RFC2047-encode. diff --git a/pkg/message/parser.go b/pkg/message/parser.go index 6d5ee23c..cba83aee 100644 --- a/pkg/message/parser.go +++ b/pkg/message/parser.go @@ -433,7 +433,7 @@ func getPlainBody(part *parser.Part) []byte { } } -func parseMessageHeader(h message.Header) (Message, error) { //nolint:funlen +func parseMessageHeader(h message.Header) (Message, error) { var m Message for fields := h.Fields(); fields.Next(); { diff --git a/utils/hasher/main.go b/utils/hasher/main.go index 6bc924f4..1b56df6e 100644 --- a/utils/hasher/main.go +++ b/utils/hasher/main.go @@ -32,7 +32,7 @@ func main() { } } -func createApp() *cli.App { //nolint:funlen +func createApp() *cli.App { app := cli.NewApp() app.Name = "hasher" diff --git a/utils/versioner/main.go b/utils/versioner/main.go index b847b049..0ff57d62 100644 --- a/utils/versioner/main.go +++ b/utils/versioner/main.go @@ -42,7 +42,7 @@ func main() { } } -func createApp() *cli.App { //nolint:funlen +func createApp() *cli.App { app := cli.NewApp() app.Name = "versioner"