Skip to content

Commit 8e0b752

Browse files
authored
Apply linter suggestions (#2786)
* Refactor: if-elif-else => switch Signed-off-by: Matej Vašek <[email protected]> * Cleanup: calls to embedded fields Signed-off-by: Matej Vašek <[email protected]> * Fix: add missing err checks Signed-off-by: Matej Vašek <[email protected]> * Cleanup: fix format of error messages Signed-off-by: Matej Vašek <[email protected]> * Cleanup: omit type where possible Signed-off-by: Matej Vašek <[email protected]> * Cleanup: apply De Morgan's law Signed-off-by: Matej Vašek <[email protected]> * Cleanup: call ReplaceAll where possible Signed-off-by: Matej Vašek <[email protected]> * Cleanup: fix format of error messages Signed-off-by: Matej Vašek <[email protected]> * Cleanup: fix format of error messages Signed-off-by: Matej Vašek <[email protected]> --------- Signed-off-by: Matej Vašek <[email protected]>
1 parent 36e2720 commit 8e0b752

File tree

26 files changed

+52
-46
lines changed

26 files changed

+52
-46
lines changed

cmd/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ func (c buildConfig) Validate() (err error) {
359359

360360
// Platform is only supported with the S2I builder at this time
361361
if c.Platform != "" && c.Builder != builders.S2I {
362-
err = errors.New("Only S2I builds currently support specifying platform")
362+
err = errors.New("only S2I builds currently support specifying platform")
363363
return
364364
}
365365

cmd/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ func newHelpTemplate(cmd *cobra.Command) *template.Template {
534534
fm := template.FuncMap{
535535
"indent": func(i int, c string, v string) string {
536536
indentation := strings.Repeat(c, i)
537-
return indentation + strings.Replace(v, "\n", "\n"+indentation, -1)
537+
return indentation + strings.ReplaceAll(v, "\n", "\n"+indentation)
538538
},
539539
}
540540
t.Funcs(fm)

cmd/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func newDeleteConfig(cmd *cobra.Command, args []string) (cfg deleteConfig, err e
105105
// logicially inconsistent to supply only a namespace.
106106
// Either use the function's local state in its entirety, or specify
107107
// both a name and a namespace to ignore any local function source.
108-
err = fmt.Errorf("must also specify a name when specifying namespace.")
108+
err = fmt.Errorf("must also specify a name when specifying namespace")
109109
}
110110
if cfg.Name != "" && cmd.Flags().Changed("path") {
111111
// logically inconsistent to provide both a name and a path to source.

cmd/deploy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ func build(cmd *cobra.Command, flag string, f fn.Function, client *fn.Client, bu
378378
return f, false, err
379379
}
380380
} else if _, err = strconv.ParseBool(flag); err != nil {
381-
return f, false, fmt.Errorf("--build ($FUNC_BUILD) %q not recognized. Should be 'auto' or a truthy value such as 'true', 'false', '0', or '1'.", flag)
381+
return f, false, fmt.Errorf("invalid value for the build flag (%q), valid value is either 'auto' or a boolean", flag)
382382
} else if !build {
383383
return f, false, nil
384384
}

cmd/describe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func newDescribeConfig(cmd *cobra.Command, args []string) (cfg describeConfig, e
118118
// logicially inconsistent to supply only a namespace.
119119
// Either use the function's local state in its entirety, or specify
120120
// both a name and a namespace to ignore any local function source.
121-
err = fmt.Errorf("must also specify a name when specifying namespace.")
121+
err = fmt.Errorf("must also specify a name when specifying namespace")
122122
}
123123
if cfg.Name != "" && cmd.Flags().Changed("path") {
124124
// logically inconsistent to provide both a name and a path to source.

cmd/format.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func write(out io.Writer, s Formatter, formatName string) {
4444
case URL:
4545
err = s.URL(out)
4646
default:
47-
err = fmt.Errorf("format not recognized: %v\n", formatName)
47+
err = fmt.Errorf("format not recognized: %v", formatName)
4848
}
4949
if err != nil {
5050
panic(err)

cmd/func-util/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func main() {
3939
os.Exit(137)
4040
}()
4141

42-
var cmd func(context.Context) error = unknown
42+
var cmd = unknown
4343

4444
switch filepath.Base(os.Args[0]) {
4545
case "deploy":

cmd/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func newListConfig(cmd *cobra.Command) (cfg listConfig, err error) {
130130

131131
// specifying both -A and --namespace is logically inconsistent
132132
if cmd.Flags().Changed("namespace") && viper.GetBool("all-namespaces") {
133-
err = errors.New("Both --namespace and --all-namespaces specified.")
133+
err = errors.New("both --namespace and --all-namespaces specified")
134134
}
135135

136136
return

cmd/repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ func runRepositoryRemove(_ *cobra.Command, args []string, newClient ClientFactor
529529
}
530530

531531
if len(repositories) == 0 {
532-
return errors.New("No repositories installed. use 'add' to install")
532+
return errors.New("no repositories installed. use 'add' to install")
533533
}
534534

535535
// Confirm (interactive prompt mode)

cmd/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func (c runConfig) Validate(cmd *cobra.Command, f fn.Function) (err error) {
350350
}
351351

352352
if !c.Container && !oci.IsSupported(f.Runtime) {
353-
return fmt.Errorf("The %q runtime currently requires being run in a container", f.Runtime)
353+
return fmt.Errorf("the %q runtime currently requires being run in a container", f.Runtime)
354354
}
355355

356356
// When the docker runner respects the StartTimeout, this validation check

0 commit comments

Comments
 (0)