Skip to content

Commit 289b86c

Browse files
authored
Merge pull request rancher-sandbox#8356 from mook-as/golangci-lint/stylecheck
golangci-lint: Add stylecheck
2 parents 7f16938 + b026134 commit 289b86c

File tree

27 files changed

+77
-54
lines changed

27 files changed

+77
-54
lines changed

.github/actions/spelling/expect.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ JOBOBJECT
394394
joycelin
395395
jpe
396396
jsmith
397+
JSONOr
397398
jsontable
399+
JSONTo
398400
julianb
399401
karl
400402
Kaspersky

.golangci.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ linters:
6262
- ineffassign
6363
- misspell
6464
- staticcheck
65+
- stylecheck
6566
- typecheck
6667
- unconvert
6768
- unused
@@ -84,6 +85,11 @@ issues:
8485
text: "ST1005:"
8586
path: src/go/wsl-helper/cmd/kubeconfig.go
8687
source: errors.New\("Windows
88+
- # Exclude ST1005 when it encounters errors starting with proper noun
89+
linters: [ stylecheck ]
90+
text: "ST1005:"
91+
path: src/go/rdctl/pkg/lock/lock.go
92+
source: fmt.Errorf\("Rancher Desktop
8793
- # Exclude long function declarations
8894
linters: [ lll ]
8995
source: ^\s*func\b
@@ -94,3 +100,18 @@ issues:
94100
- # Ignore errors from syscall
95101
linters: [ dogsled ]
96102
source: ^\s*_, _, _ = .*\.Call\(
103+
- # Ignore foreign constants
104+
path: src/go/rdctl/pkg/process/process_darwin.go
105+
linters: [ stylecheck ]
106+
text: "ST1003:"
107+
source: ^\s*(CTL_KERN|KERN_PROCARGS)\s*=
108+
- # Ignore foreign constants
109+
path: src/go/rdctl/pkg/process/process_windows.go
110+
linters: [ stylecheck ]
111+
text: "ST1003:"
112+
source: ^\s*type\s+[A-Z0-9_]+\s+struct
113+
- # Ignore foreign constants
114+
path: src/go/rdctl/pkg/process/process_windows.go
115+
linters: [ stylecheck ]
116+
text: "ST1003:"
117+
source: ^\s*[A-Z0-9_]+\s+=

src/go/docker-credential-none/dcnone/dcnone.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (p DCNone) List() (map[string]string, error) {
114114
if ok {
115115
auths, ok := authsInterface.(map[string]interface{})
116116
if !ok {
117-
return entries, fmt.Errorf("Unexpected data: %v: not a hash\n", authsInterface)
117+
return entries, fmt.Errorf("unexpected data: %v: not a hash", authsInterface)
118118
}
119119
for url := range auths {
120120
username, _, err := getRecordForServerURL(&config, url)

src/go/docker-credential-none/dcnone/helpers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ func getRecordForServerURL(config *dockerConfigType, urlArg string) (string, str
5858
return "", "", credentials.NewErrCredentialsNotFound()
5959
}
6060
auths := authsInterface.(map[string]interface{})
61-
authDataForUrl, ok := auths[urlArg]
61+
authDataForURL, ok := auths[urlArg]
6262
if !ok {
6363
return "", "", credentials.NewErrCredentialsNotFound()
6464
}
65-
authData, ok := authDataForUrl.(map[string]interface{})["auth"]
65+
authData, ok := authDataForURL.(map[string]interface{})["auth"]
6666
if !ok {
6767
return "", "", credentials.NewErrCredentialsNotFound()
6868
}

src/go/nerdctl-stub/generate/main_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ func buildSubcommand(args []string, parentData helpData, writer io.Writer) error
9797
logrus.WithField("args", args).Trace("building subcommand")
9898
help, err := getHelp(args)
9999
if err != nil {
100-
return fmt.Errorf("Error getting help for %v: %w", args, err)
100+
return fmt.Errorf("error getting help for %v: %w", args, err)
101101
}
102102
subcommands, err := parseHelp(args, help, parentData)
103103
if err != nil {
104-
return fmt.Errorf("Error parsing help for %v: %w", args, err)
104+
return fmt.Errorf("error parsing help for %v: %w", args, err)
105105
}
106106

107107
err = emitCommand(args, subcommands, writer)

src/go/rdctl/cmd/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func doAPICommand(cmd *cobra.Command, args []string) error {
8282
}
8383
endpoint := args[0]
8484
if endpoint != "/" && regexp.MustCompile(`^/v\d+(?:/|$)`).FindString(endpoint) == "" {
85-
endpoint = fmt.Sprintf("/%s", client.VersionCommand(client.ApiVersion, endpoint))
85+
endpoint = fmt.Sprintf("/%s", client.VersionCommand(client.APIVersion, endpoint))
8686
}
8787
if apiSettings.InputFile != "" && apiSettings.Body != "" {
8888
return fmt.Errorf("api command: --body and --input options cannot both be specified")

src/go/rdctl/cmd/createProfile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ func createProfile() (string, error) {
113113
return "", err
114114
}
115115
if outputSettingsFlags.Format == regFormat {
116-
lines, err := reg.JsonToReg(outputSettingsFlags.RegistryHive, outputSettingsFlags.RegistryProfileType, string(output))
116+
lines, err := reg.JSONToReg(outputSettingsFlags.RegistryHive, outputSettingsFlags.RegistryProfileType, string(output))
117117
if err != nil {
118118
return "", err
119119
}
120120
return strings.Join(lines, "\n"), nil
121121
} else if outputSettingsFlags.Format == plistFormat {
122-
return plist.JsonToPlist(string(output))
122+
return plist.JSONToPlist(string(output))
123123
}
124124
return "", fmt.Errorf(`internal error: expecting an output format of %q or %q, got %q`, regFormat, plistFormat, outputSettingsFlags.Format)
125125
}

src/go/rdctl/cmd/extension.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var extensionCmd = &cobra.Command{
3131
Use: "extension [install | uninstall | list] [options...]",
3232
RunE: func(cmd *cobra.Command, args []string) error {
3333
cmd.SilenceUsage = true
34-
return fmt.Errorf("No subcommand given.\n\nUsage: rdctl %s", cmd.Use)
34+
return fmt.Errorf("no subcommand given.\n\nUsage: rdctl %s", cmd.Use)
3535
},
3636
}
3737

src/go/rdctl/cmd/extensionInstall.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func installExtension(args []string) error {
5050
}
5151
rdClient := client.NewRDClient(connectionInfo)
5252
imageID := args[0]
53-
endpoint := fmt.Sprintf("/%s/extensions/install?id=%s", client.ApiVersion, imageID)
53+
endpoint := fmt.Sprintf("/%s/extensions/install?id=%s", client.APIVersion, imageID)
5454
// https://stackoverflow.com/questions/20847357/golang-http-client-always-escaped-the-url
5555
// Looks like http.NewRequest(method, url) escapes the URL
5656

src/go/rdctl/cmd/extensionList.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func listExtensions() error {
5252
return fmt.Errorf("failed to get connection info: %w", err)
5353
}
5454
rdClient := client.NewRDClient(connectionInfo)
55-
endpoint := fmt.Sprintf("/%s/extensions", client.ApiVersion)
55+
endpoint := fmt.Sprintf("/%s/extensions", client.APIVersion)
5656
result, errorPacket, err := client.ProcessRequestForAPI(rdClient.DoRequest("GET", endpoint))
5757
if errorPacket != nil || err != nil {
5858
return displayAPICallResult([]byte{}, errorPacket, err)

0 commit comments

Comments
 (0)