openjaf/cenit

View on GitHub
app/controllers/oauth_controller.rb

Summary

Maintainability
F
3 days
Test Coverage

Method check_index has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

  def check_index
    if request.get?
      @errors << 'Missing client_id.' unless (@client_id = params[:client_id])
      if (@response_type = params[:response_type])
        @errors << 'Invalid response_type.' unless @response_type == 'code'
Severity: Minor
Found in app/controllers/oauth_controller.rb - About 6 hrs to fix

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 callback has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

  def callback
    redirect_uri = nil
    error = params[:error]
    if (cenit_token = CallbackAuthorizationToken.where(token: params[:state] || session[:oauth_state]).first) &&
      (User.current = cenit_token.set_current_tenant!.owner) && (auth = cenit_token.authorization)
Severity: Minor
Found in app/controllers/oauth_controller.rb - About 5 hrs to fix

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 index has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    skip_consent = false
    if request.get?
      if @errors.blank?
        if @app_id && (@app_id.tenant == Account.current || @app_id.registered?)
Severity: Minor
Found in app/controllers/oauth_controller.rb - About 4 hrs to fix

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 token has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

  def token
    response = {}
    response_code = :bad_request
    errors = ''
    token_class =
Severity: Minor
Found in app/controllers/oauth_controller.rb - About 4 hrs to fix

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 callback has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def callback
    redirect_uri = nil
    error = params[:error]
    if (cenit_token = CallbackAuthorizationToken.where(token: params[:state] || session[:oauth_state]).first) &&
      (User.current = cenit_token.set_current_tenant!.owner) && (auth = cenit_token.authorization)
Severity: Major
Found in app/controllers/oauth_controller.rb - About 2 hrs to fix

    Method index has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def index
        skip_consent = false
        if request.get?
          if @errors.blank?
            if @app_id && (@app_id.tenant == Account.current || @app_id.registered?)
    Severity: Minor
    Found in app/controllers/oauth_controller.rb - About 1 hr to fix

      Method token has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def token
          response = {}
          response_code = :bad_request
          errors = ''
          token_class =
      Severity: Minor
      Found in app/controllers/oauth_controller.rb - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status