Skip to content

Commit

Permalink
activated nlreturn lint
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsky committed Apr 18, 2021
1 parent ac69ce1 commit 1359f88
Show file tree
Hide file tree
Showing 26 changed files with 95 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ linters:
disable:
- cyclop
- exhaustivestruct
- forbidigo
- funlen
- gci
- gofumpt
- ifshort
- interfacer
- lll
- nlreturn
- maligned
- paralleltest
- scopelint
- testpackage
- thelper
- wrapcheck
3 changes: 3 additions & 0 deletions internal/clicommand/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@ func newCheckCmd() *checkCmd {

if err := context.NewInterrupt().Run(ctx, func() error {
log.Info(color.New(color.Bold).Sprint("checking config:"))

return defaults.Pipe{}.Run(ctx)
}); err != nil {
log.WithError(err).Error(color.New(color.Bold).Sprintf("config is invalid"))

return fmt.Errorf("invalid config: %w", err)
}

log.Info(color.New(color.Bold).Sprintf("config is valid"))

return nil
},
}
Expand Down
1 change: 1 addition & 0 deletions internal/clicommand/completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func newCompletionsCmd() *completionsCmd {
case "powershell":
return cmd.Root().GenPowerShellCompletion(os.Stdout)
}

return ErrUnsupportedShell
},
}
Expand Down
2 changes: 2 additions & 0 deletions internal/clicommand/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ More info: https://developer.apple.com/documentation/appstoreconnectapi/creating
}

log.Info(color.New(color.Bold).Sprintf("release succeeded after %0.2fs", time.Since(start).Seconds()))

return nil
},
}
Expand Down Expand Up @@ -269,6 +270,7 @@ func releaseProject(options releaseOpts) (*context.Context, error) {
return err
}
}

return nil
})
}
Expand Down
3 changes: 3 additions & 0 deletions internal/clicommand/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ func Execute(version string, exit func(int), args []string) {

log.SetHandler(cli.Default)

// nolint: forbidigo
fmt.Println()
// nolint: forbidigo
defer fmt.Println()

NewRoot(version, exit).Execute(args)
}

Expand Down
1 change: 1 addition & 0 deletions internal/client/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (c *ascClient) UploadRoutingCoverage(ctx *context.Context, versionID string

commit := func(id string, checksum string) error {
_, _, err := c.client.Apps.CommitRoutingAppCoverage(ctx, id, asc.Bool(true), &checksum)

return err
}

Expand Down
1 change: 1 addition & 0 deletions internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ type Client interface {
// New returns a new Client.
func New(ctx *context.Context) Client {
client := asc.NewClient(ctx.Credentials.Client())

return &ascClient{client: client}
}

Expand Down
10 changes: 10 additions & 0 deletions internal/client/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (c *ascClient) UpdateApp(ctx *context.Context, appID string, appInfoID stri
}

_, _, err := c.client.Apps.UpdateApp(ctx, appID, &attrs, availableTerritoryIDs, prices)

return err
})

Expand All @@ -76,6 +77,7 @@ func (c *ascClient) UpdateApp(ctx *context.Context, appID string, appInfoID stri
if _, _, err := c.client.Apps.UpdateAppInfo(ctx, appInfoID, categoriesUpdate(*config.Categories)); err != nil {
return err
}

return nil
})

Expand All @@ -90,6 +92,7 @@ func (c *ascClient) UpdateApp(ctx *context.Context, appID string, appInfoID stri
}

_, _, err = c.client.Apps.UpdateAgeRatingDeclaration(ctx, ageRatingResp.Data.ID, ageRatingDeclaration(*config.AgeRatingDeclaration))

return err
})

Expand Down Expand Up @@ -238,6 +241,7 @@ func (c *ascClient) UpdateAppLocalizations(ctx *context.Context, appID string, c

if !ok {
log.WithField("locale", locale).Debug("not in configuration. skipping...")

continue
}

Expand All @@ -250,6 +254,7 @@ func (c *ascClient) UpdateAppLocalizations(ctx *context.Context, appID string, c
PrivacyPolicyText: &locConfig.PrivacyPolicyText,
PrivacyPolicyURL: &locConfig.PrivacyPolicyURL,
})

return err
})
}
Expand All @@ -270,6 +275,7 @@ func (c *ascClient) UpdateAppLocalizations(ctx *context.Context, appID string, c
PrivacyPolicyText: &locConfig.PrivacyPolicyText,
PrivacyPolicyURL: &locConfig.PrivacyPolicyURL,
}, appInfo.ID)

