From 395c7c8525430b8aabe48d5eb7b0d552060958f0 Mon Sep 17 00:00:00 2001 From: ashmrtn <3891298+ashmrtn@users.noreply.github.com> Date: Fri, 22 Jul 2022 11:28:25 -0700 Subject: [PATCH] Add spell check linter and run gofmt in golangci-lint (#396) * Basic golangci-lint config with gofmt and timeout Remove corresponding sections from other CI config files. * Enable comment and string spelling linter * Fix spelling mistakes for linter Co-authored-by: Danny --- .github/workflows/ci.yml | 4 ---- .github/workflows/lint.yml | 1 - src/.golangci.yml | 7 +++++++ src/cli/backup/exchange.go | 6 +++--- src/cli/config/account.go | 2 +- src/cli/config/storage.go | 2 +- src/cli/restore/exchange.go | 2 +- src/internal/connector/support/errors.go | 4 ++-- src/pkg/account/account.go | 2 +- src/pkg/repository/repository.go | 2 +- src/pkg/selectors/exchange_test.go | 2 +- src/pkg/storage/storage.go | 2 +- 12 files changed, 19 insertions(+), 17 deletions(-) create mode 100644 src/.golangci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f38ada33..f5ccc8b09 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,10 +58,6 @@ jobs: - name: Run go-licenses run: go-licenses check github.com/alcionai/corso --ignore github.com/alcionai/corso - # gofmt - - name: Run gofmt - run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi - # AWS creds - name: Configure AWS credentials from Test account uses: aws-actions/configure-aws-credentials@v1 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 412467082..6a139f5d5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -48,5 +48,4 @@ jobs: with: version: v1.45.2 working-directory: ./src - args: --timeout=15m skip-pkg-cache: true diff --git a/src/.golangci.yml b/src/.golangci.yml new file mode 100644 index 000000000..01e3b8faf --- /dev/null +++ b/src/.golangci.yml @@ -0,0 +1,7 @@ +run: + timeout: 15m + +linters: + enable: + - gofmt + - misspell diff --git a/src/cli/backup/exchange.go b/src/cli/backup/exchange.go index 47e39f677..0e3113734 100644 --- a/src/cli/backup/exchange.go +++ b/src/cli/backup/exchange.go @@ -179,7 +179,7 @@ func exchangeBackupCreateSelectors(all bool, users, data []string) selectors.Sel func validateExchangeBackupCreateFlags(all bool, users, data []string) error { if len(users) == 0 && !all { - return errors.New("requries one or more --user ids, the wildcard --user *, or the --all flag.") + return errors.New("requires one or more --user ids, the wildcard --user *, or the --all flag.") } if len(data) > 0 && all { return errors.New("--all does a backup on all data, and cannot be reduced with --data") @@ -370,7 +370,7 @@ func validateExchangeBackupDetailFlags( backupID string, ) error { if len(backupID) == 0 { - return errors.New("a backup ID is requried") + return errors.New("a backup ID is required") } lu := len(users) lc, lcf := len(contacts), len(contactFolders) @@ -381,7 +381,7 @@ func validateExchangeBackupDetailFlags( return nil } if lu == 0 { - return errors.New("requries one or more --user ids, the wildcard --user *, or the --all flag.") + return errors.New("requires one or more --user ids, the wildcard --user *, or the --all flag.") } if lc > 0 && lcf == 0 { return errors.New("one or more --contact-folder ids or the wildcard --contact-folder * must be included to specify a --contact") diff --git a/src/cli/config/account.go b/src/cli/config/account.go index ded37d6a6..cb7f8418f 100644 --- a/src/cli/config/account.go +++ b/src/cli/config/account.go @@ -61,7 +61,7 @@ func configureAccount(vpr *viper.Viper, readConfigFromViper bool, overrides map[ TenantID: first(overrides[account.TenantID], m365Cfg.TenantID, os.Getenv(account.TenantID)), } - // ensure requried properties are present + // ensure required properties are present if err := utils.RequireProps(map[string]string{ credentials.ClientID: m365Cfg.ClientID, credentials.ClientSecret: m365Cfg.ClientSecret, diff --git a/src/cli/config/storage.go b/src/cli/config/storage.go index da3e96b7a..068d7476d 100644 --- a/src/cli/config/storage.go +++ b/src/cli/config/storage.go @@ -75,7 +75,7 @@ func configureStorage(vpr *viper.Viper, readConfigFromViper bool, overrides map[ Corso: corso, } - // ensure requried properties are present + // ensure required properties are present if err := utils.RequireProps(map[string]string{ credentials.AWSAccessKeyID: aws.AccessKey, storage.Bucket: s3Cfg.Bucket, diff --git a/src/cli/restore/exchange.go b/src/cli/restore/exchange.go index dc2dfa72f..6df9f7e0f 100644 --- a/src/cli/restore/exchange.go +++ b/src/cli/restore/exchange.go @@ -121,7 +121,7 @@ func exchangeRestoreSelectors(u, f, m string) selectors.Selector { func validateRestoreFlags(u, f, m, rpid string) error { if len(rpid) == 0 { - return errors.New("a restore point ID is requried") + return errors.New("a restore point ID is required") } lu, lf, lm := len(u), len(f), len(m) if (lu == 0 || u == "*") && (lf+lm > 0) { diff --git a/src/internal/connector/support/errors.go b/src/internal/connector/support/errors.go index ec8cb0c62..fbff81a58 100644 --- a/src/internal/connector/support/errors.go +++ b/src/internal/connector/support/errors.go @@ -72,7 +72,7 @@ func ListErrors(multi multierror.Error) string { return aString } -// concatenateStringFromPointers is a helper funtion that adds +// concatenateStringFromPointers is a helper function that adds // strings to the originalMessage iff the pointer is not nil func concatenateStringFromPointers(orig string, pointers []*string) string { for _, pointer := range pointers { @@ -94,7 +94,7 @@ func ConnectorStackErrorTrace(e error) string { // target *string // code *string // details ErrorDetailsable - // Ignoring Additonal Detail + // Ignoring Additional Detail code := mainErr.GetCode() subject := mainErr.GetMessage() target := mainErr.GetTarget() diff --git a/src/pkg/account/account.go b/src/pkg/account/account.go index dce9fb55c..a1ffb907c 100644 --- a/src/pkg/account/account.go +++ b/src/pkg/account/account.go @@ -20,7 +20,7 @@ var ( ) // Account defines an account provider, along with any credentials -// and identifiers requried to set up or communicate with that provider. +// and identifiers required to set up or communicate with that provider. type Account struct { Provider accountProvider Config map[string]string diff --git a/src/pkg/repository/repository.go b/src/pkg/repository/repository.go index 71fbab84a..e03f64cba 100644 --- a/src/pkg/repository/repository.go +++ b/src/pkg/repository/repository.go @@ -155,7 +155,7 @@ func (r Repository) NewRestore( sel) } -// backups lists backups in a respository +// backups lists backups in a repository func (r Repository) Backups(ctx context.Context) ([]backup.Backup, error) { sw := store.NewKopiaStore(r.modelStore) return sw.GetBackups(ctx) diff --git a/src/pkg/selectors/exchange_test.go b/src/pkg/selectors/exchange_test.go index 59efb0620..368c6c6de 100644 --- a/src/pkg/selectors/exchange_test.go +++ b/src/pkg/selectors/exchange_test.go @@ -543,7 +543,7 @@ func (suite *ExchangeSourceSuite) TestExchangeScope_MatchesPath() { {"all user's items", es.Users(Any()), assert.True}, {"no user's items", es.Users(None()), assert.False}, {"matching user", es.Users([]string{usr}), assert.True}, - {"non-maching user", es.Users([]string{"smarf"}), assert.False}, + {"non-matching user", es.Users([]string{"smarf"}), assert.False}, {"one of multiple users", es.Users([]string{"smarf", usr}), assert.True}, {"all folders", es.MailFolders(Any(), Any()), assert.True}, {"no folders", es.MailFolders(Any(), None()), assert.False}, diff --git a/src/pkg/storage/storage.go b/src/pkg/storage/storage.go index 484df2d47..c1730994e 100644 --- a/src/pkg/storage/storage.go +++ b/src/pkg/storage/storage.go @@ -29,7 +29,7 @@ const ( ) // Storage defines a storage provider, along with any configuration -// requried to set up or communicate with that provider. +// required to set up or communicate with that provider. type Storage struct { Provider storageProvider Config map[string]string