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 <danny@alcion.ai>
This commit is contained in:
parent
da8ff3c267
commit
395c7c8525
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -58,10 +58,6 @@ jobs:
|
|||||||
- name: Run go-licenses
|
- name: Run go-licenses
|
||||||
run: go-licenses check github.com/alcionai/corso --ignore github.com/alcionai/corso
|
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
|
# AWS creds
|
||||||
- name: Configure AWS credentials from Test account
|
- name: Configure AWS credentials from Test account
|
||||||
uses: aws-actions/configure-aws-credentials@v1
|
uses: aws-actions/configure-aws-credentials@v1
|
||||||
|
|||||||
1
.github/workflows/lint.yml
vendored
1
.github/workflows/lint.yml
vendored
@ -48,5 +48,4 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
version: v1.45.2
|
version: v1.45.2
|
||||||
working-directory: ./src
|
working-directory: ./src
|
||||||
args: --timeout=15m
|
|
||||||
skip-pkg-cache: true
|
skip-pkg-cache: true
|
||||||
|
|||||||
7
src/.golangci.yml
Normal file
7
src/.golangci.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
run:
|
||||||
|
timeout: 15m
|
||||||
|
|
||||||
|
linters:
|
||||||
|
enable:
|
||||||
|
- gofmt
|
||||||
|
- misspell
|
||||||
@ -179,7 +179,7 @@ func exchangeBackupCreateSelectors(all bool, users, data []string) selectors.Sel
|
|||||||
|
|
||||||
func validateExchangeBackupCreateFlags(all bool, users, data []string) error {
|
func validateExchangeBackupCreateFlags(all bool, users, data []string) error {
|
||||||
if len(users) == 0 && !all {
|
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 {
|
if len(data) > 0 && all {
|
||||||
return errors.New("--all does a backup on all data, and cannot be reduced with --data")
|
return errors.New("--all does a backup on all data, and cannot be reduced with --data")
|
||||||
@ -370,7 +370,7 @@ func validateExchangeBackupDetailFlags(
|
|||||||
backupID string,
|
backupID string,
|
||||||
) error {
|
) error {
|
||||||
if len(backupID) == 0 {
|
if len(backupID) == 0 {
|
||||||
return errors.New("a backup ID is requried")
|
return errors.New("a backup ID is required")
|
||||||
}
|
}
|
||||||
lu := len(users)
|
lu := len(users)
|
||||||
lc, lcf := len(contacts), len(contactFolders)
|
lc, lcf := len(contacts), len(contactFolders)
|
||||||
@ -381,7 +381,7 @@ func validateExchangeBackupDetailFlags(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if lu == 0 {
|
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 {
|
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")
|
return errors.New("one or more --contact-folder ids or the wildcard --contact-folder * must be included to specify a --contact")
|
||||||
|
|||||||
@ -61,7 +61,7 @@ func configureAccount(vpr *viper.Viper, readConfigFromViper bool, overrides map[
|
|||||||
TenantID: first(overrides[account.TenantID], m365Cfg.TenantID, os.Getenv(account.TenantID)),
|
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{
|
if err := utils.RequireProps(map[string]string{
|
||||||
credentials.ClientID: m365Cfg.ClientID,
|
credentials.ClientID: m365Cfg.ClientID,
|
||||||
credentials.ClientSecret: m365Cfg.ClientSecret,
|
credentials.ClientSecret: m365Cfg.ClientSecret,
|
||||||
|
|||||||
@ -75,7 +75,7 @@ func configureStorage(vpr *viper.Viper, readConfigFromViper bool, overrides map[
|
|||||||
Corso: corso,
|
Corso: corso,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure requried properties are present
|
// ensure required properties are present
|
||||||
if err := utils.RequireProps(map[string]string{
|
if err := utils.RequireProps(map[string]string{
|
||||||
credentials.AWSAccessKeyID: aws.AccessKey,
|
credentials.AWSAccessKeyID: aws.AccessKey,
|
||||||
storage.Bucket: s3Cfg.Bucket,
|
storage.Bucket: s3Cfg.Bucket,
|
||||||
|
|||||||
@ -121,7 +121,7 @@ func exchangeRestoreSelectors(u, f, m string) selectors.Selector {
|
|||||||
|
|
||||||
func validateRestoreFlags(u, f, m, rpid string) error {
|
func validateRestoreFlags(u, f, m, rpid string) error {
|
||||||
if len(rpid) == 0 {
|
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)
|
lu, lf, lm := len(u), len(f), len(m)
|
||||||
if (lu == 0 || u == "*") && (lf+lm > 0) {
|
if (lu == 0 || u == "*") && (lf+lm > 0) {
|
||||||
|
|||||||
@ -72,7 +72,7 @@ func ListErrors(multi multierror.Error) string {
|
|||||||
return aString
|
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
|
// strings to the originalMessage iff the pointer is not nil
|
||||||
func concatenateStringFromPointers(orig string, pointers []*string) string {
|
func concatenateStringFromPointers(orig string, pointers []*string) string {
|
||||||
for _, pointer := range pointers {
|
for _, pointer := range pointers {
|
||||||
@ -94,7 +94,7 @@ func ConnectorStackErrorTrace(e error) string {
|
|||||||
// target *string
|
// target *string
|
||||||
// code *string
|
// code *string
|
||||||
// details ErrorDetailsable
|
// details ErrorDetailsable
|
||||||
// Ignoring Additonal Detail
|
// Ignoring Additional Detail
|
||||||
code := mainErr.GetCode()
|
code := mainErr.GetCode()
|
||||||
subject := mainErr.GetMessage()
|
subject := mainErr.GetMessage()
|
||||||
target := mainErr.GetTarget()
|
target := mainErr.GetTarget()
|
||||||
|
|||||||
@ -20,7 +20,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Account defines an account provider, along with any credentials
|
// 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 {
|
type Account struct {
|
||||||
Provider accountProvider
|
Provider accountProvider
|
||||||
Config map[string]string
|
Config map[string]string
|
||||||
|
|||||||
@ -155,7 +155,7 @@ func (r Repository) NewRestore(
|
|||||||
sel)
|
sel)
|
||||||
}
|
}
|
||||||
|
|
||||||
// backups lists backups in a respository
|
// backups lists backups in a repository
|
||||||
func (r Repository) Backups(ctx context.Context) ([]backup.Backup, error) {
|
func (r Repository) Backups(ctx context.Context) ([]backup.Backup, error) {
|
||||||
sw := store.NewKopiaStore(r.modelStore)
|
sw := store.NewKopiaStore(r.modelStore)
|
||||||
return sw.GetBackups(ctx)
|
return sw.GetBackups(ctx)
|
||||||
|
|||||||
@ -543,7 +543,7 @@ func (suite *ExchangeSourceSuite) TestExchangeScope_MatchesPath() {
|
|||||||
{"all user's items", es.Users(Any()), assert.True},
|
{"all user's items", es.Users(Any()), assert.True},
|
||||||
{"no user's items", es.Users(None()), assert.False},
|
{"no user's items", es.Users(None()), assert.False},
|
||||||
{"matching user", es.Users([]string{usr}), assert.True},
|
{"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},
|
{"one of multiple users", es.Users([]string{"smarf", usr}), assert.True},
|
||||||
{"all folders", es.MailFolders(Any(), Any()), assert.True},
|
{"all folders", es.MailFolders(Any(), Any()), assert.True},
|
||||||
{"no folders", es.MailFolders(Any(), None()), assert.False},
|
{"no folders", es.MailFolders(Any(), None()), assert.False},
|
||||||
|
|||||||
@ -29,7 +29,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Storage defines a storage provider, along with any configuration
|
// 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 {
|
type Storage struct {
|
||||||
Provider storageProvider
|
Provider storageProvider
|
||||||
Config map[string]string
|
Config map[string]string
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user