Showing 402 of 849 total issues
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"),
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=${(
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
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 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
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 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 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 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 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 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()})...)
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 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")
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(),
Method JwkApiService.DeleteJsonWebKeyExecute
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (a *JwkApiService) DeleteJsonWebKeyExecute(r ApiDeleteJsonWebKeyRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
Function TestJWTBearer
has 12 return statements (exceeds 4 allowed). Open
Open
func TestJWTBearer(t *testing.T) {
ctx := context.Background()
reg := internal.NewMockedRegistry(t, &contextx.Default{})
reg.Config().MustSet(ctx, config.KeyAccessTokenStrategy, "opaque")
_, admin := testhelpers.NewOAuth2Server(ctx, t, reg)
Method OAuth2ApiService.DeleteTrustedOAuth2JwtGrantIssuerExecute
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (a *OAuth2ApiService) DeleteTrustedOAuth2JwtGrantIssuerExecute(r ApiDeleteTrustedOAuth2JwtGrantIssuerRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
Method OidcApiService.DeleteOidcDynamicClientExecute
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (a *OidcApiService) DeleteOidcDynamicClientExecute(r ApiDeleteOidcDynamicClientRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile