Skip to content

Commit 29a9da0

Browse files
authored
refactor: enable linter rule QF1008 for 'Omit embedded fields from selector expression' (#95)
refactor: enable linter QF1008 'Omit embedded fields from selector expression'
1 parent 09d4247 commit 29a9da0

File tree

11 files changed

+25
-26
lines changed

11 files changed

+25
-26
lines changed

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ linters:
3838
- '-QF1012' # disable rule 'Use fmt.Fprintf instead of x.Write(fmt.Sprintf(...))'
3939
- '-QF1003' # disable rule 'Convert if/else-if chain to tagged switch'
4040
- '-QF1004' # disable rule 'Use strings.ReplaceAll instead of strings.Replace'
41-
- '-QF1008' # disable rule 'Omit embedded fields from selector'
4241
# https://golangci-lint.run/usage/linters/#staticcheck
4342
# https://staticcheck.dev/docs/configuration/options/#initialisms
4443
initialisms:

cmd/triggers/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func runUpdateCommand(clients *shared.ClientFactory, cmd *cobra.Command) error {
139139
// If the user used --workflow and the creation failed because we were missing the interactivity
140140
// context, lets prompt and optionally add it
141141
if updateFlags.workflow != "" && extendedErr.MissingParameterDetail.Type == "slack#/types/interactivity" {
142-
updateRequest.TriggerRequest.Inputs = api.Inputs{
142+
updateRequest.Inputs = api.Inputs{
143143
extendedErr.MissingParameterDetail.Name: &api.Input{Value: dataInteractivityPayload},
144144
}
145145
shouldUpdate, innerErr := updatePromptShouldRetryWithInteractivityFunc(cmd, clients.IO, triggerArg)

internal/api/activity.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (c *Client) Activity(ctx context.Context, token string, activityRequest typ
124124
if !resp.Ok {
125125
return ActivityResult{}, slackerror.NewAPIError(resp.Error, resp.Description, resp.Errors, appActivityMethod)
126126
}
127-
resp.ActivityResult.NextCursor = resp.ResponseMetadata.NextCursor
127+
resp.NextCursor = resp.ResponseMetadata.NextCursor
128128

129129
return resp.ActivityResult, nil
130130
}

internal/api/app_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestClient_ExportAppManifest_Ok(t *testing.T) {
6868
defer teardown()
6969
result, err := c.ExportAppManifest(ctx, "token", "A0123456789")
7070
require.NoError(t, err)
71-
require.Equal(t, "example", result.Manifest.AppManifest.DisplayInformation.Name)
71+
require.Equal(t, "example", result.Manifest.DisplayInformation.Name)
7272
}
7373

7474
func TestClient_ExportAppManifest_CommonErrors(t *testing.T) {

internal/api/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (c *Client) ExchangeAuthTicket(ctx context.Context, ticket string, challeng
110110
}
111111

112112
// ExchangeAuthTicketResult must have a token to be valid
113-
if resp.ExchangeAuthTicketResult.Token == "" {
113+
if resp.Token == "" {
114114
return ExchangeAuthTicketResult{}, slackerror.New(fmt.Sprintf("No token returned from the following Slack API method %s. Login can not be completed.", exchangeAuthTicketMethod))
115115
}
116116

internal/api/datastore.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ func (c *Client) AppsDatastoreBulkPut(ctx context.Context, token string, request
136136
return types.AppDatastoreBulkPutResult{}, slackerror.NewAPIError(resp.Error, resp.Description, resp.Errors, appDatastoreBulkPutMethod)
137137
}
138138

139-
if resp.AppDatastoreBulkPutResult.Datastore == "" {
140-
resp.AppDatastoreBulkPutResult.Datastore = request.Datastore
139+
if resp.Datastore == "" {
140+
resp.Datastore = request.Datastore
141141
}
142142

143143
return resp.AppDatastoreBulkPutResult, nil
@@ -234,7 +234,7 @@ func (c *Client) AppsDatastoreQuery(ctx context.Context, token string, query typ
234234
return types.AppDatastoreQueryResult{}, slackerror.NewAPIError(resp.Error, resp.Description, resp.Errors, appDatastoreQueryMethod)
235235
}
236236

237-
resp.AppDatastoreQueryResult.NextCursor = resp.baseResponse.ResponseMetadata.NextCursor
237+
resp.NextCursor = resp.ResponseMetadata.NextCursor
238238

239239
return resp.AppDatastoreQueryResult, nil
240240
}
@@ -327,11 +327,11 @@ func (c *Client) AppsDatastoreDelete(ctx context.Context, token string, request
327327
}
328328

329329
// the delete API doesn't return id or datastore (yet) so set it if empty
330-
if resp.AppDatastoreDeleteResult.ID == "" {
331-
resp.AppDatastoreDeleteResult.ID = request.ID
330+
if resp.ID == "" {
331+
resp.ID = request.ID
332332
}
333-
if resp.AppDatastoreDeleteResult.Datastore == "" {
334-
resp.AppDatastoreDeleteResult.Datastore = request.Datastore
333+
if resp.Datastore == "" {
334+
resp.Datastore = request.Datastore
335335
}
336336

337337
return resp.AppDatastoreDeleteResult, nil
@@ -377,8 +377,8 @@ func (c *Client) AppsDatastoreBulkDelete(ctx context.Context, token string, requ
377377
return types.AppDatastoreBulkDeleteResult{}, slackerror.NewAPIError(resp.Error, resp.Description, resp.Errors, appDatastoreBulkDeleteMethod)
378378
}
379379

380-
if resp.AppDatastoreBulkDeleteResult.Datastore == "" {
381-
resp.AppDatastoreBulkDeleteResult.Datastore = request.Datastore
380+
if resp.Datastore == "" {
381+
resp.Datastore = request.Datastore
382382
}
383383

384384
return resp.AppDatastoreBulkDeleteResult, nil
@@ -467,8 +467,8 @@ func (c *Client) AppsDatastoreBulkGet(ctx context.Context, token string, request
467467
return types.AppDatastoreBulkGetResult{}, slackerror.NewAPIError(resp.Error, resp.Description, resp.Errors, appDatastoreBulkGetMethod)
468468
}
469469

470-
if resp.AppDatastoreBulkGetResult.Datastore == "" {
471-
resp.AppDatastoreBulkGetResult.Datastore = request.Datastore
470+
if resp.Datastore == "" {
471+
resp.Datastore = request.Datastore
472472
}
473473

474474
return resp.AppDatastoreBulkGetResult, nil

internal/api/workflows.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func (c *Client) workflowsTriggerSave(ctx context.Context, token string, method
207207
}
208208
}
209209

210-
serverTrigger := resp.triggerResult.Trigger
210+
serverTrigger := resp.Trigger
211211

212212
return serverTrigger, nil
213213
}
@@ -217,7 +217,7 @@ func parseMissingParameterErrors(details triggerCreateOrUpdateErrorDetails) ([]s
217217
var missingParameterDetail *MissingParameterDetail
218218
for _, detail := range details {
219219
slackErrorDetails = append(slackErrorDetails, detail.ErrorDetail)
220-
if detail.MissingParameterDetail.Name != "" {
220+
if detail.Name != "" {
221221
missingParameterDetail = &detail.MissingParameterDetail
222222
}
223223
}
@@ -258,7 +258,7 @@ func (c *Client) WorkflowsTriggersList(ctx context.Context, token string, listAr
258258
return []types.DeployedTrigger{}, "", slackerror.NewAPIError(resp.Error, resp.Description, resp.Errors, workflowsTriggersListMethod)
259259
}
260260

261-
return resp.Triggers, resp.extendedBaseResponse.ResponseMetadata.NextCursor, nil
261+
return resp.Triggers, resp.ResponseMetadata.NextCursor, nil
262262
}
263263

264264
// WorkflowsTriggersInfo will retrieve information on an existing trigger

internal/cache/manifest.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (c *Cache) SetManifestHash(ctx context.Context, appID string, hash Hash) er
7878
cache[appID] = ManifestCacheApp{
7979
Hash: hash,
8080
}
81-
c.ManifestCache.Apps = cache
81+
c.Apps = cache
8282
return c.writeManifestCache(ctx)
8383
}
8484

@@ -112,7 +112,7 @@ func (c *Cache) writeManifestCache(ctx context.Context) error {
112112
if err != nil && !os.IsExist(err) {
113113
return err
114114
}
115-
cache, err := json.MarshalIndent(c.ManifestCache.Apps, "", " ")
115+
cache, err := json.MarshalIndent(c.Apps, "", " ")
116116
if err != nil {
117117
return err
118118
}

internal/cache/manifest_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TestCache_Manifest(t *testing.T) {
5252
cache := NewCache(fsMock, osMock, projectDirPath)
5353
err = cache.SetManifestHash(ctx, tt.mockAppID, tt.mockCache.Hash)
5454
require.NoError(t, err)
55-
cache.ManifestCache.Apps = map[string]ManifestCacheApp{
55+
cache.Apps = map[string]ManifestCacheApp{
5656
tt.mockAppID: tt.mockCache,
5757
}
5858
hash, err := cache.GetManifestHash(ctx, tt.mockAppID)

internal/pkg/apps/install.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ func Install(ctx context.Context, clients *shared.ClientFactory, log *logger.Log
8686
return app, "", err
8787
}
8888

89-
log.Data["appName"] = slackYaml.AppManifest.DisplayInformation.Name
89+
log.Data["appName"] = slackYaml.DisplayInformation.Name
9090
log.Data["isUpdate"] = app.AppID != ""
9191
log.Data["teamName"] = *authSession.TeamName
9292
log.Log("INFO", "app_install_manifest")
9393

9494
manifest := slackYaml.AppManifest
95-
if slackYaml.AppManifest.IsFunctionRuntimeSlackHosted() {
95+
if slackYaml.IsFunctionRuntimeSlackHosted() {
9696
configureHostedManifest(ctx, clients, &manifest)
9797
}
9898

@@ -370,7 +370,7 @@ func InstallLocalApp(ctx context.Context, clients *shared.ClientFactory, orgGran
370370
return app, api.DeveloperAppInstallResult{}, "", err
371371
}
372372

373-
log.Data["appName"] = slackYaml.AppManifest.DisplayInformation.Name
373+
log.Data["appName"] = slackYaml.DisplayInformation.Name
374374
log.Data["isUpdate"] = app.AppID != ""
375375
log.Data["teamName"] = *authSession.TeamName
376376
log.Log("INFO", "app_install_manifest")

0 commit comments

Comments
 (0)