return err
})
}
Expand Down Expand Up @@ -338,6 +344,7 @@ func (c *ascClient) UpdateVersionLocalizations(ctx *context.Context, versionID s

if !ok {
log.WithField("locale", locale).Debug("not in configuration. skipping...")

continue
}

Expand All @@ -349,6 +356,7 @@ func (c *ascClient) UpdateVersionLocalizations(ctx *context.Context, versionID s
if err != nil {
return err
}

return c.UpdatePreviewsAndScreenshotsIfNeeded(ctx, g, &updatedLocResp.Data, locConfig)
})
}
Expand All @@ -367,6 +375,7 @@ func (c *ascClient) UpdateVersionLocalizations(ctx *context.Context, versionID s
if err != nil {
return err
}

return c.UpdatePreviewsAndScreenshotsIfNeeded(ctx, g, &locResp.Data, locConfig)
})
}
Expand Down Expand Up @@ -543,5 +552,6 @@ func (c *ascClient) EnablePhasedRelease(ctx *context.Context, versionID string)

func (c *ascClient) SubmitApp(ctx *context.Context, versionID string) error {
_, _, err := c.client.Submission.CreateSubmission(ctx, versionID)

return err
}
23 changes: 23 additions & 0 deletions internal/client/testflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ func (c *ascClient) UpdateBetaAppLocalizations(ctx *context.Context, appID strin

if !ok {
log.WithField("locale", locale).Debug("not in configuration. skipping...")

continue
}

found[locale] = true

g.Go(func() error {
_, _, err = c.client.TestFlight.UpdateBetaAppLocalization(ctx, loc.ID, betaAppLocalizationUpdateRequestAttributes(locConfig))

return err
})
}
Expand All @@ -67,6 +69,7 @@ func (c *ascClient) UpdateBetaAppLocalizations(ctx *context.Context, appID strin

g.Go(func() error {
_, _, err = c.client.TestFlight.CreateBetaAppLocalization(ctx.Context, betaAppLocalizationCreateRequestAttributes(locale, locConfig), appID)

return err
})
}
Expand Down Expand Up @@ -130,6 +133,7 @@ func betaAppLocalizationCreateRequestAttributes(locale string, locConfig config.

func (c *ascClient) UpdateBetaBuildDetails(ctx *context.Context, buildID string, config config.Testflight) error {
_, _, err := c.client.TestFlight.UpdateBuildBetaDetail(ctx, buildID, &config.EnableAutoNotify)

return err
}

Expand All @@ -151,16 +155,19 @@ func (c *ascClient) UpdateBetaBuildLocalizations(ctx *context.Context, buildID s

if !ok {
log.WithField("locale", locale).Debug("not in configuration. skipping...")

continue
} else if locConfig.WhatsNew == "" {
log.WithField("locale", locale).Warn("skipping updating beta build localization due to empty What's New text")

continue
}

found[locale] = true

g.Go(func() error {
_, _, err := c.client.TestFlight.UpdateBetaBuildLocalization(ctx, loc.ID, &locConfig.WhatsNew)

return err
})
}
Expand All @@ -175,11 +182,13 @@ func (c *ascClient) UpdateBetaBuildLocalizations(ctx *context.Context, buildID s

if locConfig.WhatsNew == "" {
log.WithField("locale", locale).Warn("skipping updating beta build localization due to empty What's New text")

continue
}

g.Go(func() error {
_, _, err := c.client.TestFlight.CreateBetaBuildLocalization(ctx.Context, locale, &locConfig.WhatsNew, buildID)

return err
})
}
Expand Down Expand Up @@ -207,6 +216,7 @@ func (c *ascClient) AssignBetaGroups(ctx *context.Context, appID string, buildID

if len(groups) == 0 {
log.Debug("no groups in configuration")

return nil
}

Expand Down Expand Up @@ -240,11 +250,13 @@ func (c *ascClient) AssignBetaGroups(ctx *context.Context, appID string, buildID

if !ok {
log.WithField("group", name).Debug("not in configuration. skipping...")

continue
}

g.Go(func() error {
log.WithField("group", name).Debug("update beta group")

return c.updateBetaGroup(ctx, g, appID, group.ID, buildID, configGroup)
})
}
Expand All @@ -253,13 +265,15 @@ func (c *ascClient) AssignBetaGroups(ctx *context.Context, appID string, buildID
group := groups[i]
if group.Name == "" {
log.Warn("skipping a beta group with a missing name")

continue
} else if found[group.Name] {
continue
}

g.Go(func() error {
log.WithField("group", group.Name).Debug("create beta group")

return c.createBetaGroup(ctx, g, appID, buildID, group)
})
}
Expand All @@ -276,10 +290,12 @@ func (c *ascClient) updateBetaGroup(ctx *context.Context, g parallel.Group, appI
PublicLinkLimit: &group.PublicLinkLimit,
PublicLinkLimitEnabled: &group.EnablePublicLinkLimit,
})

return err
})
g.Go(func() error {
_, err := c.client.TestFlight.AddBuildsToBetaGroup(ctx, groupID, []string{buildID})

return err
})
g.Go(func() error {
Expand Down Expand Up @@ -322,13 +338,15 @@ func (c *ascClient) updateBetaTestersForGroup(ctx *context.Context, g parallel.G

g.Go(func() error {
_, err = c.client.TestFlight.AddBetaTestersToBetaGroup(ctx, groupID, betaTesterIDs)

return err
})

for i := range testers {
tester := testers[i]
if tester.Email == "" {
log.Warnf("skipping a beta tester in beta group %s with a missing email", groupID)

continue
} else if found[tester.Email] {
continue
Expand Down Expand Up @@ -362,6 +380,7 @@ func filterTestersNotInBetaGroup(testers []asc.BetaTester, groupID string) (beta
for _, rel := range tester.Relationships.BetaGroups.Data {
if rel.ID == groupID {
inGroup = true

break
}
}
Expand Down Expand Up @@ -406,6 +425,7 @@ func (c *ascClient) AssignBetaTesters(ctx *context.Context, appID string, buildI
}).
Debug("assign individual beta tester")
_, err := c.client.TestFlight.AssignSingleBetaTesterToBuilds(ctx, tester.ID, []string{buildID})

return err
})
}
Expand All @@ -414,13 +434,15 @@ func (c *ascClient) AssignBetaTesters(ctx *context.Context, appID string, buildI
tester := testers[i]
if tester.Email == "" {
log.Warn("beta tester email missing")

continue
} else if found[tester.Email] {
continue
}

g.Go(func() error {
log.WithField("email", tester.Email).Debug("create individual beta tester")

return c.createBetaTester(ctx, tester, nil, []string{buildID})
})
}
Expand Down Expand Up @@ -508,5 +530,6 @@ func (c *ascClient) UpdateBetaReviewDetails(ctx *context.Context, appID string,

func (c *ascClient) SubmitBetaApp(ctx *context.Context, buildID string) error {
_, _, err := c.client.TestFlight.CreateBetaAppReviewSubmission(ctx, buildID)

return err
}
3 changes: 1 addition & 2 deletions internal/closer/closer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ var onCloseErr closeErrFunc = func(err error) { log.Fatal(err) }

// Close closes an io.Closer and handles the possible Close error.
func Close(c io.Closer) {
err := c.Close()
if err != nil {
if err := c.Close(); err != nil {
onCloseErr(err)
}
}
1 change: 1 addition & 0 deletions internal/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func (git *Git) RunInEnv(env map[string]string, args ...string) (*shell.Complete
// IsRepo returns true if current folder is a Git repository.
func (git *Git) IsRepo() bool {
proc, err := git.Run("rev-parse", "--is-inside-work-tree")

return err == nil && strings.TrimSpace(proc.Stdout) == "true"
}

Expand Down
1 change: 1 addition & 0 deletions internal/git/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (

func newMockGit(t *testing.T, commands ...shelltest.Command) *Git {
ctx := context.New(config.Project{})

return newMockGitWithContext(ctx, t, commands...)
}

Expand Down
1 change: 1 addition & 0 deletions internal/middleware/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func ErrHandler(action Action) Action {

if pipe.IsSkip(err) {
log.WithError(err).Warn("pipe skipped")

return nil
}

Expand Down
1 change: 1 addition & 0 deletions internal/parallel/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func (s *parallelGroup) Go(fn func() error) {
defer func() {
<-s.ch
}()

return fn()
})
}
Expand Down
Loading

0 comments on commit 1359f88

Please sign in to comment.