Showing 402 of 849 total issues
Method APIClient.decode
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) {
if len(b) == 0 {
return nil
}
if s, ok := v.(*string); ok {
Function TestGetOrGenerateKeys
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestGetOrGenerateKeys(t *testing.T) {
t.Parallel()
reg := internal.NewMockedRegistry(t, &contextx.Default{})
setId := uuid.NewUUID().String()
Method Handler.rejectOAuth2LoginRequest
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (h *Handler) rejectOAuth2LoginRequest(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
ctx := r.Context()
challenge := stringsx.Coalesce(
r.URL.Query().Get("login_challenge"),
Function Test_toSDKFriendlyJSONWebKey
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func Test_toSDKFriendlyJSONWebKey(t *testing.T) {
publicJWK := []byte(`{
"kty": "RSA",
"e": "AQAB",
"use": "sig",
Function getRefreshRequests
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func getRefreshRequests(uniqueName string, lifespan time.Duration) []*fosite.AccessRequest {
var tokenSignature = "4c7c7e8b3a77ad0c3ec846a21653c48b45dbfa31" //nolint:gosec
return []*fosite.AccessRequest{
{
GrantTypes: []string{
Function purge
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func purge(cmd *cobra.Command, args []string, sl *servicelocatorx.Options, dOpts []driver.OptionsModifier) error {
ctx := cmd.Context()
var d driver.Registry
co := []configx.OptionModifier{
Method Handler.acceptOAuth2LoginRequest
has 10 return statements (exceeds 4 allowed). Open
Open
func (h *Handler) acceptOAuth2LoginRequest(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
ctx := r.Context()
challenge := stringsx.Coalesce(
r.URL.Query().Get("login_challenge"),
Function SaneMockHandleConsentRequest
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func SaneMockHandleConsentRequest(t *testing.T, m consent.Manager, f *flow.Flow, c *flow.OAuth2ConsentRequest, authAt time.Time, rememberFor int, remember bool, hasError bool) *flow.AcceptOAuth2ConsentRequest {
Method DefaultStrategy.requestAuthentication
has 10 return statements (exceeds 4 allowed). Open
Open
func (s *DefaultStrategy) requestAuthentication(ctx context.Context, w http.ResponseWriter, r *http.Request, ar fosite.AuthorizeRequester) (err error) {
ctx, span := trace.SpanFromContext(ctx).TracerProvider().Tracer("").Start(ctx, "DefaultStrategy.requestAuthentication")
defer otelx.End(span, &err)
prompt := stringsx.Splitx(ar.GetRequestForm().Get("prompt"), " ")
Function MockConsentRequest
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func MockConsentRequest(key string, remember bool, rememberFor int, hasError bool, skip bool, authAt bool, loginChallengeBase string, network string) (c *flow.OAuth2ConsentRequest, h *flow.AcceptOAuth2ConsentRequest, f *flow.Flow) {
Method OidcApiService.CreateVerifiableCredentialExecute
has 10 return statements (exceeds 4 allowed). Open
Open
func (a *OidcApiService) CreateVerifiableCredentialExecute(r ApiCreateVerifiableCredentialRequest) (*VerifiableCredentialResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
Function GetOrCreateTLSCertificate
has 10 return statements (exceeds 4 allowed). Open
Open
func GetOrCreateTLSCertificate(ctx context.Context, d driver.Registry, iface config.ServeInterface, stopReload <-chan struct{}) func(*tls.ClientHelloInfo) (*tls.Certificate, error) {
lock.Lock()
defer lock.Unlock()
// check if certificates are configured
Method APIClient.prepareRequest
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
ctx context.Context,
path string, method string,
postBody interface{},
headerParams map[string]string,
queryParams url.Values,
Function NewKeysImportCmd
has 10 return statements (exceeds 4 allowed). Open
Open
func NewKeysImportCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "jwk set-id file-1 [file-2] [file-n]",
Args: cobra.MinimumNArgs(1),
Example: `{{ .CommandPath }} my-set ./path/to/jwk.json ./path/to/jwk-2.json --format json
Function serve
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
ctx context.Context,
d driver.Registry,
cmd *cobra.Command,
wg *sync.WaitGroup,
iface config.ServeInterface,
Method Handler.oAuth2Authorize
has 10 return statements (exceeds 4 allowed). Open
Open
func (h *Handler) oAuth2Authorize(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
ctx := r.Context()
authorizeRequest, err := h.r.OAuth2Provider().NewAuthorizeRequest(ctx, r)
if err != nil {
Method OAuth2ApiService.RejectOAuth2LoginRequestExecute
has 9 return statements (exceeds 4 allowed). Open
Open
func (a *OAuth2ApiService) RejectOAuth2LoginRequestExecute(r ApiRejectOAuth2LoginRequestRequest) (*OAuth2RedirectTo, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
Function TestLogoutFlows
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
Open
func TestLogoutFlows(t *testing.T) {
ctx := context.Background()
fakeKratos := kratos.NewFake()
reg := internal.NewMockedRegistry(t, &contextx.Default{})
reg.Config().MustSet(ctx, config.KeyAccessTokenStrategy, "opaque")
- 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 OAuth2ApiService.AcceptOAuth2ConsentRequestExecute
has 9 return statements (exceeds 4 allowed). Open
Open
func (a *OAuth2ApiService) AcceptOAuth2ConsentRequestExecute(r ApiAcceptOAuth2ConsentRequestRequest) (*OAuth2RedirectTo, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
Method OAuth2ApiService.AcceptOAuth2LogoutRequestExecute
has 9 return statements (exceeds 4 allowed). Open
Open
func (a *OAuth2ApiService) AcceptOAuth2LogoutRequestExecute(r ApiAcceptOAuth2LogoutRequestRequest) (*OAuth2RedirectTo, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile