Skip to content

Commit bd2b344

Browse files
mwbrookszimeg
andauthored
refactor: update custom initialisms for linter rule ST1003 (#71)
* refactor: update names to match ST1003 lint rule * refactor: update Http to HTTP for ST1003 lint rule * refactor: ST1003 linter updates * refactor: ST1003 linter updates * refactor: rename 'Cli' to 'CLI' for linter ST1003 * refactor: update metaData to metadata * refactor: update MetaData to Metadata * refactor: update CallBack to Callback * build: add initialisms for CLI and SDK to linter ST1003 * Update .golangci.yml Co-authored-by: Eden Zimbelman <eden.zimbelman@salesforce.com> * refactor: add XML and UTF8 to initialisms * fix: revert GitHub Header Api changes --------- Co-authored-by: Eden Zimbelman <eden.zimbelman@salesforce.com>
1 parent e71eded commit bd2b344

17 files changed

Lines changed: 96 additions & 70 deletions

.golangci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,32 @@ linters:
4444
- '-QF1008' # disable rule 'Omit embedded fields from selector'
4545
- '-QF1011' # disable rule 'Omit redundant type from variable declaration'
4646
- '-ST1016' # disable rule 'Use consistent method receiver names'
47+
# https://golangci-lint.run/usage/linters/#staticcheck
48+
# https://staticcheck.dev/docs/configuration/options/#initialisms
49+
initialisms:
50+
- "ACL"
51+
- "API"
52+
- "CLI"
53+
- "EOF"
54+
- "HTML"
55+
- "HTTP"
56+
- "HTTPS"
57+
- "ID"
58+
- "IP"
59+
- "JSON"
60+
- "SDK"
61+
- "TCP"
62+
- "TLS"
63+
- "TS"
64+
- "TTL"
65+
- "UI"
66+
- "URI"
67+
- "URL"
68+
- "UTF"
69+
- "UTF8"
70+
- "UUID"
71+
- "XML"
72+
4773
formatters:
4874
enable:
4975
- gofmt

cmd/externalauth/select_auth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func runSelectAuthCommand(clients *shared.ClientFactory, cmd *cobra.Command) err
110110
}
111111
return err
112112
}
113-
if selectedWorkflowAuth.CallBackID == "" {
113+
if selectedWorkflowAuth.CallbackID == "" {
114114
return slackerror.New(slackerror.ErrWorkflowNotFound)
115115
}
116116
if selectedWorkflowAuth.WorkflowID == "" {
@@ -158,7 +158,7 @@ func runSelectAuthCommand(clients *shared.ClientFactory, cmd *cobra.Command) err
158158
Emoji: "sparkles",
159159
Text: fmt.Sprintf(
160160
"Workflow #/workflows/%s will use developer account %s when making calls to %s APIs",
161-
selectedWorkflowAuth.CallBackID,
161+
selectedWorkflowAuth.CallbackID,
162162
selectedAuth.ExternalUserID,
163163
selectedProviderAuth.ProviderKey,
164164
),

cmd/externalauth/select_auth_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func TestExternalAuthSelectAuthCommand(t *testing.T) {
202202
Workflows: []types.WorkflowsInfo{
203203
{
204204
WorkflowID: "Wf0548LABCD1",
205-
CallBackID: "my_callback_id1",
205+
CallbackID: "my_callback_id1",
206206
Providers: []types.ProvidersInfo{
207207
{
208208
ProviderKey: "provider_c",
@@ -225,7 +225,7 @@ func TestExternalAuthSelectAuthCommand(t *testing.T) {
225225
},
226226
{
227227
WorkflowID: "Wf0548LABCD2",
228-
CallBackID: "my_callback_id2",
228+
CallbackID: "my_callback_id2",
229229
Providers: []types.ProvidersInfo{
230230
{
231231
ProviderKey: "provider_a",

cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func InitConfig(ctx context.Context, clients *shared.ClientFactory, rootCmd *cob
260260

261261
// Init clients that use flags
262262
clients.Config.APIHostResolved = clients.AuthInterface().ResolveAPIHost(ctx, clients.Config.APIHostFlag, nil)
263-
clients.Config.LogstashHostResolved = clients.AuthInterface().ResolveLogstashHost(ctx, clients.Config.APIHostResolved, clients.CliVersion)
263+
clients.Config.LogstashHostResolved = clients.AuthInterface().ResolveLogstashHost(ctx, clients.Config.APIHostResolved, clients.CLIVersion)
264264

265265
// Init System ID
266266
if systemID, err := clients.Config.SystemConfig.InitSystemID(ctx); err != nil {
@@ -291,7 +291,7 @@ func InitConfig(ctx context.Context, clients *shared.ClientFactory, rootCmd *cob
291291
// Init configurations
292292
clients.Config.LoadExperiments(ctx, clients.IO.PrintDebug)
293293
// TODO(slackcontext) Consolidate storing CLI version to slackcontext
294-
clients.Config.Version = clients.CliVersion
294+
clients.Config.Version = clients.CLIVersion
295295

296296
// The domain auths (token->domain) shouldn't change for the execution of the CLI so preload them into config!
297297
clients.Config.DomainAuthTokens = clients.AuthInterface().MapAuthTokensToDomains(ctx)

internal/api/externalauth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ func Test_API_AppsAuthExternalList(t *testing.T) {
343343
Workflows: []types.WorkflowsInfo{
344344
{
345345
WorkflowID: "Wf04QXGCK3FF",
346-
CallBackID: "external_auth_demo_workflow",
346+
CallbackID: "external_auth_demo_workflow",
347347
Providers: []types.ProvidersInfo{
348348
{
349349
ProviderName: "Google",

internal/pkg/apps/install_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func TestInstall(t *testing.T) {
9090
mockManifestSource: config.ManifestSourceLocal,
9191
mockManifest: types.SlackYaml{
9292
AppManifest: types.AppManifest{
93-
MetaData: &types.ManifestMetaData{
93+
Metadata: &types.ManifestMetadata{
9494
MajorVersion: 2,
9595
},
9696
Settings: &types.AppSettings{
@@ -105,7 +105,7 @@ func TestInstall(t *testing.T) {
105105
TeamDomain: mockTeamDomain,
106106
},
107107
expectedManifest: types.AppManifest{
108-
MetaData: &types.ManifestMetaData{
108+
Metadata: &types.ManifestMetadata{
109109
MajorVersion: 2,
110110
},
111111
Settings: &types.AppSettings{
@@ -149,7 +149,7 @@ func TestInstall(t *testing.T) {
149149
mockManifestSource: config.ManifestSourceLocal,
150150
mockManifest: types.SlackYaml{
151151
AppManifest: types.AppManifest{
152-
MetaData: &types.ManifestMetaData{
152+
Metadata: &types.ManifestMetadata{
153153
MajorVersion: 2,
154154
},
155155
Settings: &types.AppSettings{
@@ -164,7 +164,7 @@ func TestInstall(t *testing.T) {
164164
TeamDomain: mockTeamDomain,
165165
},
166166
expectedManifest: types.AppManifest{
167-
MetaData: &types.ManifestMetaData{
167+
Metadata: &types.ManifestMetadata{
168168
MajorVersion: 2,
169169
},
170170
Settings: &types.AppSettings{
@@ -210,7 +210,7 @@ func TestInstall(t *testing.T) {
210210
mockIsTTY: true,
211211
mockManifest: types.SlackYaml{
212212
AppManifest: types.AppManifest{
213-
MetaData: &types.ManifestMetaData{
213+
Metadata: &types.ManifestMetadata{
214214
MajorVersion: 1,
215215
},
216216
DisplayInformation: types.DisplayInformation{
@@ -232,7 +232,7 @@ func TestInstall(t *testing.T) {
232232
},
233233
expectedInstallState: types.InstallSuccess,
234234
expectedManifest: types.AppManifest{
235-
MetaData: &types.ManifestMetaData{
235+
Metadata: &types.ManifestMetadata{
236236
MajorVersion: 1,
237237
},
238238
DisplayInformation: types.DisplayInformation{
@@ -386,7 +386,7 @@ func TestInstall(t *testing.T) {
386386
mockIsTTY: true,
387387
mockManifest: types.SlackYaml{
388388
AppManifest: types.AppManifest{
389-
MetaData: &types.ManifestMetaData{
389+
Metadata: &types.ManifestMetadata{
390390
MajorVersion: 1,
391391
},
392392
DisplayInformation: types.DisplayInformation{
@@ -426,7 +426,7 @@ func TestInstall(t *testing.T) {
426426
mockBoltExperiment: true,
427427
mockManifest: types.SlackYaml{
428428
AppManifest: types.AppManifest{
429-
MetaData: &types.ManifestMetaData{
429+
Metadata: &types.ManifestMetadata{
430430
MajorVersion: 1,
431431
},
432432
DisplayInformation: types.DisplayInformation{
@@ -442,7 +442,7 @@ func TestInstall(t *testing.T) {
442442
},
443443
expectedInstallState: types.InstallSuccess,
444444
expectedManifest: types.AppManifest{
445-
MetaData: &types.ManifestMetaData{
445+
Metadata: &types.ManifestMetadata{
446446
MajorVersion: 1,
447447
},
448448
DisplayInformation: types.DisplayInformation{
@@ -687,7 +687,7 @@ func TestInstallLocalApp(t *testing.T) {
687687
},
688688
mockManifest: types.SlackYaml{
689689
AppManifest: types.AppManifest{
690-
MetaData: &types.ManifestMetaData{
690+
Metadata: &types.ManifestMetadata{
691691
MajorVersion: 2,
692692
},
693693
DisplayInformation: types.DisplayInformation{
@@ -707,7 +707,7 @@ func TestInstallLocalApp(t *testing.T) {
707707
UserID: mockUserID,
708708
},
709709
expectedManifest: types.AppManifest{
710-
MetaData: &types.ManifestMetaData{
710+
Metadata: &types.ManifestMetadata{
711711
MajorVersion: 2,
712712
},
713713
DisplayInformation: types.DisplayInformation{
@@ -749,7 +749,7 @@ func TestInstallLocalApp(t *testing.T) {
749749
},
750750
mockManifest: types.SlackYaml{
751751
AppManifest: types.AppManifest{
752-
MetaData: &types.ManifestMetaData{
752+
Metadata: &types.ManifestMetadata{
753753
MajorVersion: 1,
754754
},
755755
DisplayInformation: types.DisplayInformation{
@@ -777,7 +777,7 @@ func TestInstallLocalApp(t *testing.T) {
777777
UserID: mockUserID,
778778
},
779779
expectedManifest: types.AppManifest{
780-
MetaData: &types.ManifestMetaData{
780+
Metadata: &types.ManifestMetadata{
781781
MajorVersion: 1,
782782
},
783783
DisplayInformation: types.DisplayInformation{

internal/pkg/externalauth/prompt_provider_auth_select_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestPrompt_ProviderAuthSelectPrompt_empty_list(t *testing.T) {
4141
func TestPrompt_ProviderAuthSelectPrompt_no_selected_auth(t *testing.T) {
4242
workflowsInfo := types.WorkflowsInfo{
4343
WorkflowID: "Wf0548LABCD1",
44-
CallBackID: "my_callback_id1",
44+
CallbackID: "my_callback_id1",
4545
Providers: []types.ProvidersInfo{
4646
{
4747
ProviderKey: "provider_a",
@@ -108,7 +108,7 @@ func TestPrompt_ProviderAuthSelectPrompt_no_selected_auth(t *testing.T) {
108108
func TestPrompt_ProviderAuthSelectPrompt_with_selected_auth(t *testing.T) {
109109
workflowsInfo := types.WorkflowsInfo{
110110
WorkflowID: "Wf0548LABCD1",
111-
CallBackID: "my_callback_id1",
111+
CallbackID: "my_callback_id1",
112112
Providers: []types.ProvidersInfo{
113113
{
114114
ProviderKey: "provider_a",

internal/pkg/externalauth/prompt_workflow_select.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func WorkflowSelectPrompt(ctx context.Context, clients *shared.ClientFactory, pr
3232
var workflowOptions = []string{}
3333
var selectedWorkflow types.WorkflowsInfo
3434
for _, workflow := range workflows {
35-
workflowMap[workflow.CallBackID] = workflow
35+
workflowMap[workflow.CallbackID] = workflow
3636
providers := workflow.Providers
3737
var providerList strings.Builder
3838
for _, provider := range providers {
@@ -43,7 +43,7 @@ func WorkflowSelectPrompt(ctx context.Context, clients *shared.ClientFactory, pr
4343
}
4444
fmt.Fprintf(&providerList, "\tKey: %s, Name: %s, Selected Account: %s\n", provider.ProviderKey, provider.ProviderName, selectedExternalAccountID)
4545
}
46-
optionText := fmt.Sprintf("Workflow: %s\n Providers:\n %s", workflowCallbackPrefix+workflow.CallBackID, providerList.String())
46+
optionText := fmt.Sprintf("Workflow: %s\n Providers:\n %s", workflowCallbackPrefix+workflow.CallbackID, providerList.String())
4747
workflowOptions = append(workflowOptions, optionText)
4848
}
4949
selection, err := clients.IO.SelectPrompt(ctx, "Select a workflow", workflowOptions, iostreams.SelectPromptConfig{

internal/pkg/externalauth/prompt_workflow_select_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func TestPrompt_WorkflowSelectPrompt_with_workflows(t *testing.T) {
8383
Workflows: []types.WorkflowsInfo{
8484
{
8585
WorkflowID: "Wf0548LABCD1",
86-
CallBackID: "my_callback_id1",
86+
CallbackID: "my_callback_id1",
8787
Providers: []types.ProvidersInfo{
8888
{
8989
ProviderKey: "provider_a",
@@ -102,7 +102,7 @@ func TestPrompt_WorkflowSelectPrompt_with_workflows(t *testing.T) {
102102
},
103103
{
104104
WorkflowID: "Wf0548LABCD2",
105-
CallBackID: "my_callback_id2",
105+
CallbackID: "my_callback_id2",
106106
Providers: []types.ProvidersInfo{
107107
{
108108
ProviderKey: "provider_a",
@@ -160,7 +160,7 @@ func TestPrompt_WorkflowSelectPrompt_with_workflows(t *testing.T) {
160160
require.NoError(t, err)
161161
require.Equal(t, selectedWorkflow, types.WorkflowsInfo{
162162
WorkflowID: "Wf0548LABCD2",
163-
CallBackID: "my_callback_id2",
163+
CallbackID: "my_callback_id2",
164164
Providers: []types.ProvidersInfo{
165165
{
166166
ProviderKey: "provider_a",

internal/shared/clients.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type ClientFactory struct {
5656
EventTracker tracking.TrackingManager
5757

5858
Runtime runtime.Runtime
59-
CliVersion string
59+
CLIVersion string
6060
AuthInterface func() auth.AuthInterface
6161

6262
// Browser can display or open URLs as webpages on the internet
@@ -115,8 +115,8 @@ func NewClientFactory(options ...func(*ClientFactory)) *ClientFactory {
115115
// Used by the APIClient for its userAgent
116116
// Currently needed because trying to get the version of the CLI from pkg/version/version.go would cause a circular dependency
117117
// We can get rid of this once we refactor the code relationship between pkg/ and internal/
118-
// userAgent can get Slack CLI version from context which is defined in main.go, this approach bypass circular dependency. The clients.CliVersion is retained for future code refactor purpose and serve SetVersion function
119-
clients.CliVersion = ""
118+
// userAgent can get Slack CLI version from context which is defined in main.go, this approach bypass circular dependency. The clients.CLIVersion is retained for future code refactor purpose and serve SetVersion function
119+
clients.CLIVersion = ""
120120

121121
// Custom values set by functional options
122122
// Learn more: https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis
@@ -224,7 +224,7 @@ func (c *ClientFactory) InitSDKConfig(ctx context.Context, dirPath string) error
224224
hooksJSONFilePath = filepath.Join(dirPath, ".slack", "cli.json")
225225
info, err = c.Fs.Stat(hooksJSONFilePath)
226226
if err == nil && !info.IsDir() {
227-
return slackerror.New(slackerror.ErrCliConfigLocationError)
227+
return slackerror.New(slackerror.ErrCLIConfigLocationError)
228228
}
229229
// Return an error if the current path is the project root, identified by the
230230
// .slack directory, because no hooks file was found
@@ -331,7 +331,7 @@ func DebugMode(c *ClientFactory) {
331331
// SetVersion is a functional option that sets the Cli version that the API Client references
332332
// Learn more: https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis
333333
func SetVersion(version string) func(c *ClientFactory) {
334-
return func(c *ClientFactory) { c.CliVersion = version }
334+
return func(c *ClientFactory) { c.CLIVersion = version }
335335
}
336336

337337
// getDevHostname returns the hostname of the given URL if it is dev or a numbered dev instance

0 commit comments

Comments
 (0)