NoamB/sorcery

View on GitHub

Showing 8 of 14 total issues

Method included has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def self.included(base)
          base.send(:include, InstanceMethods)

          require 'sorcery/providers/base'
          require 'sorcery/providers/facebook'
Severity: Minor
Found in lib/sorcery/controller/submodules/external.rb - About 1 hr to fix

    Method included has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def self.included(base)
              base.sorcery_config.class_eval do
                attr_accessor :activation_state_attribute_name,               # the attribute name to hold activation state
                                                                              # (active/pending).
    
    
    Severity: Minor
    Found in lib/sorcery/model/submodules/user_activation.rb - About 1 hr to fix

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

            def copy_migration_files
              # Copy core migration file in all cases except when you pass --only-submodules.
              return unless defined?(Sorcery::Generators::InstallGenerator::ActiveRecord)
              migration_template "migration/core.rb", "db/migrate/sorcery_core.rb", migration_class_name: migration_class_name unless only_submodules?
      
      
      Severity: Minor
      Found in lib/generators/sorcery/install_generator.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 user_attrs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

                def user_attrs(user_info_mapping, user_hash)
                  attrs = {}
                  user_info_mapping.each do |k,v|
                    if (varr = v.split("/")).size > 1
                      attribute_value = varr.inject(user_hash[:user_info]) {|hash, value| hash[value]} rescue nil
      Severity: Minor
      Found in lib/sorcery/controller/submodules/external.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 authenticate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def authenticate(*credentials)
              raise ArgumentError, "at least 2 arguments required" if credentials.size < 2
      
              return false if credentials[0].blank?
      
      
      Severity: Minor
      Found in lib/sorcery/model.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 realm_name_by_controller has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

                def realm_name_by_controller
                  if defined?(ActionController::Base)
                    current_controller = self.class
                    while current_controller != ActionController::Base
                      result = Config.controller_to_realm_map[current_controller.controller_name]
      Severity: Minor
      Found in lib/sorcery/controller/submodules/http_basic_auth.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 load_from_token has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def load_from_token(token, token_attr_name, token_expiration_date_attr)
                return nil if token.blank?
                user = sorcery_adapter.find_by_token(token_attr_name,token)
                if !user.blank? && !user.send(token_expiration_date_attr).nil?
                  return Time.now.in_time_zone < user.send(token_expiration_date_attr) ? user : nil
      Severity: Minor
      Found in lib/sorcery/model/temporary_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 find_by_credentials has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def find_by_credentials(credentials)
                relation = nil
      
                @klass.sorcery_config.username_attribute_names.each do |attribute|
                  if @klass.sorcery_config.downcase_username_before_authenticating
      Severity: Minor
      Found in lib/sorcery/adapters/active_record_adapter.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