Showing 412 of 865 total issues
Method JwkAPIService.DeleteJsonWebKeyExecute
has 7 return statements (exceeds 4 allowed). Open
Open
func (a *JwkAPIService) DeleteJsonWebKeyExecute(r ApiDeleteJsonWebKeyRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
Function NewPersister
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewPersister(ctx context.Context, c *pop.Connection, r Dependencies, config *config.DefaultProvider, extraMigrations []fs.FS, goMigrations []popx.Migration) (*Persister, error) {
Method RegistrySQL.Init
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
ctx context.Context,
skipNetworkInit bool,
migrate bool,
ctxer contextx.Contextualizer,
extraMigrations []fs.FS,
Method Handler.CreateClient
has 7 return statements (exceeds 4 allowed). Open
Open
func (h *Handler) CreateClient(r *http.Request, validator func(context.Context, *Client) error, isDynamic bool) (*Client, error) {
var c Client
if err := json.NewDecoder(r.Body).Decode(&c); err != nil {
return nil, errorsx.WithStack(herodot.ErrBadRequest.WithReasonf("Unable to decode the request body: %s", err))
}
Avoid deeply nested control flow statements. Open
Open
} else if gt == fosite.GrantTypePassword {
if tt == fosite.AccessToken && c.PasswordGrantAccessTokenLifespan.Valid {
cl = &c.PasswordGrantAccessTokenLifespan.Duration
} else if tt == fosite.RefreshToken && c.PasswordGrantRefreshTokenLifespan.Valid {
cl = &c.PasswordGrantRefreshTokenLifespan.Duration
Function TestHandler
has 7 return statements (exceeds 4 allowed). Open
Open
func TestHandler(t *testing.T) {
ctx := context.Background()
reg := internal.NewMockedRegistry(t, &contextx.Default{})
h := client.NewHandler(reg)
reg.WithContextualizer(&contextx.TestContextualizer{})
Method MetadataAPIService.GetVersionExecute
has 7 return statements (exceeds 4 allowed). Open
Open
func (a *MetadataAPIService) GetVersionExecute(r ApiGetVersionRequest) (*GetVersion200Response, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
Avoid deeply nested control flow statements. Open
Open
if tt == fosite.AccessToken && c.JwtBearerGrantAccessTokenLifespan.Valid {
cl = &c.JwtBearerGrantAccessTokenLifespan.Duration
}
Method Persister.flushInactiveTokens
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (p *Persister) flushInactiveTokens(ctx context.Context, notAfter time.Time, limit int, batchSize int, table tableName, lifespan time.Duration) (err error) {
Function BenchmarkClientCredentials
has 7 return statements (exceeds 4 allowed). Open
Open
func BenchmarkClientCredentials(b *testing.B) {
ctx := context.Background()
spans := tracetest.NewSpanRecorder()
tracer := trace.NewTracerProvider(trace.WithSpanProcessor(spans)).Tracer("")
Avoid deeply nested control flow statements. Open
Open
for {
bo := conf.NextBackOff()
require.NotEqual(t, backoff.Stop, bo, "%+v", err)
_, _, err = hydra.JwkAPI.CreateJsonWebKeySet(context.Background(), "hydra.openid.id-token").CreateJsonWebKeySet(hydrac.CreateJsonWebKeySet{
Method Handler.getOidcUserInfo
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (h *Handler) getOidcUserInfo(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
session := NewSessionWithCustomClaims(ctx, h.c, "")
tokenType, ar, err := h.r.OAuth2Provider().IntrospectToken(ctx, fosite.AccessTokenFromRequest(r), fosite.AccessToken, session)
if err != nil {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function createAccessTokenSessionPairwise
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func createAccessTokenSessionPairwise(subject, client string, token string, expiresAt time.Time, fs x.FositeStorer, scopes fosite.Arguments, obfuscated string) {
Avoid deeply nested control flow statements. Open
Open
if dbName != dbal.DriverMySQL {
t.Errorf("an unexpected RFC6749 error with the name %q was returned.\n"+
"Hint: has the refresh token error handling changed in fosite? If so, you need to add further "+
"assertions here to cover the additional errors that are being returned by the handler.\n"+
"DB version: %s\n"+
Avoid deeply nested control flow statements. Open
Open
switch dbName {
case dbal.DriverMySQL:
case dbal.DriverPostgreSQL, dbal.DriverCockroachDB:
var matched bool
for _, errSubstr := range []string{
Function TestUserinfo
has 7 return statements (exceeds 4 allowed). Open
Open
func TestUserinfo(t *testing.T) {
ctx := context.Background()
conf := internal.NewConfigurationWithDefaults()
conf.MustSet(ctx, config.KeyScopeStrategy, "")
conf.MustSet(ctx, config.KeyAuthCodeLifespan, lifespan)
Method Persister.ConfirmLoginSession
has 7 return statements (exceeds 4 allowed). Open
Open
func (p *Persister) ConfirmLoginSession(ctx context.Context, loginSession *flow.LoginSession) (err error) {
ctx, span := p.r.Tracer(ctx).Tracer().Start(ctx, "persistence.sql.ConfirmLoginSession")
defer otelx.End(span, &err)
loginSession.NID = p.NetworkID(ctx)
Function checkTokenResponse
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func checkTokenResponse(token oauth2token) {
if token.RefreshToken == "" {
log.Fatalf("Expected a refresh token but none received: %+v", token)
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method DefaultStrategy.authenticationSession
has 6 return statements (exceeds 4 allowed). Open
Open
func (s *DefaultStrategy) authenticationSession(ctx context.Context, _ http.ResponseWriter, r *http.Request) (*flow.LoginSession, error) {
store, err := s.r.CookieStore(ctx)
if err != nil {
return nil, err
}
Method Flow.HandleLoginRequest
has 6 return statements (exceeds 4 allowed). Open
Open
func (f *Flow) HandleLoginRequest(h *HandledLoginRequest) error {
if f.LoginWasUsed {
return errors.WithStack(x.ErrConflict.WithHint("The login request was already used and can no longer be changed."))
}