Showing 412 of 865 total issues
Method APIClient.decode
has 15 return statements (exceeds 4 allowed). 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 {
Method OAuth2APIService.RevokeOAuth2LoginSessionsExecute
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (a *OAuth2APIService) RevokeOAuth2LoginSessionsExecute(r ApiRevokeOAuth2LoginSessionsRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
Method OidcUserInfo.ToMap
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (o OidcUserInfo) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if !IsNil(o.Birthdate) {
toSerialize["birthdate"] = o.Birthdate
}
Method DefaultStrategy.forwardConsentRequest
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *DefaultStrategy) forwardConsentRequest(
ctx context.Context,
w http.ResponseWriter,
r *http.Request,
ar fosite.AuthorizeRequester,
Function run
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const run = (client) => {
cy.visit(
`${Cypress.env("client_url")}/${path}/code?client_id=${
client_id || client.client_id
}&client_secret=${client_secret || client.client_secret}&scope=${(
Function main
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func main() {
flag.Parse()
conf := oauth2.Config{
ClientID: os.Getenv("OAUTH2_CLIENT_ID"),
ClientSecret: os.Getenv("OAUTH2_CLIENT_SECRET"),
Method OAuth2APIService.DeleteOAuth2TokenExecute
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (a *OAuth2APIService) DeleteOAuth2TokenExecute(r ApiDeleteOAuth2TokenRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
Function TestGetLoginRequest
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestGetLoginRequest(t *testing.T) {
for k, tc := range []struct {
exists bool
handled bool
status int
Method OAuth2APIService.RejectOAuth2LogoutRequestExecute
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (a *OAuth2APIService) RejectOAuth2LogoutRequestExecute(r ApiRejectOAuth2LogoutRequestRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
Function RegisterCommandRecursive
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func RegisterCommandRecursive(parent *cobra.Command, slOpts []servicelocatorx.Option, dOpts []driver.OptionsModifier, cOpts []configx.OptionModifier) {
createCmd := NewCreateCmd()
createCmd.AddCommand(
NewCreateClientsCommand(),
NewCreateJWKSCmd(),
Function TestImportClient
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestImportClient(t *testing.T) {
ctx := context.Background()
c := cmd.NewImportClientCmd()
reg := setup(t, c)
Function TestGetOrCreateTLSCertificate
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestGetOrCreateTLSCertificate(t *testing.T) {
certPath, keyPath, cert, priv := testhelpers.GenerateTLSCertificateFilesForTests(t)
logger := logrusx.New("", "")
logger.Logger.ExitFunc = func(code int) { t.Fatalf("Logger called os.Exit(%v)", code) }
hook := test.NewLocal(logger.Logger)
Function executeHookAndUpdateSession
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func executeHookAndUpdateSession(ctx context.Context, reg x.HTTPClientProvider, hookConfig *config.HookConfig, reqBodyBytes []byte, session *Session) error {
req, err := retryablehttp.NewRequestWithContext(ctx, http.MethodPost, hookConfig.URL, bytes.NewReader(reqBodyBytes))
if err != nil {
return errorsx.WithStack(
fosite.ErrServerError.
Function TestHelperManagerKey
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestHelperManagerKey(m Manager, algo string, keys *jose.JSONWebKeySet, suffix string) func(t *testing.T) {
priv := canonicalizeThumbprints(keys.Key(suffix))
var pub []jose.JSONWebKey
for _, k := range priv {
pub = append(pub, canonicalizeThumbprints([]jose.JSONWebKey{k.Public()})...)
Function TestPublicHealthHandler
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestPublicHealthHandler(t *testing.T) {
ctx := context.Background()
doCORSRequest := func(t *testing.T, endpoint string) *http.Response {
req, err := http.NewRequest(http.MethodGet, endpoint, nil)
Function TestUnmarshalSession
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestUnmarshalSession(t *testing.T) {
expect := &Session{
DefaultSession: &openid.DefaultSession{
Claims: &jwt.IDTokenClaims{
JTI: "",
Function TestLogoutFlows
has 13 return statements (exceeds 4 allowed). 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")
Method OAuth2APIService.SetOAuth2ClientExecute
has 13 return statements (exceeds 4 allowed). Open
Open
func (a *OAuth2APIService) SetOAuth2ClientExecute(r ApiSetOAuth2ClientRequest) (*OAuth2Client, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
Function TestStrategyLoginConsentNext
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
Open
func TestStrategyLoginConsentNext(t *testing.T) {
ctx := context.Background()
reg := internal.NewMockedRegistry(t, &contextx.Default{})
reg.Config().MustSet(ctx, config.KeyAccessTokenStrategy, "opaque")
reg.Config().MustSet(ctx, config.KeyConsentRequestMaxAge, time.Hour)
- 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 getGrantRequests
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func getGrantRequests(uniqueName string, lifespan time.Duration) []*createGrantRequest {
return []*createGrantRequest{
{
grant: trust.Grant{
ID: uuid.New().String(),