NoamB/sorcery

View on GitHub

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

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

            def process_callback(params, session)
              args = {
                oauth_verifier:       params[:oauth_verifier],
                request_token:        session[:request_token],
                request_token_secret: session[:request_token_secret]
      Severity: Minor
      Found in lib/sorcery/providers/xing.rb and 3 other locations - About 25 mins to fix
      lib/sorcery/providers/jira.rb on lines 64..72
      lib/sorcery/providers/linkedin.rb on lines 53..61
      lib/sorcery/providers/twitter.rb on lines 46..54

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

      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

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

            def process_callback(params, session)
              args = {
                oauth_verifier:       params[:oauth_verifier],
                request_token:        session[:request_token],
                request_token_secret: session[:request_token_secret]
      Severity: Minor
      Found in lib/sorcery/providers/linkedin.rb and 3 other locations - About 25 mins to fix
      lib/sorcery/providers/jira.rb on lines 64..72
      lib/sorcery/providers/twitter.rb on lines 46..54
      lib/sorcery/providers/xing.rb on lines 51..59

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

      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

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

            def process_callback(params, session)
              args = {
                oauth_verifier:       params[:oauth_verifier],
                request_token:        session[:request_token],
                request_token_secret: session[:request_token_secret]
      Severity: Minor
      Found in lib/sorcery/providers/twitter.rb and 3 other locations - About 25 mins to fix
      lib/sorcery/providers/jira.rb on lines 64..72
      lib/sorcery/providers/linkedin.rb on lines 53..61
      lib/sorcery/providers/xing.rb on lines 51..59

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

      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

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

            def process_callback(params, session)
              args = {
                oauth_verifier:       params[:oauth_verifier],
                request_token:        session[:request_token],
                request_token_secret: session[:request_token_secret]
      Severity: Minor
      Found in lib/sorcery/providers/jira.rb and 3 other locations - About 25 mins to fix
      lib/sorcery/providers/linkedin.rb on lines 53..61
      lib/sorcery/providers/twitter.rb on lines 46..54
      lib/sorcery/providers/xing.rb on lines 51..59

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

      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 get_user_hash(access_token)
              response = access_token.get(user_info_url)
      
              auth_hash(access_token).tap do |h|
                h[:user_info] = JSON.parse(response.body)
      Severity: Minor
      Found in lib/sorcery/providers/google.rb and 1 other location - About 20 mins to fix
      lib/sorcery/providers/facebook.rb on lines 32..37

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

      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 get_user_hash(access_token)
              response = access_token.get(user_info_path)
      
              auth_hash(access_token).tap do |h|
                h[:user_info] = JSON.parse(response.body)
      Severity: Minor
      Found in lib/sorcery/providers/facebook.rb and 1 other location - About 20 mins to fix
      lib/sorcery/providers/google.rb on lines 25..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 27.

      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

      Severity
      Category
      Status
      Source
      Language