akretion/ooor

View on GitHub
lib/ooor/session.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Session has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Session
    include ActiveSupport::Configurable
    include Transport

    attr_accessor :web_session, :id, :models
Severity: Minor
Found in lib/ooor/session.rb - About 2 hrs to fix

    Method login has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def login(db, username, password, kw={})
          logger.debug "OOOR login - db: #{db}, username: #{username}"
          raise "Cannot login without specifying a database" unless db
          raise "Cannot login without specifying a username" unless username
          raise "Cannot login without specifying a password" unless password
    Severity: Minor
    Found in lib/ooor/session.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

    Method login has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def login(db, username, password, kw={})
          logger.debug "OOOR login - db: #{db}, username: #{username}"
          raise "Cannot login without specifying a database" unless db
          raise "Cannot login without specifying a username" unless username
          raise "Cannot login without specifying a password" unless password
    Severity: Minor
    Found in lib/ooor/session.rb - About 1 hr to fix

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

          def odoo_serie
            if config.user_id # authenticated session
              if config[:server_version_info] # v10 and onward
                config[:server_version_info][0]
              elsif config['partner_id']
      Severity: Minor
      Found in lib/ooor/session.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 define_openerp_model has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def define_openerp_model(options) #TODO param to tell if we define constants or not
            if !models[options[:model]] || options[:reload]# || !scope.const_defined?(model_class_name)
              scope_prefix = options[:scope_prefix]
              scope = scope_prefix ? Object.const_get(scope_prefix) : Object
              model_class_name = class_name_from_model_key(options[:model])
      Severity: Minor
      Found in lib/ooor/session.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 const_get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def const_get(model_key, lang=nil);
            if config[:aliases]
              if lang && alias_data = config[:aliases][lang]
                openerp_model = alias_data[model_key] || model_key
              elsif alias_data = config[:aliases][connection_session['lang'] || :en_US]
      Severity: Minor
      Found in lib/ooor/session.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

      There are no issues that match your filters.

      Category
      Status