Skip to content

Commit c2a7119

Browse files
committed
Fix linting errors
1 parent 4fa89d4 commit c2a7119

File tree

14 files changed

+50
-57
lines changed

14 files changed

+50
-57
lines changed

cli/cliui/job.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func Job(cmd *cobra.Command, opts JobOptions) (codersdk.ProvisionerJob, error) {
3030
completed = false
3131
job codersdk.ProvisionerJob
3232
)
33-
_, _ = fmt.Fprintln(cmd.OutOrStdout(), fmt.Sprintf("%s%s %s", Styles.FocusedPrompt, opts.Title, Styles.Placeholder.Render("(ctrl+c to cancel)")))
33+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%s%s %s\n", Styles.FocusedPrompt, opts.Title, Styles.Placeholder.Render("(ctrl+c to cancel)"))
3434

3535
spin.Writer = cmd.OutOrStdout()
3636
defer spin.Stop()
@@ -46,7 +46,7 @@ func Job(cmd *cobra.Command, opts JobOptions) (codersdk.ProvisionerJob, error) {
4646

4747
if !started && job.StartedAt != nil {
4848
spin.Stop()
49-
fmt.Fprintf(cmd.OutOrStdout(), Styles.Prompt.String()+"Started "+Styles.Placeholder.Render("[%dms]")+"\n", job.StartedAt.Sub(job.CreatedAt).Milliseconds())
49+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), Styles.Prompt.String()+"Started "+Styles.Placeholder.Render("[%dms]")+"\n", job.StartedAt.Sub(job.CreatedAt).Milliseconds())
5050
spin.Start()
5151
started = true
5252
}
@@ -65,7 +65,7 @@ func Job(cmd *cobra.Command, opts JobOptions) (codersdk.ProvisionerJob, error) {
6565
if job.StartedAt != nil {
6666
started = *job.StartedAt
6767
}
68-
fmt.Fprintf(cmd.OutOrStderr(), Styles.Prompt.String()+msg+" "+Styles.Placeholder.Render("[%dms]")+"\n", job.CompletedAt.Sub(started).Milliseconds())
68+
_, _ = fmt.Fprintf(cmd.OutOrStderr(), Styles.Prompt.String()+msg+" "+Styles.Placeholder.Render("[%dms]")+"\n", job.CompletedAt.Sub(started).Milliseconds())
6969
spin.Start()
7070
completed = true
7171
}
@@ -95,11 +95,11 @@ func Job(cmd *cobra.Command, opts JobOptions) (codersdk.ProvisionerJob, error) {
9595
}
9696
}
9797
spin.Stop()
98-
fmt.Fprintf(cmd.OutOrStdout(), Styles.FocusedPrompt.String()+"Gracefully canceling... wait for exit or data loss may occur!\n")
98+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), Styles.FocusedPrompt.String()+"Gracefully canceling... wait for exit or data loss may occur!\n")
9999
spin.Start()
100100
err := opts.Cancel()
101101
if err != nil {
102-
fmt.Fprintf(cmd.OutOrStdout(), "Failed to cancel %s...\n", err)
102+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Failed to cancel %s...\n", err)
103103
}
104104
refresh()
105105
}()
@@ -143,7 +143,7 @@ func Job(cmd *cobra.Command, opts JobOptions) (codersdk.ProvisionerJob, error) {
143143
case database.LogLevelInfo:
144144
style = defaultStyles.Note
145145
}
146-
fmt.Fprintln(cmd.OutOrStdout(), fmt.Sprintf("%s %s %s", Styles.Placeholder.Render("|"), style.Render(string(log.Level)), log.Output))
146+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%s %s %s\n", Styles.Placeholder.Render("|"), style.Render(string(log.Level)), log.Output)
147147
spin.Start()
148148
}
149149
}

