Skip to content

Commit c53a984

Browse files
authored
Update src to use 125 max line long for easier GitHub reviews (#880)
* auto format * comments * semi-manual * cspell * cspell again
1 parent 467421a commit c53a984

File tree

113 files changed

+2242
-533
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+2242
-533
lines changed

cli/azd/.golangci.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ linters:
22
enable:
33
- errorlint
44
- gofmt
5+
- lll
56
linters-settings:
67
errorlint:
78
errorf: true
89
asserts: true
9-
comparison: true
10+
comparison: true
11+
lll:
12+
# GitHub recommended for code review
13+
line-length: 125

cli/azd/cmd/deploy.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func deployCmd(rootOptions *internal.GlobalCommandOptions) *cobra.Command {
2929
"deploy",
3030
"Deploy the application's code to Azure.",
3131
&commands.BuildOptions{
32+
//nolint:lll
3233
Long: `Deploy the application's code to Azure.
3334
3435
When no ` + output.WithBackticks("--service") + ` value is specified, all services in the ` + output.WithBackticks("azure.yaml") + ` file (found in the root of your project) are deployed.
@@ -62,7 +63,13 @@ func (d *deployAction) SetupFlags(
6263
persis *pflag.FlagSet,
6364
local *pflag.FlagSet,
6465
) {
65-
local.StringVar(&d.serviceName, "service", "", "Deploys a specific service (when the string is unspecified, all services that are listed in the "+azdcontext.ProjectFileName+" file are deployed).")
66+
local.StringVar(
67+
&d.serviceName,
68+
"service",
69+
"",
70+
"Deploys a specific service (when the string is unspecified, "+
71+
"all services that are listed in the "+azdcontext.ProjectFileName+" file are deployed).",
72+
)
6673
}
6774

6875
func (d *deployAction) Run(ctx context.Context, cmd *cobra.Command, args []string, azdCtx *azdcontext.AzdContext) error {
@@ -185,7 +192,12 @@ func (d *deployAction) Run(ctx context.Context, cmd *cobra.Command, args []strin
185192
return nil
186193
}
187194

188-
func reportServiceDeploymentResultInteractive(ctx context.Context, console input.Console, svc *project.Service, sdr *project.ServiceDeploymentResult) {
195+
func reportServiceDeploymentResultInteractive(
196+
ctx context.Context,
197+
console input.Console,
198+
svc *project.Service,
199+
sdr *project.ServiceDeploymentResult,
200+
) {
189201
var builder strings.Builder
190202

191203
builder.WriteString(fmt.Sprintf("Deployed service %s\n", output.WithHighLightFormat(svc.Config.Name)))

cli/azd/cmd/env.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func envCmd(rootOptions *internal.GlobalCommandOptions) *cobra.Command {
2626
root := &cobra.Command{
2727
Use: "env",
2828
Short: "Manage environments.",
29+
//nolint:lll
2930
Long: `Manage environments.
3031
3132
With this command group, you can create a new environment or get, set, and list your application environments. An application can have multiple environments (for example, dev, test, prod), each with a different configuration (that is, connectivity information) for accessing Azure resources.
@@ -70,7 +71,12 @@ func envSetCmd(rootOptions *internal.GlobalCommandOptions) *cobra.Command {
7071
}
7172

7273
//lint:ignore SA4006 // We want ctx overridden here for future changes
73-
env, ctx, err := loadOrInitEnvironment(ctx, &rootOptions.EnvironmentName, azdCtx, console) //nolint:ineffassign,staticcheck
74+
env, ctx, err := loadOrInitEnvironment( //nolint:ineffassign,staticcheck
75+
ctx,
76+
&rootOptions.EnvironmentName,
77+
azdCtx,
78+
console,
79+
)
7480
if err != nil {
7581
return fmt.Errorf("loading environment: %w", err)
7682
}
@@ -190,7 +196,12 @@ type envNewAction struct {
190196
}
191197

192198
func (en *envNewAction) SetupFlags(persis *pflag.FlagSet, local *pflag.FlagSet) {
193-
local.StringVar(&en.subscription, "subscription", "", "Name or ID of an Azure subscription to use for the new environment")
199+
local.StringVar(
200+
&en.subscription,
201+
"subscription",
202+
"",
203+
"Name or ID of an Azure subscription to use for the new environment",
204+
)
194205
local.StringVarP(&en.location, "location", "l", "", "Azure location for the new environment")
195206
}
196207

@@ -306,7 +317,12 @@ func envGetValuesCmd(rootOptions *internal.GlobalCommandOptions) *cobra.Command
306317
writer := output.GetWriter(ctx)
307318

308319
//lint:ignore SA4006 // We want ctx overridden here for future changes
309-
env, ctx, err := loadOrInitEnvironment(ctx, &rootOptions.EnvironmentName, azdCtx, console) //nolint:ineffassign,staticcheck
320+
env, ctx, err := loadOrInitEnvironment( //nolint:ineffassign,staticcheck
321+
ctx,
322+
&rootOptions.EnvironmentName,
323+
azdCtx,
324+
console,
325+
)
310326
if err != nil {
311327
return err
312328
}

cli/azd/cmd/infra_create.go

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ func (ica *infraCreateAction) SetupFlags(persis, local *pflag.FlagSet) {
4747
local.BoolVar(&ica.noProgress, "no-progress", false, "Suppresses progress information.")
4848
}
4949

50-
func (ica *infraCreateAction) Run(ctx context.Context, cmd *cobra.Command, args []string, azdCtx *azdcontext.AzdContext) error {
50+
func (ica *infraCreateAction) Run(
51+
ctx context.Context,
52+
cmd *cobra.Command,
53+
args []string,
54+
azdCtx *azdcontext.AzdContext,
55+
) error {
5156
azCli := azcli.GetAzCli(ctx)
5257
console := input.GetConsole(ctx)
5358

@@ -100,19 +105,28 @@ func (ica *infraCreateAction) Run(ctx context.Context, cmd *cobra.Command, args
100105
if formatter.Kind() == output.JsonFormat {
101106
stateResult, err := infraManager.State(ctx, provisioningScope)
102107
if err != nil {
103-
return fmt.Errorf("deployment failed and the deployment result is unavailable: %w", multierr.Combine(err, err))
108+
return fmt.Errorf(
109+
"deployment failed and the deployment result is unavailable: %w",
110+
multierr.Combine(err, err),
111+
)
104112
}
105113

106-
if err := formatter.Format(contracts.NewEnvRefreshResultFromProvisioningState(stateResult.State), writer, nil); err != nil {
107-
return fmt.Errorf("deployment failed and the deployment result could not be displayed: %w", multierr.Combine(err, err))
114+
if err := formatter.Format(
115+
contracts.NewEnvRefreshResultFromProvisioningState(stateResult.State), writer, nil); err != nil {
116+
return fmt.Errorf(
117+
"deployment failed and the deployment result could not be displayed: %w",
118+
multierr.Combine(err, err),
119+
)
108120
}
109121
}
110122

111123
return fmt.Errorf("deployment failed: %w", err)
112124
}
113125

114126
for _, svc := range prj.Services {
115-
if err := svc.RaiseEvent(ctx, project.Deployed, map[string]any{"bicepOutput": deployResult.Deployment.Outputs}); err != nil {
127+
if err := svc.RaiseEvent(
128+
ctx, project.Deployed,
129+
map[string]any{"bicepOutput": deployResult.Deployment.Outputs}); err != nil {
116130
return err
117131
}
118132
}
@@ -125,7 +139,12 @@ func (ica *infraCreateAction) Run(ctx context.Context, cmd *cobra.Command, args
125139
return nil
126140
}
127141

128-
func (ica *infraCreateAction) displayResourceGroupCreatedMessage(ctx context.Context, console input.Console, subscriptionId string, resourceGroup string) {
142+
func (ica *infraCreateAction) displayResourceGroupCreatedMessage(
143+
ctx context.Context,
144+
console input.Console,
145+
subscriptionId string,
146+
resourceGroup string,
147+
) {
129148
resourceGroupCreatedMessage := resourceGroupCreatedMessage(ctx, subscriptionId, resourceGroup)
130149
if ica.finalOutputRedirect != nil {
131150
*ica.finalOutputRedirect = append(*ica.finalOutputRedirect, resourceGroupCreatedMessage)

cli/azd/cmd/infra_delete.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,21 @@ func (a *infraDeleteAction) SetupFlags(
3939
local *pflag.FlagSet,
4040
) {
4141
local.BoolVar(&a.forceDelete, "force", false, "Does not require confirmation before it deletes resources.")
42-
local.BoolVar(&a.purgeDelete, "purge", false, "Does not require confirmation before it permanently deletes resources that are soft-deleted by default (for example, key vaults).")
42+
local.BoolVar(
43+
&a.purgeDelete,
44+
"purge",
45+
false,
46+
"Does not require confirmation before it permanently deletes resources that are"+
47+
" soft-deleted by default (for example, key vaults).",
48+
)
4349
}
4450

45-
func (a *infraDeleteAction) Run(ctx context.Context, cmd *cobra.Command, args []string, azdCtx *azdcontext.AzdContext) error {
51+
func (a *infraDeleteAction) Run(
52+
ctx context.Context,
53+
cmd *cobra.Command,
54+
args []string,
55+
azdCtx *azdcontext.AzdContext,
56+
) error {
4657
azCli := azcli.GetAzCli(ctx)
4758
console := input.GetConsole(ctx)
4859

cli/azd/cmd/init.go

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func initCmd(rootOptions *internal.GlobalCommandOptions) *cobra.Command {
4141
"init",
4242
"Initialize a new application.",
4343
&commands.BuildOptions{
44+
//nolint:lll
4445
Long: `Initialize a new application.
4546
4647
When no template is supplied, you can optionally select an Azure Developer CLI template for cloning. Otherwise, ` + output.WithBackticks("azd init") + ` initializes the current directory and creates resources so that your project is compatible with Azure Developer CLI.
@@ -62,9 +63,21 @@ func (i *initAction) SetupFlags(
6263
persis *pflag.FlagSet,
6364
local *pflag.FlagSet,
6465
) {
65-
local.StringVarP(&i.template.Name, "template", "t", "", "The template to use when you initialize the project. You can use Full URI, <owner>/<repository>, or <repository> if it's part of the azure-samples organization.")
66+
local.StringVarP(
67+
&i.template.Name,
68+
"template",
69+
"t",
70+
"",
71+
"The template to use when you initialize the project. "+
72+
"You can use Full URI, <owner>/<repository>, or <repository> if it's part of the azure-samples organization.",
73+
)
6674
local.StringVarP(&i.templateBranch, "branch", "b", "", "The template branch to initialize from.")
67-
local.StringVar(&i.subscription, "subscription", "", "Name or ID of an Azure subscription to use for the new environment")
75+
local.StringVar(
76+
&i.subscription,
77+
"subscription",
78+
"",
79+
"Name or ID of an Azure subscription to use for the new environment",
80+
)
6881
local.StringVarP(&i.location, "location", "l", "", "Azure location for the new environment")
6982
}
7083

@@ -155,7 +168,11 @@ func (i *initAction) Run(ctx context.Context, cmd *cobra.Command, args []string,
155168
return fmt.Errorf("fetching template: %w", err)
156169
}
157170

158-
log.Printf("template init, checking for duplicates. source: %s target: %s", templateStagingDir, azdCtx.ProjectDirectory())
171+
log.Printf(
172+
"template init, checking for duplicates. source: %s target: %s",
173+
templateStagingDir,
174+
azdCtx.ProjectDirectory(),
175+
)
159176

160177
// If there are any existing files in the destination that would be overwritten by files from the
161178
// template, have the user confirm they would like to overwrite these files. This is a more relaxed
@@ -234,13 +251,20 @@ func (i *initAction) Run(ctx context.Context, cmd *cobra.Command, args []string,
234251
}
235252

236253
//create .azure when running azd init
237-
err = os.MkdirAll(filepath.Join(azdCtx.ProjectDirectory(), azdcontext.EnvironmentDirectoryName), osutil.PermissionDirectory)
254+
err = os.MkdirAll(
255+
filepath.Join(azdCtx.ProjectDirectory(), azdcontext.EnvironmentDirectoryName),
256+
osutil.PermissionDirectory,
257+
)
238258
if err != nil {
239259
return fmt.Errorf("failed to create a directory: %w", err)
240260
}
241261

242262
//create .gitignore or open existing .gitignore file, and contains .azure
243-
gitignoreFile, err := os.OpenFile(filepath.Join(azdCtx.ProjectDirectory(), ".gitignore"), os.O_APPEND|os.O_RDWR|os.O_CREATE, osutil.PermissionFile)
263+
gitignoreFile, err := os.OpenFile(
264+
filepath.Join(azdCtx.ProjectDirectory(), ".gitignore"),
265+
os.O_APPEND|os.O_RDWR|os.O_CREATE,
266+
osutil.PermissionFile,
267+
)
244268
if err != nil {
245269
return fmt.Errorf("fail to create or open .gitignore: %w", err)
246270
}

cli/azd/cmd/login.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ func (la *loginAction) Run(ctx context.Context, cmd *cobra.Command, args []strin
6363

6464
var res contracts.LoginResult
6565

66-
if token, err := azCli.GetAccessToken(ctx); errors.Is(err, azcli.ErrAzCliNotLoggedIn) || errors.Is(err, azcli.ErrAzCliRefreshTokenExpired) {
66+
if token, err := azCli.GetAccessToken(ctx); errors.Is(err, azcli.ErrAzCliNotLoggedIn) ||
67+
errors.Is(err, azcli.ErrAzCliRefreshTokenExpired) {
6768
res.Status = contracts.LoginStatusUnauthenticated
6869
} else if err != nil {
6970
return fmt.Errorf("checking auth status: %w", err)
@@ -87,7 +88,12 @@ func (la *loginAction) Run(ctx context.Context, cmd *cobra.Command, args []strin
8788

8889
func (la *loginAction) SetupFlags(persistent *pflag.FlagSet, local *pflag.FlagSet) {
8990
local.BoolVar(&la.onlyCheckStatus, "check-status", false, "Checks the log-in status instead of logging in.")
90-
local.BoolVar(&la.useDeviceCode, "use-device-code", false, "When true, log in by using a device code instead of a browser.")
91+
local.BoolVar(
92+
&la.useDeviceCode,
93+
"use-device-code",
94+
false,
95+
"When true, log in by using a device code instead of a browser.",
96+
)
9197
}
9298

9399
// ensureLoggedIn checks to see if the user is currently logged in. If not, the equivalent of `az login` is run.
@@ -119,7 +125,8 @@ func runLogin(ctx context.Context, forceDeviceCode bool) error {
119125
)
120126

121127
azCli := azcli.GetAzCli(ctx)
122-
useDeviceCode := forceDeviceCode || os.Getenv(CodespacesEnvVarName) == "true" || os.Getenv(RemoteContainersEnvVarName) == "true"
128+
useDeviceCode := forceDeviceCode || os.Getenv(CodespacesEnvVarName) == "true" ||
129+
os.Getenv(RemoteContainersEnvVarName) == "true"
123130

124131
return azCli.Login(ctx, useDeviceCode, os.Stdout)
125132
}

cli/azd/cmd/monitor.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ func (m *monitorAction) SetupFlags(
5353
persis *pflag.FlagSet,
5454
local *pflag.FlagSet,
5555
) {
56-
persis.BoolVar(&m.monitorLive, "live", false, "Open a browser to Application Insights Live Metrics. Live Metrics is currently not supported for Python applications.")
56+
persis.BoolVar(
57+
&m.monitorLive,
58+
"live",
59+
false,
60+
"Open a browser to Application Insights Live Metrics. Live Metrics is currently not supported for Python applications.",
61+
)
5762
persis.BoolVar(&m.monitorLogs, "logs", false, "Open a browser to Application Insights Logs.")
5863
persis.BoolVar(&m.monitorOverview, "overview", false, "Open a browser to Application Insights Overview Dashboard.")
5964
}

cli/azd/cmd/pipeline.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func pipelineCmd(rootOptions *internal.GlobalCommandOptions) *cobra.Command {
2121
cmd := &cobra.Command{
2222
Use: "pipeline",
2323
Short: "Manage GitHub Actions pipelines.",
24+
//nolint:lll
2425
Long: `Manage GitHub Actions pipelines.
2526
2627
The Azure Developer CLI template includes a GitHub Actions pipeline configuration file (in the *.github/workflows* folder) that deploys your application whenever code is pushed to the main branch.
@@ -65,9 +66,24 @@ func (p *pipelineConfigAction) SetupFlags(
6566
persis *pflag.FlagSet,
6667
local *pflag.FlagSet,
6768
) {
68-
local.StringVar(&p.manager.PipelineServicePrincipalName, "principal-name", "", "The name of the service principal to use to grant access to Azure resources as part of the pipeline.")
69-
local.StringVar(&p.manager.PipelineRemoteName, "remote-name", "origin", "The name of the git remote to configure the pipeline to run on.")
70-
local.StringVar(&p.manager.PipelineRoleName, "principal-role", "Contributor", "The role to assign to the service principal.")
69+
local.StringVar(
70+
&p.manager.PipelineServicePrincipalName,
71+
"principal-name",
72+
"",
73+
"The name of the service principal to use to grant access to Azure resources as part of the pipeline.",
74+
)
75+
local.StringVar(
76+
&p.manager.PipelineRemoteName,
77+
"remote-name",
78+
"origin",
79+
"The name of the git remote to configure the pipeline to run on.",
80+
)
81+
local.StringVar(
82+
&p.manager.PipelineRoleName,
83+
"principal-role",
84+
"Contributor",
85+
"The role to assign to the service principal.",
86+
)
7187
local.StringVar(&p.manager.PipelineProvider, "provider", "", "The pipeline provider to use (GitHub and Azdo supported).")
7288
}
7389

cli/azd/cmd/pipeline_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ func TestSetupFlags(t *testing.T) {
4242
principalNameFlag := command.LocalFlags().Lookup(flagName)
4343
assert.NotEqual(t, (*pflag.Flag)(nil), principalNameFlag)
4444
assert.Equal(t, "", principalNameFlag.Value.String())
45-
assert.Equal(t, "The name of the service principal to use to grant access to Azure resources as part of the pipeline.", principalNameFlag.Usage)
45+
assert.Equal(
46+
t,
47+
"The name of the service principal to use to grant access to Azure resources as part of the pipeline.",
48+
principalNameFlag.Usage,
49+
)
4650
principalNameFlag = command.PersistentFlags().Lookup(flagName)
4751
assert.Equal(t, (*pflag.Flag)(nil), principalNameFlag)
4852

0 commit comments

Comments
 (0)