Skip to content

Commit e645f48

Browse files
authored
Upgrade golangci-lint and fix linting issues (#544)
## Summary Upgrade golangci-lint and fix linting issues ## How was it tested? devbox run lint (and CICD) ## Community Contribution License All community contributions in this pull request are licensed to the project maintainers under the terms of the [Apache 2 License](https://www.apache.org/licenses/LICENSE-2.0). By creating this pull request I represent that I have the right to license the contributions to the project maintainers under the Apache 2 License as stated in the [Community Contribution License](https://github.com/jetify-com/opensource/blob/main/CONTRIBUTING.md#community-contribution-license).
1 parent 6f0eea6 commit e645f48

File tree

17 files changed

+41
-50
lines changed

17 files changed

+41
-50
lines changed

devbox.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
2-
"packages": [
3-
"go@latest",
4-
"golangci-lint@latest",
5-
"runx:mvdan/gofumpt@latest",
6-
],
2+
"packages": {
3+
"go": "latest",
4+
"golangci-lint": "latest"
5+
},
76
"shell": {
87
"init_hook": [
98
"export \"GOROOT=$(go env GOROOT)\"",
@@ -23,12 +22,7 @@
2322
"devbox run build",
2423
"dist/envsec auth login",
2524
],
26-
"fmt": [
27-
"find . -name '*.go' -not -wholename './gen/*' -exec gofumpt -w -l {} \\+",
28-
"if [ -n \"$CI\" ]; then",
29-
" git diff --exit-code",
30-
"fi"
31-
],
25+
"fmt": "golangci-lint run",
3226
}
3327
},
3428
"nixpkgs": {

devbox.lock

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@
9999
"store_path": "/nix/store/25732rsdh49iwjrik69sb9cfhiza00b5-golangci-lint-1.64.5"
100100
}
101101
}
102-
},
103-
"runx:mvdan/gofumpt@latest": {
104-
"resolved": "mvdan/gofumpt@v0.7.0",
105-
"version": "v0.7.0"
106102
}
107103
}
108104
}

internal/build/build.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ var (
1818

1919
func init() {
2020
buildEnv := strings.ToLower(os.Getenv("ENVSEC_BUILD_ENV"))
21-
if buildEnv == "prod" {
21+
switch buildEnv {
22+
case "prod":
2223
IsDev = false
23-
} else if buildEnv == "dev" {
24+
case "dev":
2425
IsDev = true
2526
}
2627
}

internal/tux/style.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type StyleRule struct {
3535
MarginLeft int
3636
}
3737

38-
func Render(styleSheet StyleSheet, class string, text string) string {
38+
func Render(styleSheet StyleSheet, class, text string) string {
3939
return text
4040
}
4141

@@ -68,7 +68,7 @@ func Renderer(styleRule StyleRule, tokens map[string]string) StyleRenderer {
6868
return renderer
6969
}
7070

71-
func getColor(token string, invertedToken string, tokens map[string]string) lipgloss.TerminalColor {
71+
func getColor(token, invertedToken string, tokens map[string]string) lipgloss.TerminalColor {
7272
color := resolveToken(token, tokens)
7373
invertedColor := resolveToken(invertedToken, tokens)
7474

@@ -91,8 +91,8 @@ func resolveToken(token string, tokens map[string]string) string {
9191
return token
9292
}
9393

94-
func StyleFunc(styleSheet StyleSheet) func(class string, text string) string {
95-
return func(class string, text string) string {
94+
func StyleFunc(styleSheet StyleSheet) func(class, text string) string {
95+
return func(class, text string) string {
9696
styleRule, exists := styleSheet.Styles[class]
9797
// Return the text as is if the class is not found.
9898
if !exists {

internal/tux/tux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func QuotedTerms(terms []string) []string {
104104
return q
105105
}
106106

107-
func Plural[T any](items []T, singular string, plural string) string {
107+
func Plural[T any](items []T, singular, plural string) string {
108108
if len(items) == 1 {
109109
return singular
110110
}

pkg/envcli/auth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func loginCmd() *cobra.Command {
3939

4040
_, err = client.LoginFlow()
4141
if err == nil {
42-
fmt.Fprintln(cmd.OutOrStdout(), "Logged in successfully")
42+
_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Logged in successfully")
4343
}
4444
return err
4545
},
@@ -61,7 +61,7 @@ func logoutCmd() *cobra.Command {
6161

6262
err = client.LogoutFlow()
6363
if err == nil {
64-
fmt.Fprintln(cmd.OutOrStdout(), "Logged out successfully")
64+
_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Logged out successfully")
6565
}
6666
return err
6767
},

pkg/envcli/download.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func DownloadCmd() *cobra.Command {
3333
},
3434
}
3535

36-
flags.configFlags.register(command)
36+
flags.register(command)
3737
command.Flags().StringVarP(
3838
&flags.format, "format", "f", "env", "file format: dotenv or json")
3939

pkg/envcli/exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ func ExecCmd() *cobra.Command {
4848
return commandToRun.Run()
4949
},
5050
}
51-
flags.configFlags.register(command)
51+
flags.register(command)
5252
return command
5353
}

pkg/envcli/ls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func ListCmd() *cobra.Command {
5555
"table",
5656
"format to use for displaying keys and values, one of: table, dotenv, json",
5757
)
58-
flags.configFlags.register(command)
58+
flags.register(command)
5959

6060
return command
6161
}

pkg/envcli/rm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func RemoveCmd() *cobra.Command {
2727
return cmdCfg.envsec.DeleteAll(cmd.Context(), envNames...)
2828
},
2929
}
30-
flags.configFlags.register(command)
30+
flags.register(command)
3131

3232
return command
3333
}

0 commit comments

Comments
 (0)