Showing 412 of 865 total issues
Function NewPerformAuthorizationCodeCmd
has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring. Open
func NewPerformAuthorizationCodeCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "authorization-code",
Example: "{{ .CommandPath }} --client-id ... --client-secret ...",
Short: "Example OAuth 2.0 Client performing the OAuth 2.0 Authorize Code Flow",
- 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 Validator.Validate
has 117 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (v *Validator) Validate(ctx context.Context, c *Client) error {
if c.TokenEndpointAuthMethod == "" {
c.TokenEndpointAuthMethod = "client_secret_basic"
} else if c.TokenEndpointAuthMethod == "private_key_jwt" {
if len(c.JSONWebKeysURI) == 0 && c.JSONWebKeys == nil {
AcceptOAuth2ConsentRequest
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
type AcceptOAuth2ConsentRequest struct {
Context interface{} `json:"context,omitempty"`
GrantAccessTokenAudience []string `json:"grant_access_token_audience,omitempty"`
GrantScope []string `json:"grant_scope,omitempty"`
HandledAt *time.Time `json:"handled_at,omitempty"`
Function TestIntrospectorSDK
has 114 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestIntrospectorSDK(t *testing.T) {
ctx := context.Background()
conf := internal.NewConfigurationWithDefaults()
conf.MustSet(ctx, config.KeyScopeStrategy, "wildcard")
conf.MustSet(ctx, config.KeyIssuerURL, "https://foobariss")
Function TestHelperGrantManagerCreateGetDeleteGrant
has 113 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestHelperGrantManagerCreateGetDeleteGrant(t1 GrantManager, km jwk.Manager, parallel bool) func(t *testing.T) {
tokenServicePubKey1 := jose.JSONWebKey{}
tokenServicePubKey2 := jose.JSONWebKey{}
mikePubKey := jose.JSONWebKey{}
Config
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
type Config struct {
deps configDependencies
authorizeEndpointHandlers fosite.AuthorizeEndpointHandlers
tokenEndpointHandlers fosite.TokenEndpointHandlers
Method APIClient.prepareRequest
has 112 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *APIClient) prepareRequest(
ctx context.Context,
path string, method string,
postBody interface{},
headerParams map[string]string,
Function TestJWKSDK
has 111 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestJWKSDK(t *testing.T) {
t.Parallel()
ctx := context.Background()
conf := internal.NewConfigurationWithDefaults()
reg := internal.NewRegistryMemory(t, conf, &contextx.Default{})
Method DefaultStrategy.verifyAuthentication
has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring. Open
func (s *DefaultStrategy) verifyAuthentication(
ctx context.Context,
w http.ResponseWriter,
r *http.Request,
req fosite.AuthorizeRequester,
- 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
File provider.go
has 558 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Copyright © 2022 Ory Corp
// SPDX-License-Identifier: Apache-2.0
package config
Method DefaultStrategy.issueLogoutVerifier
has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring. Open
func (s *DefaultStrategy) issueLogoutVerifier(ctx context.Context, w http.ResponseWriter, r *http.Request) (*flow.LogoutResult, error) {
// There are two types of log out flows:
//
// - RP initiated logout
// - OP initiated logout
- 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
File model_oidc_user_info.go
has 548 lines of code (exceeds 500 allowed). Consider refactoring. Open
/*
Ory Hydra API
Documentation for all of Ory Hydra's APIs.
Function TestHelperCreateGetUpdateDeleteClient
has 103 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestHelperCreateGetUpdateDeleteClient(k string, connection *pop.Connection, t1 Storage, t2 Storage) func(t *testing.T) {
return func(t *testing.T) {
ctx := context.Background()
_, err := t1.GetClient(ctx, "1234")
require.Error(t, err)
Function TestViperProviderValidates
has 103 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestViperProviderValidates(t *testing.T) {
ctx := context.Background()
l := logrusx.New("", "")
c := MustNew(context.Background(), l, configx.WithConfigFiles("../../internal/.hydra.yaml"))
File client.go
has 546 lines of code (exceeds 500 allowed). Consider refactoring. Open
/*
Ory Hydra API
Documentation for all of Ory Hydra's APIs.
Function parameterAddToHeaderOrQuery
has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring. Open
func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) {
var v = reflect.ValueOf(obj)
var value = ""
if v == reflect.ValueOf(nil) {
value = "null"
- 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 Client.GetEffectiveLifespan
has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring. Open
func (c *Client) GetEffectiveLifespan(gt fosite.GrantType, tt fosite.TokenType, fallback time.Duration) time.Duration {
var cl *time.Duration
if gt == fosite.GrantTypeAuthorizationCode {
if tt == fosite.AccessToken && c.AuthorizationCodeGrantAccessTokenLifespan.Valid {
cl = &c.AuthorizationCodeGrantAccessTokenLifespan.Duration
- 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 TestAEAD
has 100 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TestAEAD(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
name string
new func(aead.Dependencies) aead.Cipher
OAuth2TokenExchange
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
type OAuth2TokenExchange struct {
// The access token issued by the authorization server.
AccessToken *string `json:"access_token,omitempty"`
// The lifetime in seconds of the access token. For example, the value \"3600\" denotes that the access token will expire in one hour from the time the response was generated.
ExpiresIn *int64 `json:"expires_in,omitempty"`
OAuth2LogoutRequest
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
type OAuth2LogoutRequest struct {
// Challenge is the identifier (\"logout challenge\") of the logout authentication request. It is used to identify the session.
Challenge *string `json:"challenge,omitempty"`
Client *OAuth2Client `json:"client,omitempty"`
// RequestURL is the original Logout URL requested.