Skip to content
This repository was archived by the owner on Dec 6, 2025. It is now read-only.

Commit d2e22f3

Browse files
authored
chore: stylecheck (#918)
1 parent da5ca39 commit d2e22f3

File tree

162 files changed

+1414
-1416
lines changed

Some content is hidden

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

162 files changed

+1414
-1416
lines changed

.golangci.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ linters:
88
- depguard # no need
99
- ireturn # no need
1010
- funlen # we tend to have long funlens, who cares?
11-
- execinquery # deprecated
1211
- goimports # unused
1312
- gochecknoglobals # we currently make use of globals
1413
- godot # petty linter
15-
- gomnd # deprecated
1614
- gomoddirectives # not needed
1715
- gofumpt # false positives
1816
- mnd # too many false-positives
@@ -38,7 +36,6 @@ linters:
3836
- paralleltest # TODO
3937
- protogetter # TODO
4038
- revive # TODO
41-
- stylecheck # TODO
4239
- testpackage # TODO
4340

4441
linters-settings:

libs/common/auth/auth.go

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ import (
1919
// to avoid ambiguity please read: https://wiki.helpwave.de/doc/keycloak-jedzCcERwF
2020

2121
var (
22-
DEFAULT_OAUTH_ISSUER_URL = "https://accounts.helpwave.de/realms/helpwave"
23-
24-
DEFAULT_OAUTH_CLIENT_ID = "helpwave-services"
22+
DefaultOAuthIssuerURL = "https://accounts.helpwave.de/realms/helpwave"
23+
DefaultOAuthClientID = "helpwave-services"
2524
onlyFakeAuthEnabled bool
2625
insecureFakeTokenEnable = false
2726
oauthConfig *oauth2.Config
@@ -40,22 +39,22 @@ type (
4039
organizationIDKey struct{}
4140
)
4241

43-
func GetOAuthIssuerUrl() string {
44-
issuerUrl := hwutil.GetEnvOr("OAUTH_ISSUER_URL", DEFAULT_OAUTH_ISSUER_URL)
45-
if issuerUrl != DEFAULT_OAUTH_ISSUER_URL {
42+
func GetOAuthIssuerURL() string {
43+
issuerURL := hwutil.GetEnvOr("OAUTH_ISSUER_URL", DefaultOAuthIssuerURL)
44+
if issuerURL != DefaultOAuthIssuerURL {
4645
zlog.Warn().
47-
Str("OAUTH_ISSUER_URL", issuerUrl).
46+
Str("OAUTH_ISSUER_URL", issuerURL).
4847
Msg("using custom OAuth issuer url")
4948
}
50-
return issuerUrl
49+
return issuerURL
5150
}
5251

53-
func GetOAuthClientId() string {
54-
clientId := hwutil.GetEnvOr("OAUTH_CLIENT_ID", DEFAULT_OAUTH_CLIENT_ID)
55-
if clientId != DEFAULT_OAUTH_CLIENT_ID {
56-
zlog.Warn().Str("OAUTH_CLIENT_ID", clientId).Msg("using custom OAuth client id")
52+
func GetOAuthClientID() string {
53+
clientID := hwutil.GetEnvOr("OAUTH_CLIENT_ID", DefaultOAuthClientID)
54+
if clientID != DefaultOAuthClientID {
55+
zlog.Warn().Str("OAUTH_CLIENT_ID", clientID).Msg("using custom OAuth client id")
5756
}
58-
return clientId
57+
return clientID
5958
}
6059

6160
func IsOnlyFakeAuthEnabled() bool {
@@ -109,7 +108,7 @@ type IDTokenClaims struct {
109108
}
110109

111110
type OrganizationTokenClaim struct {
112-
Id string `json:"id" validate:"required,uuid"`
111+
ID string `json:"id" validate:"required,uuid"`
113112
Name string `json:"name" validate:"required"`
114113
}
115114

@@ -156,7 +155,7 @@ func VerifyFakeToken(ctx context.Context, token string) (*IDTokenClaims, *time.T
156155
}
157156

158157
claims := IDTokenClaims{}
159-
if err := hwutil.ParseValidJson(plainToken, &claims); err != nil {
158+
if err := hwutil.ParseValidJSON(plainToken, &claims); err != nil {
160159
return nil, nil, fmt.Errorf("VerifyFakeToken: cant parse json: %w", err)
161160
}
162161

@@ -267,13 +266,13 @@ func SetupAuth(ctx context.Context, fakeOnly bool, passedInsecureFakeTokenEnable
267266

268267
insecureFakeTokenEnable = passedInsecureFakeTokenEnable
269268

270-
provider, err := oidc.NewProvider(context.Background(), GetOAuthIssuerUrl())
269+
provider, err := oidc.NewProvider(context.Background(), GetOAuthIssuerURL())
271270
if err != nil {
272271
log.Fatal().Err(err).Send()
273272
}
274273

275274
oauthConfig = &oauth2.Config{
276-
ClientID: GetOAuthClientId(),
275+
ClientID: GetOAuthClientID(),
277276
Endpoint: provider.Endpoint(),
278277
}
279278

libs/common/auth/auth_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestIDTokenClaims_AsExpected(t *testing.T) {
2020
Name: "Test User",
2121
PreferredUsername: "testuser",
2222
Organization: &OrganizationTokenClaim{
23-
Id: "6759b6d7-a864-800c-a2e9-a780a83ec767",
23+
ID: "6759b6d7-a864-800c-a2e9-a780a83ec767",
2424
Name: "Example Org",
2525
},
2626
},
@@ -33,7 +33,7 @@ func TestIDTokenClaims_AsExpected(t *testing.T) {
3333
Name: "Test User",
3434
PreferredUsername: "testuser",
3535
Organization: &OrganizationTokenClaim{
36-
Id: "6759b6d7-a864-800c-a2e9-a780a83ec767",
36+
ID: "6759b6d7-a864-800c-a2e9-a780a83ec767",
3737
Name: "Example Org",
3838
},
3939
},
@@ -47,7 +47,7 @@ func TestIDTokenClaims_AsExpected(t *testing.T) {
4747
Name: "Test User",
4848
PreferredUsername: "testuser",
4949
Organization: &OrganizationTokenClaim{
50-
Id: "6759b6d7-a864-800c-a2e9-a780a83ec767",
50+
ID: "6759b6d7-a864-800c-a2e9-a780a83ec767",
5151
Name: "Example Org",
5252
},
5353
},
@@ -71,7 +71,7 @@ func TestIDTokenClaims_AsExpected(t *testing.T) {
7171
Name: "Test User",
7272
PreferredUsername: "testuser",
7373
Organization: &OrganizationTokenClaim{
74-
Id: "asdasd",
74+
ID: "asdasd",
7575
Name: "Example Org",
7676
},
7777
},
@@ -85,7 +85,7 @@ func TestIDTokenClaims_AsExpected(t *testing.T) {
8585
Name: "Test User",
8686
PreferredUsername: "testuser",
8787
Organization: &OrganizationTokenClaim{
88-
Id: "",
88+
ID: "",
8989
Name: "",
9090
},
9191
},

libs/common/dapr.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func MustNewDaprGRPCClient() *daprc.GRPCClient {
6363
}
6464

6565
// PrepCtxForSvcToSvcCall returns a context that can be used with Dapr specific service to service gRPC calls
66-
func PrepCtxForSvcToSvcCall(ctx context.Context, targetDaprAppId string) (context.Context, context.CancelFunc, error) {
66+
func PrepCtxForSvcToSvcCall(ctx context.Context, targetDaprAppID string) (context.Context, context.CancelFunc, error) {
6767
md, ok := metadata.FromIncomingContext(ctx)
6868
if !ok {
6969
return nil, nil, status.Errorf(codes.Internal, "No incoming metadata in context")
@@ -72,7 +72,7 @@ func PrepCtxForSvcToSvcCall(ctx context.Context, targetDaprAppId string) (contex
7272

7373
timeout := time.Second * 3
7474
ctx, cancel := context.WithTimeout(outgoingCtx, timeout)
75-
ctx = metadata.AppendToOutgoingContext(ctx, "dapr-app-id", targetDaprAppId)
75+
ctx = metadata.AppendToOutgoingContext(ctx, "dapr-app-id", targetDaprAppID)
7676

7777
return ctx, cancel, nil
7878
}

libs/common/hwgrpc/organization_interceptor.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func StreamOrganizationInterceptor(
4949
return next(req, stream)
5050
}
5151

52-
var ErrOrganizationIdMissing = errors.New("organization.id missing in id token")
52+
var ErrOrganizationIDMissing = errors.New("organization.id missing in id token")
5353

5454
// organizationInterceptor parses and injects the organization id of the OIDC claims into the current context
5555
// This is a separate function to allow endpoints to not fail when an organization id is not provided
@@ -62,12 +62,12 @@ func organizationInterceptor(ctx context.Context) (context.Context, error) {
6262
return nil, err
6363
}
6464

65-
if len(claims.Organization.Id) == 0 {
66-
return nil, ErrOrganizationIdMissing
65+
if len(claims.Organization.ID) == 0 {
66+
return nil, ErrOrganizationIDMissing
6767
}
6868

6969
// parse organizationID
70-
organizationID, err := uuid.Parse(claims.Organization.Id)
70+
organizationID, err := uuid.Parse(claims.Organization.ID)
7171
if err != nil {
7272
return nil, status.Errorf(codes.Internal, "invalid organizationID")
7373
}

libs/common/test/grpc.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,19 @@ func AuthenticatedUserClaim(userID string) map[string]interface{} {
7878
// AuthenticatedUserMetadata gives you a ready-to use grpc metadata object
7979
func AuthenticatedUserMetadata(userID string) metadata.MD {
8080
claims := AuthenticatedUserClaim(userID)
81-
claimsJson, err := json.Marshal(claims)
81+
claimsJSON, err := json.Marshal(claims)
8282
if err != nil {
8383
log.Fatal(err)
8484
}
85-
fakeToken := base64.StdEncoding.EncodeToString(claimsJson)
85+
fakeToken := base64.StdEncoding.EncodeToString(claimsJSON)
8686

8787
return metadata.New(map[string]string{
8888
"Authorization": "Bearer " + fakeToken,
8989
})
9090
}
9191

92-
func AuthenticatedUserContext(ctx context.Context, userId string) context.Context {
93-
md := AuthenticatedUserMetadata(userId)
92+
func AuthenticatedUserContext(ctx context.Context, userID string) context.Context {
93+
md := AuthenticatedUserMetadata(userID)
9494
if existing, existed := metadata.FromOutgoingContext(ctx); existed {
9595
md = metadata.Join(md, existing)
9696
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# decaying_lru
1+
# decayinglru
22

33
A module, which allows a service to leverage a redis-powered [LRU](https://en.wikipedia.org/wiki/Least_Recently_Used) which decays.
44
Such a data structure is, for example, needed for `recently-used` tracking.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"fmt"
77
"time"
88

9-
"decaying_lru"
9+
"decayinglru"
1010
)
1111

1212
func must(err error) {
@@ -22,7 +22,7 @@ const (
2222

2323
func main() {
2424
ctx := context.Background()
25-
lru := decaying_lru.Setup(ctx, "example", size, time.Second, inverseP)
25+
lru := decayinglru.Setup(ctx, "example", size, time.Second, inverseP)
2626

2727
must(lru.AddItemForUser(ctx, "test", "1", "abc"))
2828
must(lru.AddItemForUser(ctx, "test", "1", "def"))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module decaying_lru
1+
module decayinglru
22

33
go 1.23
44

0 commit comments

Comments
 (0)