chore: Disable funlen linter

This commit is contained in:
James Houlahan
2023-02-03 16:18:25 +01:00
parent d82b71de89
commit 34cd611a8b
22 changed files with 22 additions and 45 deletions

View File

@ -23,7 +23,6 @@ issues:
- path: _test\.go - path: _test\.go
linters: linters:
- dupl - dupl
- funlen
- gochecknoglobals - gochecknoglobals
- gochecknoinits - gochecknoinits
- gosec - gosec
@ -32,7 +31,6 @@ issues:
- path: test - path: test
linters: linters:
- dupl - dupl
- funlen
- gochecknoglobals - gochecknoglobals
- gochecknoinits - gochecknoinits
- gosec - 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] - 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] - 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] - 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] - 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] - 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] - goconst # Finds repeated strings that could be replaced by a constant [fast: true, auto-fix: false]

View File

@ -81,7 +81,7 @@ const (
appUsage = "Proton Mail IMAP and SMTP Bridge" appUsage = "Proton Mail IMAP and SMTP Bridge"
) )
func New() *cli.App { //nolint:funlen func New() *cli.App {
app := cli.NewApp() app := cli.NewApp()
app.Name = constants.FullAppName app.Name = constants.FullAppName
@ -156,7 +156,7 @@ func New() *cli.App { //nolint:funlen
return app 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. // Seed the default RNG from the math/rand package.
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())

View File

@ -47,7 +47,7 @@ const vaultSecretName = "bridge-vault-key"
var deleteOldGoIMAPFiles bool //nolint:gochecknoglobals var deleteOldGoIMAPFiles bool //nolint:gochecknoglobals
// withBridge creates creates and tears down the bridge. // withBridge creates creates and tears down the bridge.
func withBridge( //nolint:funlen func withBridge(
c *cli.Context, c *cli.Context,
exe string, exe string,
locations *locations.Locations, locations *locations.Locations,

View File

@ -187,7 +187,6 @@ func migrateOldAccount(userID string, store *credentials.Store, v *vault.Vault)
return nil return nil
} }
// nolint:funlen
func migratePrefsToVault(vault *vault.Vault, b []byte) error { func migratePrefsToVault(vault *vault.Vault, b []byte) error {
var prefs struct { var prefs struct {
IMAPPort int `json:"user_port_imap,,string"` IMAPPort int `json:"user_port_imap,,string"`

View File

@ -128,7 +128,7 @@ type Bridge struct {
} }
// New creates a new bridge. // New creates a new bridge.
func New( //nolint:funlen func New(
locator Locator, // the locator to provide paths to store data locator Locator, // the locator to provide paths to store data
vault *vault.Vault, // the bridge's encrypted data store vault *vault.Vault, // the bridge's encrypted data store
autostarter Autostarter, // the autostarter to manage autostart settings autostarter Autostarter, // the autostarter to manage autostart settings
@ -191,7 +191,6 @@ func New( //nolint:funlen
return bridge, eventCh, nil return bridge, eventCh, nil
} }
// nolint:funlen
func newBridge( func newBridge(
tasks *async.Group, tasks *async.Group,
imapEventCh chan imapEvents.Event, imapEventCh chan imapEvents.Event,
@ -302,7 +301,6 @@ func newBridge(
return bridge, nil return bridge, nil
} }
// nolint:funlen
func (bridge *Bridge) init(tlsReporter TLSReporter) error { func (bridge *Bridge) init(tlsReporter TLSReporter) error {
// Enable or disable the proxy at startup. // Enable or disable the proxy at startup.
if bridge.vault.GetProxyAllowed() { if bridge.vault.GetProxyAllowed() {

View File

@ -37,7 +37,7 @@ const (
MaxCompressedFilesCount = 6 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 var account string
if info, err := bridge.QueryUserInfo(username); err == nil { if info, err := bridge.QueryUserInfo(username); err == nil {

View File

@ -123,8 +123,6 @@ func (bridge *Bridge) closeIMAP(ctx context.Context) error {
} }
// addIMAPUser connects the given user to gluon. // addIMAPUser connects the given user to gluon.
//
//nolint:funlen
func (bridge *Bridge) addIMAPUser(ctx context.Context, user *user.User) error { func (bridge *Bridge) addIMAPUser(ctx context.Context, user *user.User) error {
if bridge.imapServer == nil { if bridge.imapServer == nil {
return fmt.Errorf("no imap server instance running") return fmt.Errorf("no imap server instance running")
@ -276,7 +274,6 @@ func ApplyGluonConfigPathSuffix(basePath string) string {
return filepath.Join(basePath, "backend", "db") return filepath.Join(basePath, "backend", "db")
} }
// nolint:funlen
func newIMAPServer( func newIMAPServer(
gluonCacheDir, gluonConfigDir string, gluonCacheDir, gluonConfigDir string,
version *semver.Version, version *semver.Version,

View File

@ -115,7 +115,7 @@ func (f *frontendCLI) showAccountAddressInfo(user bridge.UserInfo, address strin
f.Println("") f.Println("")
} }
func (f *frontendCLI) loginAccount(c *ishell.Context) { //nolint:funlen func (f *frontendCLI) loginAccount(c *ishell.Context) {
f.ShowPrompt(false) f.ShowPrompt(false)
defer f.ShowPrompt(true) defer f.ShowPrompt(true)

View File

@ -40,7 +40,7 @@ type frontendCLI struct {
} }
// New returns a new CLI frontend configured with the given options. // 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{ fe := &frontendCLI{
Shell: ishell.New(), Shell: ishell.New(),
bridge: bridge, bridge: bridge,
@ -261,7 +261,7 @@ func New(bridge *bridge.Bridge, restarter *restarter.Restarter, eventCh <-chan e
return fe 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. // GODT-1949: Better error events.
for _, err := range f.bridge.GetErrors() { for _, err := range f.bridge.GetErrors() {
switch { switch {

View File

@ -94,8 +94,6 @@ type Service struct { // nolint:structcheck
} }
// NewService returns a new instance of the service. // NewService returns a new instance of the service.
//
// nolint:funlen
func NewService( func NewService(
panicHandler CrashHandler, panicHandler CrashHandler,
restarter Restarter, restarter Restarter,
@ -246,7 +244,7 @@ func (s *Service) WaitUntilFrontendIsReady() {
s.initializing.Wait() s.initializing.Wait()
} }
// nolint:funlen,gocyclo // nolint:gocyclo
func (s *Service) watchEvents() { func (s *Service) watchEvents() {
// GODT-1949 Better error events. // GODT-1949 Better error events.
for _, err := range s.bridge.GetErrors() { for _, err := range s.bridge.GetErrors() {

View File

@ -110,7 +110,7 @@ func (s *Service) SendEvent(event *StreamEvent) error {
} }
// StartEventTest sends all the known event via gRPC. // 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" const dummyAddress = "dummy@proton.me"
events := []*StreamEvent{ events := []*StreamEvent{
// app // app

View File

@ -142,7 +142,7 @@ func checksum(path string) (hash string) {
// srcDir including app folder. // srcDir including app folder.
// dstDir 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 { return filepath.Walk(srcDir, func(srcPath string, srcInfo os.FileInfo, err error) error {
if err != nil { if err != nil {
return err return err

View File

@ -415,7 +415,7 @@ func (user *User) handleDeleteLabelEvent(ctx context.Context, event proton.Label
} }
// handleMessageEvents handles the given message events. // 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 { for _, event := range messageEvents {
ctx = logging.WithLogrusField(ctx, "messageID", event.ID) ctx = logging.WithLogrusField(ctx, "messageID", event.ID)

View File

@ -264,8 +264,6 @@ func (conn *imapConnector) DeleteMailbox(ctx context.Context, labelID imap.Mailb
} }
// CreateMessage creates a new message on the remote. // CreateMessage creates a new message on the remote.
//
// nolint:funlen
func (conn *imapConnector) CreateMessage( func (conn *imapConnector) CreateMessage(
ctx context.Context, ctx context.Context,
mailboxID imap.MailboxID, 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. // Create a new message parser from the reader.
parser, err := parser.New(bytes.NewReader(literal)) parser, err := parser.New(bytes.NewReader(literal))
if err != nil { if err != nil {

View File

@ -218,8 +218,6 @@ func (h *sendRecorder) getWaitCh(hash string) (<-chan struct{}, bool) {
// - the Content-Type header of each (leaf) part, // - the Content-Type header of each (leaf) part,
// - the Content-Disposition header of each (leaf) part, // - the Content-Disposition header of each (leaf) part,
// - the (decoded) body of each part. // - the (decoded) body of each part.
//
// nolint:funlen
func getMessageHash(b []byte) (string, error) { func getMessageHash(b []byte) (string, error) {
section := rfc822.Parse(b) section := rfc822.Parse(b)

View File

@ -47,8 +47,6 @@ import (
) )
// sendMail sends an email from the given address to the given recipients. // 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 { func (user *User) sendMail(authID string, from string, to []string, r io.Reader) error {
return safe.RLockRet(func() error { return safe.RLockRet(func() error {
ctx, cancel := context.WithCancel(context.Background()) 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. // sendWithKey sends the message with the given address key.
func sendWithKey( //nolint:funlen func sendWithKey(
ctx context.Context, ctx context.Context,
client *proton.Client, client *proton.Client,
sentry reporter.Reporter, sentry reporter.Reporter,
@ -247,7 +245,7 @@ func sendWithKey( //nolint:funlen
return res, nil return res, nil
} }
func getParentID( //nolint:funlen func getParentID(
ctx context.Context, ctx context.Context,
client *proton.Client, client *proton.Client,
authAddrID string, authAddrID string,
@ -375,7 +373,6 @@ func createDraft(
}) })
} }
// nolint:funlen
func createAttachments( func createAttachments(
ctx context.Context, ctx context.Context,
client *proton.Client, client *proton.Client,

View File

@ -87,7 +87,6 @@ func (user *User) doSync(ctx context.Context) error {
return nil return nil
} }
// nolint:funlen
func (user *User) sync(ctx context.Context) error { func (user *User) sync(ctx context.Context) error {
return safe.RLockRet(func() error { return safe.RLockRet(func() error {
return withAddrKRs(user.apiUser, user.apiAddrs, user.vault.KeyPass(), func(_ *crypto.KeyRing, addrKRs map[string]*crypto.KeyRing) 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) return float64(v) / float64(Megabyte)
} }
// nolint:funlen,gocyclo // nolint:gocyclo
func syncMessages( func syncMessages(
ctx context.Context, ctx context.Context,
userID string, userID string,

View File

@ -90,8 +90,6 @@ type User struct {
} }
// New returns a new user. // New returns a new user.
//
// nolint:funlen
func New( func New(
ctx context.Context, ctx context.Context,
encVault *vault.User, encVault *vault.User,
@ -101,7 +99,7 @@ func New(
crashHandler async.PanicHandler, crashHandler async.PanicHandler,
showAllMail bool, showAllMail bool,
maxSyncMemory uint64, maxSyncMemory uint64,
) (*User, error) { //nolint:funlen ) (*User, error) {
logrus.WithField("userID", apiUser.ID).Info("Creating new user") logrus.WithField("userID", apiUser.ID).Info("Creating new user")
// Get the user's API addresses. // 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. // 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 { func (user *User) SendMail(authID string, from string, to []string, r io.Reader) error {
defer user.goPollAPIEvents(true) defer user.goPollAPIEvents(true)

View File

@ -325,7 +325,7 @@ func buildPGPMIMEFallbackRFC822(msg proton.Message, opts JobOptions, buf *bytes.
return nil 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() boundary := newBoundary("").gen()
header.SetContentType("multipart/signed", map[string]string{ header.SetContentType("multipart/signed", map[string]string{
@ -427,7 +427,7 @@ func addressEmpty(address *mail.Address) bool {
return false 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) hdr := toMessageHeader(msg.ParsedHeaders)
// SetText will RFC2047-encode. // SetText will RFC2047-encode.

View File

@ -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 var m Message
for fields := h.Fields(); fields.Next(); { for fields := h.Fields(); fields.Next(); {

View File

@ -32,7 +32,7 @@ func main() {
} }
} }
func createApp() *cli.App { //nolint:funlen func createApp() *cli.App {
app := cli.NewApp() app := cli.NewApp()
app.Name = "hasher" app.Name = "hasher"

View File

@ -42,7 +42,7 @@ func main() {
} }
} }
func createApp() *cli.App { //nolint:funlen func createApp() *cli.App {
app := cli.NewApp() app := cli.NewApp()
app.Name = "versioner" app.Name = "versioner"