doorkeeper-gem/doorkeeper

View on GitHub

Showing 25 of 25 total issues

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

    def validate_each(record, attribute, value)
      if value.blank?
        return if Doorkeeper.config.allow_blank_redirect_uri?(record)

        record.errors.add(attribute, :blank)
Severity: Minor
Found in lib/doorkeeper/orm/active_record/redirect_uri_validator.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 option has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def option(name, options = {})
        attribute = options[:as] || name
        attribute_builder = options[:builder_class]

        builder_class.instance_eval do
Severity: Minor
Found in lib/doorkeeper/config/option.rb - About 2 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 PreAuthorization has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

    class PreAuthorization
      include Validations

      validate :client_id, error: Errors::InvalidRequest
      validate :client, error: Errors::InvalidClient
Severity: Minor
Found in lib/doorkeeper/oauth/pre_authorization.rb - About 2 hrs to fix

    Method option has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def option(name, options = {})
            attribute = options[:as] || name
            attribute_builder = options[:builder_class]
    
            builder_class.instance_eval do
    Severity: Minor
    Found in lib/doorkeeper/config/option.rb - About 1 hr to fix

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

          def redirect_or_render(auth)
            if auth.redirectable?
              if Doorkeeper.configuration.api_only
                if pre_auth.form_post_response?
                  render(
      Severity: Minor
      Found in app/controllers/doorkeeper/authorizations_controller.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

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

      module Doorkeeper
        # Copies main Doorkeeper migration into parent Rails application.
        #
        class MigrationGenerator < ::Rails::Generators::Base
          include ::Rails::Generators::Migration
      Severity: Major
      Found in lib/generators/doorkeeper/migration_generator.rb and 4 other locations - About 55 mins to fix
      lib/generators/doorkeeper/application_owner_generator.rb on lines 6..30
      lib/generators/doorkeeper/confidential_applications_generator.rb on lines 6..30
      lib/generators/doorkeeper/pkce_generator.rb on lines 6..30
      lib/generators/doorkeeper/remove_applications_secret_not_null_constraint_generator.rb on lines 6..30

      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 46.

      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 5 locations. Consider refactoring.
      Open

      module Doorkeeper
        # Generates migration with PKCE required database columns for
        # Doorkeeper tables.
        #
        class PkceGenerator < ::Rails::Generators::Base
      Severity: Major
      Found in lib/generators/doorkeeper/pkce_generator.rb and 4 other locations - About 55 mins to fix
      lib/generators/doorkeeper/application_owner_generator.rb on lines 6..30
      lib/generators/doorkeeper/confidential_applications_generator.rb on lines 6..30
      lib/generators/doorkeeper/migration_generator.rb on lines 6..29
      lib/generators/doorkeeper/remove_applications_secret_not_null_constraint_generator.rb on lines 6..30

      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 46.

      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 5 locations. Consider refactoring.
      Open

      module Doorkeeper
        # Generates migration to add confidential column to Doorkeeper
        # applications table.
        #
        class ConfidentialApplicationsGenerator < ::Rails::Generators::Base
      lib/generators/doorkeeper/application_owner_generator.rb on lines 6..30
      lib/generators/doorkeeper/migration_generator.rb on lines 6..29
      lib/generators/doorkeeper/pkce_generator.rb on lines 6..30
      lib/generators/doorkeeper/remove_applications_secret_not_null_constraint_generator.rb on lines 6..30

      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 46.

      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 5 locations. Consider refactoring.
      Open

      module Doorkeeper
        # Generates migration to add reference to owner of the
        # Doorkeeper application.
        #
        class ApplicationOwnerGenerator < ::Rails::Generators::Base
      Severity: Major
      Found in lib/generators/doorkeeper/application_owner_generator.rb and 4 other locations - About 55 mins to fix
      lib/generators/doorkeeper/confidential_applications_generator.rb on lines 6..30
      lib/generators/doorkeeper/migration_generator.rb on lines 6..29
      lib/generators/doorkeeper/pkce_generator.rb on lines 6..30
      lib/generators/doorkeeper/remove_applications_secret_not_null_constraint_generator.rb on lines 6..30

      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 46.

      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 5 locations. Consider refactoring.
      Open

      module Doorkeeper
        # Generates migration with which drops NOT NULL constraint and allows not
        # to bloat the database with redundant secret value.
        #
        class RemoveApplicationSecretNotNullConstraint < ::Rails::Generators::Base
      lib/generators/doorkeeper/application_owner_generator.rb on lines 6..30
      lib/generators/doorkeeper/confidential_applications_generator.rb on lines 6..30
      lib/generators/doorkeeper/migration_generator.rb on lines 6..29
      lib/generators/doorkeeper/pkce_generator.rb on lines 6..30

      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 46.

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

            def token_strategy(grant_type)
              raise Errors::MissingRequiredParameter, :grant_type if grant_type.blank?
      
              grant_flow = token_flows.detect do |flow|
                flow.matches_grant_type?(grant_type)
      Severity: Minor
      Found in lib/doorkeeper/request.rb - About 55 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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(server, client, credentials, resource_owner, parameters = {})
      Severity: Minor
      Found in lib/doorkeeper/oauth/password_access_token_request.rb - About 35 mins to fix

        Method find_or_create_access_token has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def find_or_create_access_token(client, resource_owner, scopes, custom_attributes, server)
        Severity: Minor
        Found in lib/doorkeeper/oauth/base_request.rb - About 35 mins to fix

          Method call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def call(client, scopes, attributes = {})
                    existing_token = nil
          
                    if lookup_existing_token?
                      existing_token = find_active_existing_token_for(client, scopes, attributes)
          Severity: Minor
          Found in lib/doorkeeper/oauth/client_credentials/creator.rb - About 35 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 7 (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 if credentials.present?
          Severity: Minor
          Found in lib/doorkeeper/oauth/client/credentials.rb - About 35 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 matches? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def self.matches?(url, client_url)
                    url = as_uri(url)
                    client_url = as_uri(client_url)
          
                    unless client_url.query.nil?
          Severity: Minor
          Found in lib/doorkeeper/oauth/helpers/uri_checker.rb - About 35 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

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

              def token_generator
                generator_name = Doorkeeper.config.access_token_generator
                generator = generator_name.constantize
          
                return generator if generator.respond_to?(:generate)
          Severity: Minor
          Found in lib/doorkeeper/models/access_token_mixin.rb and 1 other location - About 35 mins to fix
          lib/doorkeeper/orm/active_record/mixins/application.rb on lines 107..115

          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 34.

          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

                def secret_generator
                  generator_name = Doorkeeper.config.application_secret_generator
                  generator = generator_name.constantize
          
                  return generator if generator.respond_to?(:generate)
          Severity: Minor
          Found in lib/doorkeeper/orm/active_record/mixins/application.rb and 1 other location - About 35 mins to fix
          lib/doorkeeper/models/access_token_mixin.rb on lines 503..511

          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 34.

          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 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

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

                def extract_serializable_attributes(options = {})
                  opts = options.try(:dup) || {}
                  only = Array.wrap(opts[:only]).map(&:to_s)
          
                  only = if only.blank?
          Severity: Minor
          Found in lib/doorkeeper/orm/active_record/mixins/application.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