cli/cliui/parameter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ func ParameterSchema(cmd *cobra.Command, parameterSchema codersdk.ProjectVersion
2727
var value string
2828
if len(options) > 0 {
2929
// Move the cursor up a single line for nicer display!
30-
fmt.Fprint(cmd.OutOrStdout(), "\033[1A")
30+
_, _ = fmt.Fprint(cmd.OutOrStdout(), "\033[1A")
3131
value, err = Select(cmd, SelectOptions{
3232
Options: options,
3333
HideSearch: true,
3434
})
3535
if err == nil {
36-
fmt.Fprintln(cmd.OutOrStdout())
37-
fmt.Fprintln(cmd.OutOrStdout(), " "+Styles.Prompt.String()+Styles.Field.Render(value))
36+
_, _ = fmt.Fprintln(cmd.OutOrStdout())
37+
_, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+Styles.Prompt.String()+Styles.Field.Render(value))
3838
}
3939
} else {
4040
value, err = Prompt(cmd, PromptOptions{

cli/cliui/prompt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
8484
return "", cmd.Context().Err()
8585
case <-interrupt:
8686
// Print a newline so that any further output starts properly on a new line.
87-
fmt.Fprintln(cmd.OutOrStdout())
87+
_, _ = fmt.Fprintln(cmd.OutOrStdout())
8888
return "", Canceled
8989
}
9090
}

cli/cliui/select.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package cliui
22

33
import (
44
"errors"
5-
"fmt"
65
"io"
76
"strings"
87
"text/template"
@@ -50,7 +49,7 @@ func Select(cmd *cobra.Command, opts SelectOptions) (string, error) {
5049
Inactive: " {{ . }}",
5150
Label: "{{.}}",
5251
Selected: "{{ \"\" }}",
53-
Help: fmt.Sprintf(`{{ "Use" | faint }} {{ .SearchKey | faint }} {{ "to toggle search" | faint }}`),
52+
Help: `{{ "Use" | faint }} {{ .SearchKey | faint }} {{ "to toggle search" | faint }}`,
5453
},
5554
HideSelected: true,
5655
}
@@ -69,6 +68,6 @@ type writeCloser struct {
6968
io.Writer
7069
}
7170

72-
func (w *writeCloser) Close() error {
71+
func (*writeCloser) Close() error {
7372
return nil
7473
}

cli/projectcreate.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func projectCreate() *cobra.Command {
9898
return err
9999
}
100100

101-
_, _ = fmt.Fprintln(cmd.OutOrStdout(), fmt.Sprintf("The %s project has been created!", projectName))
101+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "The %s project has been created!\n", projectName)
102102
return nil
103103
},
104104
}
@@ -172,11 +172,7 @@ func createValidProjectVersion(cmd *cobra.Command, client *codersdk.Client, orga
172172
missingSchemas = append(missingSchemas, parameterSchema)
173173
}
174174
_, _ = fmt.Fprintln(cmd.OutOrStdout(), cliui.Styles.Paragraph.Render("This project has required variables! They are scoped to the project, and not viewable after being set.")+"\r\n")
175-
for _, parameterSchema := range parameterSchemas {
176-
_, ok := valuesBySchemaID[parameterSchema.ID.String()]
177-
if ok {
178-
continue
179-
}
175+
for _, parameterSchema := range missingSchemas {
180176
value, err := cliui.ParameterSchema(cmd, parameterSchema)
181177
if err != nil {
182178
return nil, nil, err
@@ -202,5 +198,5 @@ func createValidProjectVersion(cmd *cobra.Command, client *codersdk.Client, orga
202198
if err != nil {
203199
return nil, nil, err
204200
}
205-
return &version, parameters, displayProjectVersionInfo(cmd, parameterSchemas, parameterValues, resources)
201+
return &version, parameters, displayProjectVersionInfo(cmd, resources)
206202
}

cli/projectcreate_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package cli_test
33
import (
44
"testing"
55

6+
"github.com/stretchr/testify/require"
7+
68
"github.com/coder/coder/cli/clitest"
79
"github.com/coder/coder/coderd/coderdtest"
810
"github.com/coder/coder/database"
911
"github.com/coder/coder/provisioner/echo"
1012
"github.com/coder/coder/pty/ptytest"
11-
"github.com/stretchr/testify/require"
1213
)
1314

1415
func TestProjectCreate(t *testing.T) {

cli/projectinit.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import (
55
"os"
66
"path/filepath"
77

8+
"github.com/spf13/cobra"
9+
810
"github.com/coder/coder/cli/cliui"
911
"github.com/coder/coder/examples"
1012
"github.com/coder/coder/provisionersdk"
11-
"github.com/spf13/cobra"
1213
)
1314

1415
func projectInit() *cobra.Command {

cli/projectinit_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import (
44
"os"
55
"testing"
66

7+
"github.com/stretchr/testify/require"
8+
79
"github.com/coder/coder/cli/clitest"
810
"github.com/coder/coder/pty/ptytest"
9-
"github.com/stretchr/testify/require"
1011
)
1112

1213
func TestProjectInit(t *testing.T) {

cli/projects.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ func projects() *cobra.Command {
4242
return cmd
4343
}
4444

45-
func displayProjectVersionInfo(cmd *cobra.Command, parameterSchemas []codersdk.ProjectVersionParameterSchema, parameterValues []codersdk.ProjectVersionParameter, resources []codersdk.WorkspaceResource) error {
46-
schemaByID := map[string]codersdk.ProjectVersionParameterSchema{}
47-
for _, schema := range parameterSchemas {
48-
schemaByID[schema.ID.String()] = schema
49-
}
45+
func displayProjectVersionInfo(cmd *cobra.Command, resources []codersdk.WorkspaceResource) error {
5046
sort.Slice(resources, func(i, j int) bool {
5147
return fmt.Sprintf("%s.%s", resources[i].Type, resources[i].Name) < fmt.Sprintf("%s.%s", resources[j].Type, resources[j].Name)
5248
})
@@ -81,7 +77,7 @@ func displayProjectVersionInfo(cmd *cobra.Command, parameterSchemas []codersdk.P
8177
if resource.Agent != nil {
8278
_, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+cliui.Styles.Fuschia.Render("▲ allows ssh"))
8379
}
84-
fmt.Fprintln(cmd.OutOrStdout())
80+
_, _ = fmt.Fprintln(cmd.OutOrStdout())
8581
}
8682
return nil
8783
}

cli/start_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ import (
1515
func TestStart(t *testing.T) {
1616
t.Parallel()
1717
t.Run("Production", func(t *testing.T) {
18+
t.Parallel()
1819
ctx, cancelFunc := context.WithCancel(context.Background())
1920
go cancelFunc()
2021
root, _ := clitest.New(t, "start", "--address", ":0")
2122
err := root.ExecuteContext(ctx)
2223
require.ErrorIs(t, err, context.Canceled)
2324
})
2425
t.Run("Development", func(t *testing.T) {
26+
t.Parallel()
2527
ctx, cancelFunc := context.WithCancel(context.Background())
2628
defer cancelFunc()
2729
root, cfg := clitest.New(t, "start", "--dev", "--tunnel=false", "--address", ":0")

0 commit comments

Comments
 (0)