diff --git a/.golangci.yml b/.golangci.yml index 6149b688..b44fe6d5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -48,16 +48,13 @@ linters: disable-all: true enable: - - deadcode # Finds unused code [fast: true, auto-fix: false] - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: true, auto-fix: false] - gosimple # Linter for Go source code that specializes in simplifying a code [fast: true, auto-fix: false] - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: true, auto-fix: false] - ineffassign # Detects when assignments to existing variables are not used [fast: true, auto-fix: false] - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: true, auto-fix: false] - - structcheck # Finds unused struct fields [fast: true, auto-fix: false] - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code [fast: true, auto-fix: false] - unused # Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false] - - varcheck # Finds unused global variables and constants [fast: true, auto-fix: false] - bodyclose # checks whether HTTP response body is closed successfully [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] @@ -119,3 +116,8 @@ linters: # - testpackage # linter that makes you use a separate _test package [fast: true, auto-fix: false] # - thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers [fast: false, auto-fix: false] # - wrapcheck # Checks that errors returned from external packages are wrapped [fast: false, auto-fix: false] + + # Deprecated: + # - structcheck # Finds unused struct fields [fast: true, auto-fix: false] deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused. + # - deadcode # Finds unused code [fast: true, auto-fix: false] deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused. + # - varcheck # Finds unused global variables and constants [fast: true, auto-fix: false] deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused. \ No newline at end of file diff --git a/Makefile b/Makefile index 4fbd1e79..39ffc991 100644 --- a/Makefile +++ b/Makefile @@ -183,7 +183,7 @@ ${RESOURCE_FILE}: ./dist/info.rc ./dist/${SRC_ICO} .FORCE ## Dev dependencies .PHONY: install-devel-tools install-linter install-go-mod-outdated install-git-hooks -LINTVER:="v1.50.0" +LINTVER:="v1.52.2" LINTSRC:="https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" install-dev-dependencies: install-devel-tools install-linter install-go-mod-outdated diff --git a/internal/bridge/files.go b/internal/bridge/files.go index 475b1925..cb6a8cfc 100644 --- a/internal/bridge/files.go +++ b/internal/bridge/files.go @@ -58,11 +58,7 @@ func moveFile(from, to string) error { return err } - if err := os.Rename(from, to); err != nil { - return err - } - - return nil + return os.Rename(from, to) } func copyDir(from, to string) error { diff --git a/internal/bridge/mocks.go b/internal/bridge/mocks.go index 1c7bf934..63b16b8f 100644 --- a/internal/bridge/mocks.go +++ b/internal/bridge/mocks.go @@ -144,13 +144,13 @@ func (testUpdater *TestUpdater) SetLatestVersion(version, minAuto *semver.Versio } } -func (testUpdater *TestUpdater) GetVersionInfo(ctx context.Context, downloader updater.Downloader, channel updater.Channel) (updater.VersionInfo, error) { +func (testUpdater *TestUpdater) GetVersionInfo(_ context.Context, _ updater.Downloader, _ updater.Channel) (updater.VersionInfo, error) { testUpdater.lock.RLock() defer testUpdater.lock.RUnlock() return testUpdater.latest, nil } -func (testUpdater *TestUpdater) InstallUpdate(ctx context.Context, downloader updater.Downloader, update updater.VersionInfo) error { +func (testUpdater *TestUpdater) InstallUpdate(_ context.Context, _ updater.Downloader, _ updater.VersionInfo) error { return nil } diff --git a/internal/bridge/smtp_backend.go b/internal/bridge/smtp_backend.go index d48f3923..014edd81 100644 --- a/internal/bridge/smtp_backend.go +++ b/internal/bridge/smtp_backend.go @@ -72,7 +72,7 @@ func (s *smtpSession) Logout() error { return nil } -func (s *smtpSession) Mail(from string, opts *smtp.MailOptions) error { +func (s *smtpSession) Mail(from string, _ *smtp.MailOptions) error { s.from = from return nil } diff --git a/internal/bridge/user_test.go b/internal/bridge/user_test.go index 417e7bd7..135c8f23 100644 --- a/internal/bridge/user_test.go +++ b/internal/bridge/user_test.go @@ -709,6 +709,6 @@ func TestBridge_User_Refresh(t *testing.T) { } // getErr returns the error that was passed to it. -func getErr[T any](val T, err error) error { +func getErr[T any](_ T, err error) error { return err } diff --git a/internal/certs/cert_store_darwin.go b/internal/certs/cert_store_darwin.go index 8e1f9570..61a5977d 100644 --- a/internal/certs/cert_store_darwin.go +++ b/internal/certs/cert_store_darwin.go @@ -107,7 +107,6 @@ const ( // certPEMToDER converts a certificate in PEM format to DER format, which is the format required by Apple's Security framework. func certPEMToDER(certPEM []byte) ([]byte, error) { - block, left := pem.Decode(certPEM) if block == nil { return []byte{}, errors.New("invalid PEM certificate") @@ -127,7 +126,7 @@ func installCert(certPEM []byte) error { } p := C.CBytes(certDER) - defer C.free(unsafe.Pointer(p)) + defer C.free(unsafe.Pointer(p)) //nolint:unconvert errCode := C.installTrustedCert((*C.char)(p), (C.ulonglong)(len(certDER))) switch errCode { @@ -147,7 +146,7 @@ func uninstallCert(certPEM []byte) error { } p := C.CBytes(certDER) - defer C.free(unsafe.Pointer(p)) + defer C.free(unsafe.Pointer(p)) //nolint:unconvert if errCode := C.removeTrustedCert((*C.char)(p), (C.ulonglong)(len(certDER))); errCode != 0 { return fmt.Errorf("could not install certificate from keychain (error %v)", errCode) diff --git a/internal/certs/cert_store_darwin_test.go b/internal/certs/cert_store_darwin_test.go index 9ac9c698..3b1d419f 100644 --- a/internal/certs/cert_store_darwin_test.go +++ b/internal/certs/cert_store_darwin_test.go @@ -26,7 +26,7 @@ import ( ) // This test implies human interactions to enter password and is disabled by default. -func _TestTrustedCertsDarwin(t *testing.T) { +func _TestTrustedCertsDarwin(t *testing.T) { //nolint:unused template, err := NewTLSTemplate() require.NoError(t, err) diff --git a/internal/frontend/cli/accounts.go b/internal/frontend/cli/accounts.go index 09e3c15a..fdef4b17 100644 --- a/internal/frontend/cli/accounts.go +++ b/internal/frontend/cli/accounts.go @@ -305,11 +305,11 @@ func (f *frontendCLI) configureAppleMail(c *ishell.Context) { f.Printf("Apple Mail configured for %v with address %v\n", user.Username, user.Addresses[0]) } -func (f *frontendCLI) badEventSynchronize(c *ishell.Context) { +func (f *frontendCLI) badEventSynchronize(_ *ishell.Context) { f.badEventFeedback(true) } -func (f *frontendCLI) badEventLogout(c *ishell.Context) { +func (f *frontendCLI) badEventLogout(_ *ishell.Context) { f.badEventFeedback(false) } diff --git a/internal/frontend/cli/system.go b/internal/frontend/cli/system.go index 1290d0fa..3ea41dca 100644 --- a/internal/frontend/cli/system.go +++ b/internal/frontend/cli/system.go @@ -31,7 +31,7 @@ import ( "github.com/abiosoft/ishell" ) -func (f *frontendCLI) printLogDir(c *ishell.Context) { +func (f *frontendCLI) printLogDir(_ *ishell.Context) { if path, err := f.bridge.GetLogsPath(); err != nil { f.Println("Failed to determine location of log files") } else { @@ -39,17 +39,17 @@ func (f *frontendCLI) printLogDir(c *ishell.Context) { } } -func (f *frontendCLI) printManual(c *ishell.Context) { +func (f *frontendCLI) printManual(_ *ishell.Context) { f.Println("More instructions about the Bridge can be found at\n\n https://proton.me/mail/bridge") } -func (f *frontendCLI) printCredits(c *ishell.Context) { +func (f *frontendCLI) printCredits(_ *ishell.Context) { for _, pkg := range strings.Split(bridge.Credits, ";") { f.Println(pkg) } } -func (f *frontendCLI) changeIMAPSecurity(c *ishell.Context) { +func (f *frontendCLI) changeIMAPSecurity(_ *ishell.Context) { f.ShowPrompt(false) defer f.ShowPrompt(true) @@ -68,7 +68,7 @@ func (f *frontendCLI) changeIMAPSecurity(c *ishell.Context) { } } -func (f *frontendCLI) changeSMTPSecurity(c *ishell.Context) { +func (f *frontendCLI) changeSMTPSecurity(_ *ishell.Context) { f.ShowPrompt(false) defer f.ShowPrompt(true) @@ -131,7 +131,7 @@ func (f *frontendCLI) changeSMTPPort(c *ishell.Context) { } } -func (f *frontendCLI) allowProxy(c *ishell.Context) { +func (f *frontendCLI) allowProxy(_ *ishell.Context) { if f.bridge.GetProxyAllowed() { f.Println("Bridge is already set to use alternative routing to connect to Proton if it is being blocked.") return @@ -147,7 +147,7 @@ func (f *frontendCLI) allowProxy(c *ishell.Context) { } } -func (f *frontendCLI) disallowProxy(c *ishell.Context) { +func (f *frontendCLI) disallowProxy(_ *ishell.Context) { if !f.bridge.GetProxyAllowed() { f.Println("Bridge is already set to NOT use alternative routing to connect to Proton if it is being blocked.") return @@ -163,7 +163,7 @@ func (f *frontendCLI) disallowProxy(c *ishell.Context) { } } -func (f *frontendCLI) hideAllMail(c *ishell.Context) { +func (f *frontendCLI) hideAllMail(_ *ishell.Context) { if !f.bridge.GetShowAllMail() { f.Println("All Mail folder is not listed in your local client.") return @@ -179,7 +179,7 @@ func (f *frontendCLI) hideAllMail(c *ishell.Context) { } } -func (f *frontendCLI) showAllMail(c *ishell.Context) { +func (f *frontendCLI) showAllMail(_ *ishell.Context) { if f.bridge.GetShowAllMail() { f.Println("All Mail folder is listed in your local client.") return diff --git a/internal/frontend/cli/updates.go b/internal/frontend/cli/updates.go index baf253c8..2952b56e 100644 --- a/internal/frontend/cli/updates.go +++ b/internal/frontend/cli/updates.go @@ -23,7 +23,7 @@ import ( "github.com/abiosoft/ishell" ) -func (f *frontendCLI) checkUpdates(c *ishell.Context) { +func (f *frontendCLI) checkUpdates(_ *ishell.Context) { updateCh, done := f.bridge.GetEvents(events.UpdateAvailable{}, events.UpdateNotAvailable{}) defer done() @@ -38,7 +38,7 @@ func (f *frontendCLI) checkUpdates(c *ishell.Context) { } } -func (f *frontendCLI) enableAutoUpdates(c *ishell.Context) { +func (f *frontendCLI) enableAutoUpdates(_ *ishell.Context) { if f.bridge.GetAutoUpdate() { f.Println("Bridge is already set to automatically install updates.") return @@ -54,7 +54,7 @@ func (f *frontendCLI) enableAutoUpdates(c *ishell.Context) { } } -func (f *frontendCLI) disableAutoUpdates(c *ishell.Context) { +func (f *frontendCLI) disableAutoUpdates(_ *ishell.Context) { if !f.bridge.GetAutoUpdate() { f.Println("Bridge is already set to NOT automatically install updates.") return @@ -70,7 +70,7 @@ func (f *frontendCLI) disableAutoUpdates(c *ishell.Context) { } } -func (f *frontendCLI) selectEarlyChannel(c *ishell.Context) { +func (f *frontendCLI) selectEarlyChannel(_ *ishell.Context) { if f.bridge.GetUpdateChannel() == updater.EarlyChannel { f.Println("Bridge is already on the early-access update channel.") return @@ -86,7 +86,7 @@ func (f *frontendCLI) selectEarlyChannel(c *ishell.Context) { } } -func (f *frontendCLI) selectStableChannel(c *ishell.Context) { +func (f *frontendCLI) selectStableChannel(_ *ishell.Context) { if f.bridge.GetUpdateChannel() == updater.StableChannel { f.Println("Bridge is already on the stable update channel.") return diff --git a/internal/frontend/grpc/service_methods.go b/internal/frontend/grpc/service_methods.go index a49e698a..49e86b1f 100644 --- a/internal/frontend/grpc/service_methods.go +++ b/internal/frontend/grpc/service_methods.go @@ -47,7 +47,7 @@ import ( ) // CheckTokens implements the CheckToken gRPC service call. -func (s *Service) CheckTokens(ctx context.Context, clientConfigPath *wrapperspb.StringValue) (*wrapperspb.StringValue, error) { +func (s *Service) CheckTokens(_ context.Context, clientConfigPath *wrapperspb.StringValue) (*wrapperspb.StringValue, error) { s.log.Debug("CheckTokens") path := clientConfigPath.Value @@ -65,7 +65,7 @@ func (s *Service) CheckTokens(ctx context.Context, clientConfigPath *wrapperspb. return &wrapperspb.StringValue{Value: clientConfig.Token}, nil } -func (s *Service) AddLogEntry(ctx context.Context, request *AddLogEntryRequest) (*emptypb.Empty, error) { +func (s *Service) AddLogEntry(_ context.Context, request *AddLogEntryRequest) (*emptypb.Empty, error) { entry := s.log if len(request.Package) > 0 { @@ -93,7 +93,7 @@ func (s *Service) AddLogEntry(ctx context.Context, request *AddLogEntryRequest) } // GuiReady implement the GuiReady gRPC service call. -func (s *Service) GuiReady(ctx context.Context, _ *emptypb.Empty) (*GuiReadyResponse, error) { +func (s *Service) GuiReady(_ context.Context, _ *emptypb.Empty) (*GuiReadyResponse, error) { s.log.Debug("GuiReady") s.initializationDone.Do(s.initializing.Done) @@ -107,7 +107,7 @@ func (s *Service) GuiReady(ctx context.Context, _ *emptypb.Empty) (*GuiReadyResp } // Quit implement the Quit gRPC service call. -func (s *Service) Quit(ctx context.Context, empty *emptypb.Empty) (*emptypb.Empty, error) { +func (s *Service) Quit(_ context.Context, _ *emptypb.Empty) (*emptypb.Empty, error) { s.log.Debug("Quit") return &emptypb.Empty{}, s.quit() } @@ -143,13 +143,13 @@ func (s *Service) Restart(ctx context.Context, empty *emptypb.Empty) (*emptypb.E return s.Quit(ctx, empty) } -func (s *Service) ShowOnStartup(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.BoolValue, error) { +func (s *Service) ShowOnStartup(_ context.Context, _ *emptypb.Empty) (*wrapperspb.BoolValue, error) { s.log.Debug("ShowOnStartup") return wrapperspb.Bool(s.showOnStartup), nil } -func (s *Service) SetIsAutostartOn(ctx context.Context, isOn *wrapperspb.BoolValue) (*emptypb.Empty, error) { +func (s *Service) SetIsAutostartOn(_ context.Context, isOn *wrapperspb.BoolValue) (*emptypb.Empty, error) { s.log.WithField("show", isOn.Value).Debug("SetIsAutostartOn") defer func() { _ = s.SendEvent(NewToggleAutostartFinishedEvent()) }() @@ -169,13 +169,13 @@ func (s *Service) SetIsAutostartOn(ctx context.Context, isOn *wrapperspb.BoolVal return &emptypb.Empty{}, nil } -func (s *Service) IsAutostartOn(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.BoolValue, error) { +func (s *Service) IsAutostartOn(_ context.Context, _ *emptypb.Empty) (*wrapperspb.BoolValue, error) { s.log.Debug("IsAutostartOn") return wrapperspb.Bool(s.bridge.GetAutostart()), nil } -func (s *Service) SetIsBetaEnabled(ctx context.Context, isEnabled *wrapperspb.BoolValue) (*emptypb.Empty, error) { +func (s *Service) SetIsBetaEnabled(_ context.Context, isEnabled *wrapperspb.BoolValue) (*emptypb.Empty, error) { s.log.WithField("isEnabled", isEnabled.Value).Debug("SetIsBetaEnabled") channel := updater.StableChannel @@ -191,13 +191,13 @@ func (s *Service) SetIsBetaEnabled(ctx context.Context, isEnabled *wrapperspb.Bo return &emptypb.Empty{}, nil } -func (s *Service) IsBetaEnabled(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.BoolValue, error) { +func (s *Service) IsBetaEnabled(_ context.Context, _ *emptypb.Empty) (*wrapperspb.BoolValue, error) { s.log.Debug("IsBetaEnabled") return wrapperspb.Bool(s.bridge.GetUpdateChannel() == updater.EarlyChannel), nil } -func (s *Service) SetIsAllMailVisible(ctx context.Context, isVisible *wrapperspb.BoolValue) (*emptypb.Empty, error) { +func (s *Service) SetIsAllMailVisible(_ context.Context, isVisible *wrapperspb.BoolValue) (*emptypb.Empty, error) { s.log.WithField("isVisible", isVisible.Value).Debug("SetIsAllMailVisible") if err := s.bridge.SetShowAllMail(isVisible.Value); err != nil { @@ -208,7 +208,7 @@ func (s *Service) SetIsAllMailVisible(ctx context.Context, isVisible *wrapperspb return &emptypb.Empty{}, nil } -func (s *Service) IsAllMailVisible(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.BoolValue, error) { +func (s *Service) IsAllMailVisible(_ context.Context, _ *emptypb.Empty) (*wrapperspb.BoolValue, error) { s.log.Debug("IsAllMailVisible") return wrapperspb.Bool(s.bridge.GetShowAllMail()), nil @@ -231,13 +231,13 @@ func (s *Service) IsTelemetryDisabled(_ context.Context, _ *emptypb.Empty) (*wra return wrapperspb.Bool(s.bridge.GetTelemetryDisabled()), nil } -func (s *Service) GoOs(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { +func (s *Service) GoOs(_ context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { s.log.Debug("GoOs") // TO-DO We can probably get rid of this and use QSysInfo::product name return wrapperspb.String(runtime.GOOS), nil } -func (s *Service) TriggerReset(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error) { +func (s *Service) TriggerReset(_ context.Context, _ *emptypb.Empty) (*emptypb.Empty, error) { s.log.Debug("TriggerReset") go func() { @@ -248,13 +248,13 @@ func (s *Service) TriggerReset(ctx context.Context, _ *emptypb.Empty) (*emptypb. return &emptypb.Empty{}, nil } -func (s *Service) Version(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { +func (s *Service) Version(_ context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { s.log.Debug("Version") return wrapperspb.String(s.bridge.GetCurrentVersion().Original()), nil } -func (s *Service) LogsPath(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { +func (s *Service) LogsPath(_ context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { s.log.Debug("LogsPath") path, err := s.bridge.GetLogsPath() @@ -265,7 +265,7 @@ func (s *Service) LogsPath(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.S return wrapperspb.String(path), nil } -func (s *Service) LicensePath(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { +func (s *Service) LicensePath(_ context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { s.log.Debug("LicensePath") return wrapperspb.String(s.bridge.GetLicenseFilePath()), nil @@ -275,7 +275,7 @@ func (s *Service) DependencyLicensesLink(_ context.Context, _ *emptypb.Empty) (* return wrapperspb.String(s.bridge.GetDependencyLicensesLink()), nil } -func (s *Service) ReleaseNotesPageLink(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { +func (s *Service) ReleaseNotesPageLink(_ context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { s.latestLock.RLock() defer s.latestLock.RUnlock() @@ -289,7 +289,7 @@ func (s *Service) LandingPageLink(_ context.Context, _ *emptypb.Empty) (*wrapper return wrapperspb.String(s.latest.LandingPage), nil } -func (s *Service) SetColorSchemeName(ctx context.Context, name *wrapperspb.StringValue) (*emptypb.Empty, error) { +func (s *Service) SetColorSchemeName(_ context.Context, name *wrapperspb.StringValue) (*emptypb.Empty, error) { s.log.WithField("ColorSchemeName", name.Value).Debug("SetColorSchemeName") if !theme.IsAvailable(theme.Theme(name.Value)) { @@ -305,7 +305,7 @@ func (s *Service) SetColorSchemeName(ctx context.Context, name *wrapperspb.Strin return &emptypb.Empty{}, nil } -func (s *Service) ColorSchemeName(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { +func (s *Service) ColorSchemeName(_ context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { s.log.Debug("ColorSchemeName") current := s.bridge.GetColorScheme() @@ -320,13 +320,13 @@ func (s *Service) ColorSchemeName(ctx context.Context, _ *emptypb.Empty) (*wrapp return wrapperspb.String(current), nil } -func (s *Service) CurrentEmailClient(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { +func (s *Service) CurrentEmailClient(_ context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { s.log.Debug("CurrentEmailClient") return wrapperspb.String(s.bridge.GetCurrentUserAgent()), nil } -func (s *Service) ReportBug(ctx context.Context, report *ReportBugRequest) (*emptypb.Empty, error) { +func (s *Service) ReportBug(_ context.Context, report *ReportBugRequest) (*emptypb.Empty, error) { s.log.WithFields(logrus.Fields{ "osType": report.OsType, "osVersion": report.OsVersion, @@ -382,7 +382,7 @@ func (s *Service) ExportTLSCertificates(_ context.Context, folderPath *wrappersp return &emptypb.Empty{}, nil } -func (s *Service) ForceLauncher(ctx context.Context, launcher *wrapperspb.StringValue) (*emptypb.Empty, error) { +func (s *Service) ForceLauncher(_ context.Context, launcher *wrapperspb.StringValue) (*emptypb.Empty, error) { s.log.WithField("launcher", launcher.Value).Debug("ForceLauncher") s.restarter.Override(launcher.Value) @@ -390,7 +390,7 @@ func (s *Service) ForceLauncher(ctx context.Context, launcher *wrapperspb.String return &emptypb.Empty{}, nil } -func (s *Service) SetMainExecutable(ctx context.Context, exe *wrapperspb.StringValue) (*emptypb.Empty, error) { +func (s *Service) SetMainExecutable(_ context.Context, exe *wrapperspb.StringValue) (*emptypb.Empty, error) { s.log.WithField("executable", exe.Value).Debug("SetMainExecutable") s.restarter.AddFlags("--wait", exe.Value) @@ -398,7 +398,7 @@ func (s *Service) SetMainExecutable(ctx context.Context, exe *wrapperspb.StringV return &emptypb.Empty{}, nil } -func (s *Service) Login(ctx context.Context, login *LoginRequest) (*emptypb.Empty, error) { +func (s *Service) Login(_ context.Context, login *LoginRequest) (*emptypb.Empty, error) { s.log.WithField("username", login.Username).Debug("Login") go func() { @@ -454,7 +454,7 @@ func (s *Service) Login(ctx context.Context, login *LoginRequest) (*emptypb.Empt return &emptypb.Empty{}, nil } -func (s *Service) Login2FA(ctx context.Context, login *LoginRequest) (*emptypb.Empty, error) { +func (s *Service) Login2FA(_ context.Context, login *LoginRequest) (*emptypb.Empty, error) { s.log.WithField("username", login.Username).Debug("Login2FA") go func() { @@ -499,7 +499,7 @@ func (s *Service) Login2FA(ctx context.Context, login *LoginRequest) (*emptypb.E return &emptypb.Empty{}, nil } -func (s *Service) Login2Passwords(ctx context.Context, login *LoginRequest) (*emptypb.Empty, error) { +func (s *Service) Login2Passwords(_ context.Context, login *LoginRequest) (*emptypb.Empty, error) { s.log.WithField("username", login.Username).Debug("Login2Passwords") go func() { @@ -521,7 +521,7 @@ func (s *Service) Login2Passwords(ctx context.Context, login *LoginRequest) (*em return &emptypb.Empty{}, nil } -func (s *Service) LoginAbort(ctx context.Context, loginAbort *LoginAbortRequest) (*emptypb.Empty, error) { +func (s *Service) LoginAbort(_ context.Context, loginAbort *LoginAbortRequest) (*emptypb.Empty, error) { s.log.WithField("username", loginAbort.Username).Debug("LoginAbort") go func() { @@ -565,7 +565,7 @@ func (s *Service) CheckUpdate(context.Context, *emptypb.Empty) (*emptypb.Empty, return &emptypb.Empty{}, nil } -func (s *Service) InstallUpdate(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error) { +func (s *Service) InstallUpdate(_ context.Context, _ *emptypb.Empty) (*emptypb.Empty, error) { s.log.Debug("InstallUpdate") go func() { @@ -579,7 +579,7 @@ func (s *Service) InstallUpdate(ctx context.Context, _ *emptypb.Empty) (*emptypb return &emptypb.Empty{}, nil } -func (s *Service) SetIsAutomaticUpdateOn(ctx context.Context, isOn *wrapperspb.BoolValue) (*emptypb.Empty, error) { +func (s *Service) SetIsAutomaticUpdateOn(_ context.Context, isOn *wrapperspb.BoolValue) (*emptypb.Empty, error) { s.log.WithField("isOn", isOn.Value).Debug("SetIsAutomaticUpdateOn") if currentlyOn := s.bridge.GetAutoUpdate(); currentlyOn == isOn.Value { @@ -594,19 +594,19 @@ func (s *Service) SetIsAutomaticUpdateOn(ctx context.Context, isOn *wrapperspb.B return &emptypb.Empty{}, nil } -func (s *Service) IsAutomaticUpdateOn(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.BoolValue, error) { +func (s *Service) IsAutomaticUpdateOn(_ context.Context, _ *emptypb.Empty) (*wrapperspb.BoolValue, error) { s.log.Debug("IsAutomaticUpdateOn") return wrapperspb.Bool(s.bridge.GetAutoUpdate()), nil } -func (s *Service) DiskCachePath(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { +func (s *Service) DiskCachePath(_ context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { s.log.Debug("DiskCachePath") return wrapperspb.String(s.bridge.GetGluonCacheDir()), nil } -func (s *Service) SetDiskCachePath(ctx context.Context, newPath *wrapperspb.StringValue) (*emptypb.Empty, error) { +func (s *Service) SetDiskCachePath(_ context.Context, newPath *wrapperspb.StringValue) (*emptypb.Empty, error) { s.log.WithField("path", newPath.Value).Debug("setDiskCachePath") go func() { @@ -637,7 +637,7 @@ func (s *Service) SetDiskCachePath(ctx context.Context, newPath *wrapperspb.Stri return &emptypb.Empty{}, nil } -func (s *Service) SetIsDoHEnabled(ctx context.Context, isEnabled *wrapperspb.BoolValue) (*emptypb.Empty, error) { +func (s *Service) SetIsDoHEnabled(_ context.Context, isEnabled *wrapperspb.BoolValue) (*emptypb.Empty, error) { s.log.WithField("isEnabled", isEnabled.Value).Debug("SetIsDohEnabled") if err := s.bridge.SetProxyAllowed(isEnabled.Value); err != nil { @@ -648,7 +648,7 @@ func (s *Service) SetIsDoHEnabled(ctx context.Context, isEnabled *wrapperspb.Boo return &emptypb.Empty{}, nil } -func (s *Service) IsDoHEnabled(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.BoolValue, error) { +func (s *Service) IsDoHEnabled(_ context.Context, _ *emptypb.Empty) (*wrapperspb.BoolValue, error) { s.log.Debug("IsDohEnabled") return wrapperspb.Bool(s.bridge.GetProxyAllowed()), nil @@ -715,19 +715,19 @@ func (s *Service) SetMailServerSettings(_ context.Context, settings *ImapSmtpSet return &emptypb.Empty{}, nil } -func (s *Service) Hostname(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { +func (s *Service) Hostname(_ context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { s.log.Debug("Hostname") return wrapperspb.String(constants.Host), nil } -func (s *Service) IsPortFree(ctx context.Context, port *wrapperspb.Int32Value) (*wrapperspb.BoolValue, error) { +func (s *Service) IsPortFree(_ context.Context, port *wrapperspb.Int32Value) (*wrapperspb.BoolValue, error) { s.log.Debug("IsPortFree") return wrapperspb.Bool(ports.IsPortFree(int(port.Value))), nil } -func (s *Service) AvailableKeychains(ctx context.Context, _ *emptypb.Empty) (*AvailableKeychainsResponse, error) { +func (s *Service) AvailableKeychains(_ context.Context, _ *emptypb.Empty) (*AvailableKeychainsResponse, error) { s.log.Debug("AvailableKeychains") return &AvailableKeychainsResponse{Keychains: maps.Keys(keychain.Helpers)}, nil @@ -757,7 +757,7 @@ func (s *Service) SetCurrentKeychain(ctx context.Context, keychain *wrapperspb.S return &emptypb.Empty{}, nil } -func (s *Service) CurrentKeychain(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { +func (s *Service) CurrentKeychain(_ context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) { s.log.Debug("CurrentKeychain") helper, err := s.bridge.GetKeychainApp() diff --git a/internal/frontend/grpc/service_user.go b/internal/frontend/grpc/service_user.go index 8a72c985..91473c60 100644 --- a/internal/frontend/grpc/service_user.go +++ b/internal/frontend/grpc/service_user.go @@ -28,7 +28,7 @@ import ( "google.golang.org/protobuf/types/known/wrapperspb" ) -func (s *Service) GetUserList(ctx context.Context, _ *emptypb.Empty) (*UserListResponse, error) { +func (s *Service) GetUserList(_ context.Context, _ *emptypb.Empty) (*UserListResponse, error) { s.log.Debug("GetUserList") userIDs := s.bridge.GetUserIDs() @@ -51,7 +51,7 @@ func (s *Service) GetUserList(ctx context.Context, _ *emptypb.Empty) (*UserListR return &UserListResponse{Users: userList}, nil } -func (s *Service) GetUser(ctx context.Context, userID *wrapperspb.StringValue) (*User, error) { +func (s *Service) GetUser(_ context.Context, userID *wrapperspb.StringValue) (*User, error) { s.log.WithField("userID", userID).Debug("GetUser") user, err := s.bridge.GetUserInfo(userID.Value) @@ -62,7 +62,7 @@ func (s *Service) GetUser(ctx context.Context, userID *wrapperspb.StringValue) ( return grpcUserFromInfo(user), nil } -func (s *Service) SetUserSplitMode(ctx context.Context, splitMode *UserSplitModeRequest) (*emptypb.Empty, error) { +func (s *Service) SetUserSplitMode(_ context.Context, splitMode *UserSplitModeRequest) (*emptypb.Empty, error) { s.log.WithField("UserID", splitMode.UserID).WithField("Active", splitMode.Active).Debug("SetUserSplitMode") user, err := s.bridge.GetUserInfo(splitMode.UserID) @@ -96,7 +96,7 @@ func (s *Service) SetUserSplitMode(ctx context.Context, splitMode *UserSplitMode return &emptypb.Empty{}, nil } -func (s *Service) SendBadEventUserFeedback(ctx context.Context, feedback *UserBadEventFeedbackRequest) (*emptypb.Empty, error) { +func (s *Service) SendBadEventUserFeedback(_ context.Context, feedback *UserBadEventFeedbackRequest) (*emptypb.Empty, error) { l := s.log.WithField("UserID", feedback.UserID).WithField("doResync", feedback.DoResync) l.Debug("SendBadEventUserFeedback") @@ -114,7 +114,7 @@ func (s *Service) SendBadEventUserFeedback(ctx context.Context, feedback *UserBa return &emptypb.Empty{}, nil } -func (s *Service) LogoutUser(ctx context.Context, userID *wrapperspb.StringValue) (*emptypb.Empty, error) { +func (s *Service) LogoutUser(_ context.Context, userID *wrapperspb.StringValue) (*emptypb.Empty, error) { s.log.WithField("UserID", userID.Value).Debug("LogoutUser") if _, err := s.bridge.GetUserInfo(userID.Value); err != nil { @@ -132,7 +132,7 @@ func (s *Service) LogoutUser(ctx context.Context, userID *wrapperspb.StringValue return &emptypb.Empty{}, nil } -func (s *Service) RemoveUser(ctx context.Context, userID *wrapperspb.StringValue) (*emptypb.Empty, error) { +func (s *Service) RemoveUser(_ context.Context, userID *wrapperspb.StringValue) (*emptypb.Empty, error) { s.log.WithField("UserID", userID.Value).Debug("RemoveUser") go func() { @@ -147,7 +147,7 @@ func (s *Service) RemoveUser(ctx context.Context, userID *wrapperspb.StringValue return &emptypb.Empty{}, nil } -func (s *Service) ConfigureUserAppleMail(ctx context.Context, request *ConfigureAppleMailRequest) (*emptypb.Empty, error) { +func (s *Service) ConfigureUserAppleMail(_ context.Context, request *ConfigureAppleMailRequest) (*emptypb.Empty, error) { s.log.WithField("UserID", request.UserID).WithField("Address", request.Address).Debug("ConfigureUserAppleMail") sslWasEnabled := s.bridge.GetSMTPSSL() diff --git a/internal/sentry/reporter.go b/internal/sentry/reporter.go index 1ceb084c..2b69b4ad 100644 --- a/internal/sentry/reporter.go +++ b/internal/sentry/reporter.go @@ -203,7 +203,7 @@ func SkipDuringUnwind() { } // EnhanceSentryEvent swaps type with value and removes panic handlers from the stacktrace. -func EnhanceSentryEvent(event *sentry.Event, hint *sentry.EventHint) *sentry.Event { +func EnhanceSentryEvent(event *sentry.Event, _ *sentry.EventHint) *sentry.Event { for idx, exception := range event.Exception { exception.Type, exception.Value = exception.Value, exception.Type if exception.Stacktrace != nil { diff --git a/internal/updater/install_darwin.go b/internal/updater/install_darwin.go index 45e07b58..c55420ca 100644 --- a/internal/updater/install_darwin.go +++ b/internal/updater/install_darwin.go @@ -62,6 +62,6 @@ func (i *InstallerDarwin) InstallUpdate(_ *semver.Version, r io.Reader) error { return syncFolders(oldBundle, newBundle) } -func (i *InstallerDarwin) IsAlreadyInstalled(version *semver.Version) bool { +func (i *InstallerDarwin) IsAlreadyInstalled(_ *semver.Version) bool { return false } diff --git a/internal/user/events.go b/internal/user/events.go index 35ee921c..760d678d 100644 --- a/internal/user/events.go +++ b/internal/user/events.go @@ -394,7 +394,7 @@ func (user *User) handleLabelEvents(ctx context.Context, labelEvents []proton.La return nil } -func (user *User) handleCreateLabelEvent(ctx context.Context, event proton.LabelEvent) ([]imap.Update, error) { //nolint:unparam +func (user *User) handleCreateLabelEvent(_ context.Context, event proton.LabelEvent) ([]imap.Update, error) { //nolint:unparam return safe.LockRetErr(func() ([]imap.Update, error) { var updates []imap.Update @@ -480,7 +480,7 @@ func (user *User) handleUpdateLabelEvent(ctx context.Context, event proton.Label }, user.apiLabelsLock, user.updateChLock) } -func (user *User) handleDeleteLabelEvent(ctx context.Context, event proton.LabelEvent) ([]imap.Update, error) { //nolint:unparam +func (user *User) handleDeleteLabelEvent(_ context.Context, event proton.LabelEvent) ([]imap.Update, error) { //nolint:unparam return safe.LockRetErr(func() ([]imap.Update, error) { var updates []imap.Update @@ -643,7 +643,7 @@ func (user *User) handleCreateMessageEvent(ctx context.Context, message proton.M }, user.apiUserLock, user.apiAddrsLock, user.apiLabelsLock, user.updateChLock) } -func (user *User) handleUpdateMessageEvent(ctx context.Context, message proton.MessageMetadata) ([]imap.Update, error) { //nolint:unparam +func (user *User) handleUpdateMessageEvent(_ context.Context, message proton.MessageMetadata) ([]imap.Update, error) { //nolint:unparam return safe.RLockRetErr(func() ([]imap.Update, error) { user.log.WithFields(logrus.Fields{ "messageID": message.ID, @@ -680,7 +680,7 @@ func (user *User) handleUpdateMessageEvent(ctx context.Context, message proton.M }, user.apiLabelsLock, user.updateChLock) } -func (user *User) handleDeleteMessageEvent(ctx context.Context, event proton.MessageEvent) ([]imap.Update, error) { //nolint:unparam +func (user *User) handleDeleteMessageEvent(_ context.Context, event proton.MessageEvent) ([]imap.Update, error) { return safe.RLockRetErr(func() ([]imap.Update, error) { user.log.WithField("messageID", event.ID).Info("Handling message deleted event") @@ -696,7 +696,7 @@ func (user *User) handleDeleteMessageEvent(ctx context.Context, event proton.Mes }, user.updateChLock) } -func (user *User) handleUpdateDraftEvent(ctx context.Context, event proton.MessageEvent) ([]imap.Update, error) { //nolint:unparam +func (user *User) handleUpdateDraftEvent(ctx context.Context, event proton.MessageEvent) ([]imap.Update, error) { return safe.RLockRetErr(func() ([]imap.Update, error) { user.log.WithFields(logrus.Fields{ "messageID": event.ID, diff --git a/internal/user/imap.go b/internal/user/imap.go index 1c678495..97841a4d 100644 --- a/internal/user/imap.go +++ b/internal/user/imap.go @@ -270,7 +270,7 @@ func (conn *imapConnector) CreateMessage( mailboxID imap.MailboxID, literal []byte, flags imap.FlagSet, - date time.Time, + _ time.Time, ) (imap.Message, []byte, error) { defer conn.goPollAPIEvents(false) @@ -435,11 +435,11 @@ func (conn *imapConnector) MoveMessages(ctx context.Context, messageIDs []imap.M var result bool if v, ok := conn.apiLabels[string(labelFromID)]; ok && v.Type == proton.LabelTypeLabel { - result = result || true + result = true } if v, ok := conn.apiLabels[string(labelToID)]; ok && (v.Type == proton.LabelTypeFolder || v.Type == proton.LabelTypeSystem) { - result = result || true + result = true } return result @@ -505,7 +505,7 @@ func (conn *imapConnector) GetMailboxVisibility(_ context.Context, mailboxID ima } // Close the connector will no longer be used and all resources should be closed/released. -func (conn *imapConnector) Close(ctx context.Context) error { +func (conn *imapConnector) Close(_ context.Context) error { return nil } @@ -520,7 +520,7 @@ func (conn *imapConnector) importMessage( if err := safe.RLockRet(func() error { return withAddrKR(conn.apiUser, conn.apiAddrs[conn.addrID], conn.vault.KeyPass(), func(_, addrKR *crypto.KeyRing) error { - messageID := "" + var messageID string if slices.Contains(labelIDs, proton.DraftsLabel) { msg, err := conn.createDraft(ctx, literal, addrKR, conn.apiAddrs[conn.addrID]) diff --git a/internal/user/smtp_default.go b/internal/user/smtp_default.go index 0f048d10..11bb8ded 100644 --- a/internal/user/smtp_default.go +++ b/internal/user/smtp_default.go @@ -19,6 +19,6 @@ package user -func debugDumpToDisk(b []byte) error { +func debugDumpToDisk(_ []byte) error { return nil } diff --git a/internal/user/sync.go b/internal/user/sync.go index d3da5d8f..55012a32 100644 --- a/internal/user/sync.go +++ b/internal/user/sync.go @@ -572,10 +572,10 @@ func (user *User) syncMessages( // We could sync a placeholder message here, but for now we skip it entirely. continue - } else { - if err := vault.RemFailedMessageID(res.messageID); err != nil { - logrus.WithError(err).Error("Failed to remove failed message ID") - } + } + + if err := vault.RemFailedMessageID(res.messageID); err != nil { + logrus.WithError(err).Error("Failed to remove failed message ID") } targetInfo := addressToIndex[res.addressID] diff --git a/internal/vault/types_file.go b/internal/vault/types_file.go index 6781114d..99da52e8 100644 --- a/internal/vault/types_file.go +++ b/internal/vault/types_file.go @@ -48,11 +48,7 @@ func unmarshalFile[T any](gcm cipher.AEAD, b []byte, data *T) error { } } - if err := msgpack.Unmarshal(dec, data); err != nil { - return err - } - - return nil + return msgpack.Unmarshal(dec, data) } func marshalFile[T any](gcm cipher.AEAD, t T) ([]byte, error) { diff --git a/internal/versioner/remove_darwin.go b/internal/versioner/remove_darwin.go index 3ffe26c0..6bcc20e6 100644 --- a/internal/versioner/remove_darwin.go +++ b/internal/versioner/remove_darwin.go @@ -29,7 +29,7 @@ func (v *Versioner) RemoveOldVersions() error { } // RemoveOtherVersions removes all but the specific provided app version. -func (v *Versioner) RemoveOtherVersions(versionToKeep *semver.Version) error { +func (v *Versioner) RemoveOtherVersions(_ *semver.Version) error { // darwin does not use the versioner; removal is a noop. return nil } diff --git a/pkg/message/build.go b/pkg/message/build.go index 5e7e44bb..baf916ee 100644 --- a/pkg/message/build.go +++ b/pkg/message/build.go @@ -92,11 +92,7 @@ func buildSimpleRFC822(kr *crypto.KeyRing, msg proton.Message, opts JobOptions, return err } - if err := w.Close(); err != nil { - return err - } - - return nil + return w.Close() } func buildMultipartRFC822( @@ -148,11 +144,7 @@ func buildMultipartRFC822( } } - if err := w.Close(); err != nil { - return err - } - - return nil + return w.Close() } func writeTextPart( @@ -319,11 +311,7 @@ func buildPGPMIMEFallbackRFC822(msg proton.Message, opts JobOptions, buf *bytes. return err } - if err := w.Close(); err != nil { - return err - } - - return nil + return w.Close() } func writeMultipartSignedRFC822(header message.Header, body []byte, sig proton.Signature, buf *bytes.Buffer) error { @@ -379,11 +367,7 @@ func writeMultipartSignedRFC822(header message.Header, body []byte, sig proton.S return err } - if err := mw.Close(); err != nil { - return err - } - - return nil + return mw.Close() } func writeMultipartEncryptedRFC822(header message.Header, body []byte, buf *bytes.Buffer) error { diff --git a/pkg/message/parser_test.go b/pkg/message/parser_test.go index de28aed0..981c06a9 100644 --- a/pkg/message/parser_test.go +++ b/pkg/message/parser_test.go @@ -673,7 +673,7 @@ func TestParsePanic(t *testing.T) { require.Error(t, err) } -func TestParseTextPlainWithPdfttachmentCyrillic(t *testing.T) { +func TestParseTextPlainWithPdfAttachmentCyrillic(t *testing.T) { f := getFileReader("text_plain_pdf_attachment_cyrillic.eml") m, err := Parse(f) @@ -718,6 +718,6 @@ func getFileReader(filename string) io.Reader { type panicReader struct{} -func (panicReader) Read(p []byte) (int, error) { +func (panicReader) Read(_ []byte) (int, error) { panic("lol") } diff --git a/tests/ctx_bridge_test.go b/tests/ctx_bridge_test.go index 0afe93d7..5c62b0bf 100644 --- a/tests/ctx_bridge_test.go +++ b/tests/ctx_bridge_test.go @@ -351,8 +351,8 @@ func (t *testCtx) expectProxyCtlAllowProxy() { type mockRestarter struct{} -func (m *mockRestarter) Set(restart, crash bool) {} +func (m *mockRestarter) Set(_, _ bool) {} -func (m *mockRestarter) AddFlags(flags ...string) {} +func (m *mockRestarter) AddFlags(_ ...string) {} -func (m *mockRestarter) Override(exe string) {} +func (m *mockRestarter) Override(_ string) {} diff --git a/tests/fast.go b/tests/fast.go index 84befbeb..e08283a6 100644 --- a/tests/fast.go +++ b/tests/fast.go @@ -28,7 +28,7 @@ var ( preCompKeyPEM []byte ) -func FastGenerateCert(template *x509.Certificate) ([]byte, []byte, error) { +func FastGenerateCert(_ *x509.Certificate) ([]byte, []byte, error) { return preCompCertPEM, preCompKeyPEM, nil } diff --git a/tests/imap_test.go b/tests/imap_test.go index 155b6e37..ab17cddc 100644 --- a/tests/imap_test.go +++ b/tests/imap_test.go @@ -470,7 +470,7 @@ func (s *scenario) imapClientAppendsToMailbox(clientID string, file, mailbox str return nil } -func (s *scenario) imapClientsMoveMessageWithSubjectUserFromToByOrderedOperations(sourceIMAPClient, targetIMAPClient, messageSubject, bddUserID, targetMailboxName, op1, op2, op3 string) error { +func (s *scenario) imapClientsMoveMessageWithSubjectUserFromToByOrderedOperations(sourceIMAPClient, targetIMAPClient, messageSubject, _, targetMailboxName, op1, op2, op3 string) error { // call NOOP to prevent unilateral updates in following FETCH _, sourceClient := s.t.getIMAPClient(sourceIMAPClient) _, targetClient := s.t.getIMAPClient(targetIMAPClient)