Skip to content

Commit bd9c07a

Browse files
authored
deps: upgrade golangci-lint to v2 (#2118)
* deps: upgrade golangci-lint to v2 * deps: upgrade golangci-lint config to v2 * deps: update config * chore: fix lint errors
1 parent 8489257 commit bd9c07a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+304
-289
lines changed

.github/workflows/pr-go.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,6 @@ jobs:
178178
go-version-file: 'go.mod'
179179
cache: true
180180
- name: Install golangci-lint
181-
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
181+
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.4.0
182182
- name: Lint
183183
run: make lint

.golangci.yml

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,48 @@
1+
version: "2"
12
run:
23
tests: false
3-
linters-settings:
4-
goimports:
5-
# put imports beginning with prefix after 3rd-party packages;
6-
# it's a comma-separated list of prefixes
7-
local-prefixes: github.com/bucketeer-io/bucketeer
8-
goheader:
9-
# template does not contains the comment indicator '//' or '/*' '*/'
10-
template: |-
11-
Copyright {{mod-year-range}} The Bucketeer Authors.
12-
13-
Licensed under the Apache License, Version 2.0 (the "License");
14-
you may not use this file except in compliance with the License.
15-
You may obtain a copy of the License at
16-
17-
http://www.apache.org/licenses/LICENSE-2.0
18-
19-
Unless required by applicable law or agreed to in writing, software
20-
distributed under the License is distributed on an "AS IS" BASIS,
21-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22-
See the License for the specific language governing permissions and
23-
limitations under the License.
244
linters:
25-
disable-all: true
5+
default: none
266
enable:
277
- errcheck
288
- goheader
29-
- gosimple
309
- govet
3110
- ineffassign
32-
- typecheck
11+
- lll
12+
- staticcheck
3313
- unused
14+
settings:
15+
goheader:
16+
template: |-
17+
Copyright {{mod-year-range}} The Bucketeer Authors.
18+
19+
Licensed under the Apache License, Version 2.0 (the "License");
20+
you may not use this file except in compliance with the License.
21+
You may obtain a copy of the License at
22+
23+
http://www.apache.org/licenses/LICENSE-2.0
24+
25+
Unless required by applicable law or agreed to in writing, software
26+
distributed under the License is distributed on an "AS IS" BASIS,
27+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28+
See the License for the specific language governing permissions and
29+
limitations under the License.
30+
staticcheck:
31+
checks: ["all", "-SA1019", "-ST1003","-ST1012"] # ignore deprecated, ignore poorly chosen identifier and ignore poorly chosen name for error variable
32+
exclusions:
33+
generated: lax
34+
presets:
35+
- comments
36+
- common-false-positives
37+
- legacy
38+
- std-error-handling
39+
formatters:
40+
enable:
3441
- gofmt
3542
- goimports
36-
- lll
43+
settings:
44+
goimports:
45+
local-prefixes:
46+
- github.com/bucketeer-io/bucketeer
47+
exclusions:
48+
generated: lax

pkg/account/api/admin_account.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,12 @@ func (s *AccountService) getMyOrganizations(
415415
}
416416
myOrgs := make([]*environmentproto.Organization, 0, len(accountsWithOrg))
417417
for _, accWithOrg := range accountsWithOrg {
418-
if accWithOrg.AccountV2.Disabled || accWithOrg.Organization.Disabled || accWithOrg.Organization.Archived {
418+
if accWithOrg.AccountV2.Disabled || accWithOrg.Organization.Disabled || accWithOrg.Archived {
419419
continue
420420
}
421421
// Add the organization if the account is an admin or owner.
422422
// Otherwise, we check if the account is enabled in any environment in this organization.
423-
if accWithOrg.AccountV2.OrganizationRole >= accountproto.AccountV2_Role_Organization_ADMIN {
423+
if accWithOrg.OrganizationRole >= accountproto.AccountV2_Role_Organization_ADMIN {
424424
myOrgs = append(myOrgs, accWithOrg.Organization)
425425
continue
426426
}
@@ -432,7 +432,7 @@ func (s *AccountService) getMyOrganizations(
432432
// When the new console is ready, we will use the DisableAccount API instead,
433433
// which will update the `disabled` column in the DB.
434434
var enabled bool
435-
for _, role := range accWithOrg.AccountV2.EnvironmentRoles {
435+
for _, role := range accWithOrg.EnvironmentRoles {
436436
if role.Role != accountproto.AccountV2_Role_Environment_UNASSIGNED {
437437
enabled = true
438438
}
@@ -449,7 +449,7 @@ func (s *AccountService) containsSystemAdminOrganization(
449449
organizations []*domain.AccountWithOrganization,
450450
) bool {
451451
for _, org := range organizations {
452-
if org.Organization.SystemAdmin {
452+
if org.SystemAdmin {
453453
return true
454454
}
455455
}

pkg/account/command/account_v2.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,12 @@ func (h *accountV2CommandHandler) changeEnvironmentRoles(
223223
ctx context.Context,
224224
cmd *accountproto.ChangeAccountV2EnvironmentRolesCommand,
225225
) error {
226-
if cmd.WriteType == accountproto.ChangeAccountV2EnvironmentRolesCommand_WriteType_OVERRIDE {
226+
switch cmd.WriteType {
227+
case accountproto.ChangeAccountV2EnvironmentRolesCommand_WriteType_OVERRIDE:
227228
if err := h.account.ChangeEnvironmentRole(cmd.Roles); err != nil {
228229
return err
229230
}
230-
} else if cmd.WriteType == accountproto.ChangeAccountV2EnvironmentRolesCommand_WriteType_PATCH {
231+
case accountproto.ChangeAccountV2EnvironmentRolesCommand_WriteType_PATCH:
231232
if err := h.account.PatchEnvironmentRole(cmd.Roles); err != nil {
232233
return err
233234
}

pkg/account/domain/account.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -172,68 +172,68 @@ func (a *AccountV2) RemoveTeam(team string) error {
172172
}
173173

174174
func (a *AccountV2) ChangeName(newName string) error {
175-
a.AccountV2.Name = newName
175+
a.Name = newName
176176
a.UpdatedAt = time.Now().Unix()
177177
return nil
178178
}
179179

180180
func (a *AccountV2) ChangeFirstName(newFirstName string) error {
181-
a.AccountV2.FirstName = newFirstName
181+
a.FirstName = newFirstName
182182
a.UpdatedAt = time.Now().Unix()
183183
return nil
184184
}
185185

186186
func (a *AccountV2) ChangeLastName(newLastName string) error {
187-
a.AccountV2.LastName = newLastName
187+
a.LastName = newLastName
188188
a.UpdatedAt = time.Now().Unix()
189189
return nil
190190
}
191191

192192
func (a *AccountV2) ChangeLanguage(newLanguage string) error {
193-
a.AccountV2.Language = newLanguage
193+
a.Language = newLanguage
194194
a.UpdatedAt = time.Now().Unix()
195195
return nil
196196
}
197197

198198
func (a *AccountV2) ChangeAvatarImageURL(url string) error {
199-
a.AccountV2.AvatarImageUrl = url
199+
a.AvatarImageUrl = url
200200
a.UpdatedAt = time.Now().Unix()
201201
return nil
202202
}
203203

204204
func (a *AccountV2) ChangeAvatar(image []byte, fileType string) error {
205-
a.AccountV2.AvatarImage = image
206-
a.AccountV2.AvatarFileType = fileType
205+
a.AvatarImage = image
206+
a.AvatarFileType = fileType
207207
a.UpdatedAt = time.Now().Unix()
208208
return nil
209209
}
210210

211211
func (a *AccountV2) ChangeTags(tags []string) error {
212-
a.AccountV2.Tags = tags
212+
a.Tags = tags
213213
a.UpdatedAt = time.Now().Unix()
214214
return nil
215215
}
216216

217217
func (a *AccountV2) ChangeOrganizationRole(role proto.AccountV2_Role_Organization) error {
218-
a.AccountV2.OrganizationRole = role
218+
a.OrganizationRole = role
219219
if role >= proto.AccountV2_Role_Organization_ADMIN {
220-
a.AccountV2.EnvironmentRoles = []*proto.AccountV2_EnvironmentRole{}
220+
a.EnvironmentRoles = []*proto.AccountV2_EnvironmentRole{}
221221
}
222222
a.UpdatedAt = time.Now().Unix()
223223
return nil
224224
}
225225

226226
func (a *AccountV2) ChangeEnvironmentRole(roles []*proto.AccountV2_EnvironmentRole) error {
227-
a.AccountV2.EnvironmentRoles = roles
227+
a.EnvironmentRoles = roles
228228
a.UpdatedAt = time.Now().Unix()
229229
return nil
230230
}
231231

232232
func (a *AccountV2) PatchEnvironmentRole(patchRoles []*proto.AccountV2_EnvironmentRole) error {
233233
for _, p := range patchRoles {
234-
e := getEnvironmentRole(a.AccountV2.EnvironmentRoles, p.EnvironmentId)
234+
e := getEnvironmentRole(a.EnvironmentRoles, p.EnvironmentId)
235235
if e == nil {
236-
a.AccountV2.EnvironmentRoles = append(a.AccountV2.EnvironmentRoles, p)
236+
a.EnvironmentRoles = append(a.EnvironmentRoles, p)
237237
continue
238238
}
239239
e.Role = p.Role
@@ -243,7 +243,7 @@ func (a *AccountV2) PatchEnvironmentRole(patchRoles []*proto.AccountV2_Environme
243243
}
244244

245245
func (a *AccountV2) ChangeLastSeen(lastSeen int64) error {
246-
a.AccountV2.LastSeen = lastSeen
246+
a.LastSeen = lastSeen
247247
a.UpdatedAt = time.Now().Unix()
248248
return nil
249249
}
@@ -258,13 +258,13 @@ func getEnvironmentRole(roles []*proto.AccountV2_EnvironmentRole, envID string)
258258
}
259259

260260
func (a *AccountV2) Enable() error {
261-
a.AccountV2.Disabled = false
261+
a.Disabled = false
262262
a.UpdatedAt = time.Now().Unix()
263263
return nil
264264
}
265265

266266
func (a *AccountV2) Disable() error {
267-
a.AccountV2.Disabled = true
267+
a.Disabled = true
268268
a.UpdatedAt = time.Now().Unix()
269269
return nil
270270
}
@@ -291,17 +291,17 @@ func (a *AccountV2) AddSearchFilter(
291291
EnvironmentId: environmentID,
292292
DefaultFilter: defaultFilter,
293293
}
294-
a.AccountV2.SearchFilters = append(a.AccountV2.SearchFilters, searchFilter)
294+
a.SearchFilters = append(a.SearchFilters, searchFilter)
295295
a.UpdatedAt = time.Now().Unix()
296296
return searchFilter, nil
297297
}
298298

299299
func (a *AccountV2) DeleteSearchFilter(id string) error {
300-
for i, f := range a.AccountV2.SearchFilters {
300+
for i, f := range a.SearchFilters {
301301
if f.Id == id {
302-
a.AccountV2.SearchFilters = append(a.AccountV2.SearchFilters[:i], a.AccountV2.SearchFilters[i+1:]...)
303-
if len(a.AccountV2.SearchFilters) == 0 {
304-
a.AccountV2.SearchFilters = nil
302+
a.SearchFilters = append(a.SearchFilters[:i], a.SearchFilters[i+1:]...)
303+
if len(a.SearchFilters) == 0 {
304+
a.SearchFilters = nil
305305
}
306306
a.UpdatedAt = time.Now().Unix()
307307
return nil
@@ -311,7 +311,7 @@ func (a *AccountV2) DeleteSearchFilter(id string) error {
311311
}
312312

313313
func (a *AccountV2) ChangeSearchFilterName(id string, name string) error {
314-
for _, f := range a.AccountV2.SearchFilters {
314+
for _, f := range a.SearchFilters {
315315
if f.Id == id {
316316
f.Name = name
317317
a.UpdatedAt = time.Now().Unix()
@@ -322,7 +322,7 @@ func (a *AccountV2) ChangeSearchFilterName(id string, name string) error {
322322
}
323323

324324
func (a *AccountV2) ChangeSearchFilterQuery(id string, query string) error {
325-
for _, f := range a.AccountV2.SearchFilters {
325+
for _, f := range a.SearchFilters {
326326
if f.Id == id {
327327
f.Query = query
328328
a.UpdatedAt = time.Now().Unix()
@@ -333,7 +333,7 @@ func (a *AccountV2) ChangeSearchFilterQuery(id string, query string) error {
333333
}
334334

335335
func (a *AccountV2) ChangeDefaultSearchFilter(id string, defaultFilter bool) error {
336-
for _, f := range a.AccountV2.SearchFilters {
336+
for _, f := range a.SearchFilters {
337337
if f.Id == id {
338338
// Since there is only one default setting for a filter target, set the existing default to OFF.
339339
if defaultFilter {
@@ -349,7 +349,7 @@ func (a *AccountV2) ChangeDefaultSearchFilter(id string, defaultFilter bool) err
349349
}
350350

351351
func (a *AccountV2) resetDefaultFilter(targetFilter proto.FilterTargetType, environmentID string) {
352-
for _, f := range a.AccountV2.SearchFilters {
352+
for _, f := range a.SearchFilters {
353353
if f.DefaultFilter &&
354354
targetFilter == f.FilterTargetType &&
355355
environmentID == f.EnvironmentId {

pkg/account/domain/api_key.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ func NewAPIKey(
6060
}
6161

6262
func (a *APIKey) Rename(name string) error {
63-
a.APIKey.Name = name
63+
a.Name = name
6464
a.UpdatedAt = time.Now().Unix()
6565
return nil
6666
}
6767

6868
func (a *APIKey) Enable() error {
69-
a.APIKey.Disabled = false
69+
a.Disabled = false
7070
a.UpdatedAt = time.Now().Unix()
7171
return nil
7272
}
7373

7474
func (a *APIKey) Disable() error {
75-
a.APIKey.Disabled = true
75+
a.Disabled = true
7676
a.UpdatedAt = time.Now().Unix()
7777
return nil
7878
}

pkg/api/cmd/server.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,10 @@ func (s *server) Run(ctx context.Context, metrics metrics.Metrics, logger *zap.L
230230
}
231231

232232
// Add provider-specific options
233-
if pubSubType == factory.Google {
233+
switch pubSubType {
234+
case factory.Google:
234235
factoryOpts = append(factoryOpts, factory.WithProjectID(*s.project))
235-
} else if pubSubType == factory.RedisStream {
236+
case factory.RedisStream:
236237
redisClient, err := redisv3.NewClient(
237238
*s.pubSubRedisAddr,
238239
redisv3.WithPoolSize(*s.pubSubRedisPoolSize),

pkg/auth/api/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ func (s *authService) SwitchOrganization(
418418
zap.String("organizationID", newOrganizationID),
419419
)
420420
}
421-
accountDomain.AccountV2.OrganizationId = newOrganizationID
421+
accountDomain.OrganizationId = newOrganizationID
422422
token, err := s.generateToken(
423423
ctx,
424424
accessToken.Email,
@@ -705,7 +705,7 @@ func (s *authService) generateToken(
705705
}
706706

707707
// Use the account's organization ID
708-
organizationID := accountDomain.AccountV2.OrganizationId
708+
organizationID := accountDomain.OrganizationId
709709

710710
// Create access token
711711
timeNow := time.Now()

pkg/autoops/api/api.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
domainevent "github.com/bucketeer-io/bucketeer/pkg/domainevent/domain"
3636
experimentclient "github.com/bucketeer-io/bucketeer/pkg/experiment/client"
3737
featureclient "github.com/bucketeer-io/bucketeer/pkg/feature/client"
38-
ftstorage "github.com/bucketeer-io/bucketeer/pkg/feature/storage/v2"
3938
v2fs "github.com/bucketeer-io/bucketeer/pkg/feature/storage/v2"
4039
"github.com/bucketeer-io/bucketeer/pkg/locale"
4140
"github.com/bucketeer-io/bucketeer/pkg/log"
@@ -1545,7 +1544,7 @@ func (s *AutoOpsService) ExecuteAutoOps(
15451544
}
15461545
return dt.Err()
15471546
}
1548-
ftStorage := ftstorage.NewFeatureStorage(tx)
1547+
ftStorage := v2fs.NewFeatureStorage(tx)
15491548
feature, err := ftStorage.GetFeature(contextWithTx, autoOpsRule.FeatureId, req.EnvironmentId)
15501549
if err != nil {
15511550
return err
@@ -1698,7 +1697,7 @@ func (s *AutoOpsService) executeAutoOpsNoCommand(
16981697
return dt.Err()
16991698
}
17001699

1701-
ftStorage := ftstorage.NewFeatureStorage(tx)
1700+
ftStorage := v2fs.NewFeatureStorage(tx)
17021701
feature, err := ftStorage.GetFeature(contextWithTx, autoOpsRule.FeatureId, req.EnvironmentId)
17031702
if err != nil {
17041703
return err

0 commit comments

Comments
 (0)