applicake/doorkeeper

View on GitHub

Showing 17 of 17 total issues

Method validate_each has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_each(record, attribute, value)
    if value.blank?
      record.errors.add(attribute, :blank)
    else
      value.split.each do |val|
Severity: Minor
Found in app/validators/redirect_uri_validator.rb - About 3 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

Class Config has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Config
    class Builder
      def initialize(&block)
        @config = Config.new
        instance_eval(&block)
Severity: Minor
Found in lib/doorkeeper/config.rb - About 2 hrs to fix

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

    module Doorkeeper
      class MigrationGenerator < ::Rails::Generators::Base
        include ::Rails::Generators::Migration
        source_root File.expand_path('templates', __dir__)
        desc 'Installs Doorkeeper migration file.'
    Severity: Major
    Found in lib/generators/doorkeeper/migration_generator.rb and 3 other locations - About 1 hr to fix
    lib/generators/doorkeeper/application_owner_generator.rb on lines 6..28
    lib/generators/doorkeeper/confidential_applications_generator.rb on lines 6..28
    lib/generators/doorkeeper/pkce_generator.rb on lines 6..28

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 52.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

    module Doorkeeper
      class ConfidentialApplicationsGenerator < ::Rails::Generators::Base
        include ::Rails::Generators::Migration
        source_root File.expand_path('templates', __dir__)
        desc 'Add confidential column to Doorkeeper applications'
    lib/generators/doorkeeper/application_owner_generator.rb on lines 6..28
    lib/generators/doorkeeper/migration_generator.rb on lines 6..28
    lib/generators/doorkeeper/pkce_generator.rb on lines 6..28

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 52.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

    module Doorkeeper
      class PkceGenerator < ::Rails::Generators::Base
        include ::Rails::Generators::Migration
        source_root File.expand_path('templates', __dir__)
        desc 'Provide support for PKCE.'
    Severity: Major
    Found in lib/generators/doorkeeper/pkce_generator.rb and 3 other locations - About 1 hr to fix
    lib/generators/doorkeeper/application_owner_generator.rb on lines 6..28
    lib/generators/doorkeeper/confidential_applications_generator.rb on lines 6..28
    lib/generators/doorkeeper/migration_generator.rb on lines 6..28

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 52.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

    module Doorkeeper
      class ApplicationOwnerGenerator < ::Rails::Generators::Base
        include ::Rails::Generators::Migration
        source_root File.expand_path('templates', __dir__)
        desc 'Provide support for client application ownership.'
    Severity: Major
    Found in lib/generators/doorkeeper/application_owner_generator.rb and 3 other locations - About 1 hr to fix
    lib/generators/doorkeeper/confidential_applications_generator.rb on lines 6..28
    lib/generators/doorkeeper/migration_generator.rb on lines 6..28
    lib/generators/doorkeeper/pkce_generator.rb on lines 6..28

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 52.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method option has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def option(name, options = {})
            attribute = options[:as] || name
            attribute_builder = options[:builder_class]
    
            Builder.instance_eval do
    Severity: Minor
    Found in lib/doorkeeper/config.rb - About 1 hr 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 validate_code_verifier has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def validate_code_verifier
            return true unless grant.uses_pkce? || code_verifier
            return false unless grant.pkce_supported?
    
            if grant.code_challenge_method == 'S256'
    Severity: Minor
    Found in lib/doorkeeper/oauth/authorization_code_request.rb - About 45 mins 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 from_request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

              def from_request(request, *credentials_methods)
                credentials_methods.inject(nil) do |_, method|
                  method = self.method(method) if method.is_a?(Symbol)
                  credentials = Credentials.new(*method.call(request))
                  break credentials unless credentials.blank?
    Severity: Minor
    Found in lib/doorkeeper/oauth/client/credentials.rb - About 45 mins 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 find_or_create_for has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def find_or_create_for(application, resource_owner_id, scopes, expires_in, use_refresh_token)
    Severity: Minor
    Found in lib/doorkeeper/models/access_token_mixin.rb - About 35 mins to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              flash[:notice] = I18n.t(:notice, scope: %i[doorkeeper flash applications update])
      
              respond_to do |format|
                format.html { redirect_to oauth_application_url(@application) }
                format.json { render json: @application }
      Severity: Minor
      Found in app/controllers/doorkeeper/applications_controller.rb and 1 other location - About 25 mins to fix
      app/controllers/doorkeeper/applications_controller.rb on lines 34..38

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 31.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              flash[:notice] = I18n.t(:notice, scope: %i[doorkeeper flash applications create])
      
              respond_to do |format|
                format.html { redirect_to oauth_application_url(@application) }
                format.json { render json: @application }
      Severity: Minor
      Found in app/controllers/doorkeeper/applications_controller.rb and 1 other location - About 25 mins to fix
      app/controllers/doorkeeper/applications_controller.rb on lines 52..56

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 31.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Method validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate
            @error = nil
      
            self.class.validations.each do |validation|
              @error = validation[:options][:error] unless send("validate_#{validation[:attribute]}")
      Severity: Minor
      Found in lib/doorkeeper/validations.rb - About 25 mins 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 authorized? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def authorized?
            return unless token.present?
            # Client is confidential, therefore client authentication & authorization
            # is required
            if token.application_id? && token.application.confidential?
      Severity: Minor
      Found in app/controllers/doorkeeper/tokens_controller.rb - About 25 mins 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 authorize! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def authorize!
              # Requested client authorization
              if server.credentials
                @error = :invalid_client unless authorized_client
              else
      Severity: Minor
      Found in lib/doorkeeper/oauth/token_introspection.rb - About 25 mins 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 from_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def from_request(request, *methods)
                methods.inject(nil) do |_, method|
                  method = self.method(method) if method.is_a?(Symbol)
                  credentials = method.call(request)
                  break credentials unless credentials.blank?
      Severity: Minor
      Found in lib/doorkeeper/oauth/token.rb - About 25 mins 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 by_uid_and_secret has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def by_uid_and_secret(uid, secret)
              app = by_uid(uid)
              return unless app
              return app if secret.blank? && !app.confidential?
              return unless app.secret_matches?(secret)
      Severity: Minor
      Found in lib/doorkeeper/models/application_mixin.rb - About 25 mins 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

      Severity
      Category
      Status
      Source
      Language