Skip to content

Commit 4532ea2

Browse files
authored
Fix linting errors (#179)
This is what happens when I play around with VS Code.
1 parent 03245e4 commit 4532ea2

18 files changed

+61
-51
lines changed

cmd/src/actions_create.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ Examples:
4242
)
4343

4444
handler := func(args []string) error {
45-
flagSet.Parse(args)
45+
err := flagSet.Parse(args)
46+
if err != nil {
47+
return err
48+
}
4649

4750
if _, err := os.Stat(*fileFlag); !os.IsNotExist(err) {
4851
return fmt.Errorf("file %q already exists", *fileFlag)

cmd/src/actions_exec.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ Format of the action JSON files:
152152
)
153153

154154
handler := func(args []string) error {
155-
flagSet.Parse(args)
155+
err := flagSet.Parse(args)
156+
if err != nil {
157+
return err
158+
}
156159

157160
if !isGitAvailable() {
158161
return errors.New("Could not find git in $PATH. 'src actions exec' requires git to be available.")
@@ -168,10 +171,7 @@ Format of the action JSON files:
168171
return errors.New("cache is not a valid path")
169172
}
170173

171-
var (
172-
actionFile []byte
173-
err error
174-
)
174+
var actionFile []byte
175175

176176
if *fileFlag == "-" {
177177
actionFile, err = ioutil.ReadAll(os.Stdin)
@@ -290,7 +290,7 @@ Format of the action JSON files:
290290
return err
291291
}
292292

293-
c, _ := askForConfirmation(fmt.Sprintf("Create a patch set for the produced patches anyway?"))
293+
c, _ := askForConfirmation("Create a patch set for the produced patches anyway?")
294294
if !c {
295295
return err
296296
}
@@ -582,10 +582,6 @@ func diffStatDescription(fileDiffs []*diff.FileDiff) string {
582582
return fmt.Sprintf("%d file%s changed", len(fileDiffs), plural)
583583
}
584584

585-
func diffStatSummary(stat diff.Stat) string {
586-
return fmt.Sprintf("%d insertions(+), %d deletions(-)", stat.Added+stat.Changed, stat.Deleted+stat.Changed)
587-
}
588-
589585
func diffStatDiagram(stat diff.Stat) string {
590586
const maxWidth = 20
591587
added := float64(stat.Added + stat.Changed)

cmd/src/actions_exec_backend_runner.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ func (x *actionExecutor) do(ctx context.Context, repo ActionRepo) (err error) {
8686
}
8787

8888
x.updateRepoStatus(repo, status)
89-
x.logger.RepoFinished(repo.Name, len(patch) > 0, err)
89+
lerr := x.logger.RepoFinished(repo.Name, len(patch) > 0, err)
90+
if lerr != nil {
91+
return lerr
92+
}
9093

9194
// Add to cache if successful.
9295
if err == nil {

cmd/src/actions_exec_logger.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ var (
2020
boldBlack = color.New(color.Bold, color.FgBlack)
2121
boldRed = color.New(color.Bold, color.FgRed)
2222
boldGreen = color.New(color.Bold, color.FgGreen)
23-
green = color.New(color.FgGreen)
2423
hiGreen = color.New(color.FgHiGreen)
2524
yellow = color.New(color.FgYellow)
2625
grey = color.New(color.FgHiBlack)

cmd/src/actions_scope_query.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ Examples:
3535
)
3636

3737
handler := func(args []string) error {
38-
flagSet.Parse(args)
38+
err := flagSet.Parse(args)
39+
if err != nil {
40+
return err
41+
}
3942

40-
var (
41-
actionFile []byte
42-
err error
43-
)
43+
var actionFile []byte
4444

4545
if *fileFlag == "-" {
4646
actionFile, err = ioutil.ReadAll(os.Stdin)

cmd/src/api.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ Examples:
5656
)
5757

5858
handler := func(args []string) error {
59-
flagSet.Parse(args)
59+
err := flagSet.Parse(args)
60+
if err != nil {
61+
return err
62+
}
6063

6164
// Build the GraphQL request.
6265
query := *queryFlag
@@ -133,7 +136,7 @@ func curlCmd(endpoint, accessToken, query string, vars map[string]interface{}) (
133136
return "", err
134137
}
135138

136-
s := fmt.Sprintf("curl \\\n")
139+
s := "curl \\\n"
137140
if accessToken != "" {
138141
s += fmt.Sprintf(" %s \\\n", shellquote.Join("-H", "Authorization: token "+accessToken))
139142
}

cmd/src/campaigns_add_changesets.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ Notes:
4444
)
4545

4646
handler := func(args []string) error {
47-
flagSet.Parse(args)
47+
err := flagSet.Parse(args)
48+
if err != nil {
49+
return err
50+
}
4851

4952
if *campaignIDFlag == "" {
5053
return &usageError{errors.New("-campaign must be specified")}

cmd/src/campaigns_create.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ Examples:
5858
)
5959

6060
handler := func(args []string) error {
61-
flagSet.Parse(args)
61+
err := flagSet.Parse(args)
62+
if err != nil {
63+
return err
64+
}
6265

6366
var name, description string
6467

cmd/src/campaigns_list.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ Examples:
3838
)
3939

4040
handler := func(args []string) error {
41-
flagSet.Parse(args)
41+
err := flagSet.Parse(args)
42+
if err != nil {
43+
return err
44+
}
4245

4346
tmpl, err := parseTemplate(*formatFlag)
4447
if err != nil {

cmd/src/cmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ type commander []*command
4545
func (c commander) run(flagSet *flag.FlagSet, cmdName, usageText string, args []string) {
4646
// Parse flags.
4747
flagSet.Usage = func() {
48-
fmt.Fprintf(flag.CommandLine.Output(), usageText)
48+
fmt.Fprint(flag.CommandLine.Output(), usageText)
4949
}
5050
if !flagSet.Parsed() {
51-
flagSet.Parse(args)
51+
_ = flagSet.Parse(args)
5252
}
5353

5454
// Print usage if the command is "help".

0 commit comments

Comments
 (0)