akretion/ooor

View on GitHub

Showing 60 of 60 total issues

Method inject_includes! has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

        def inject_includes!(active_resources, options)
          (options[:includes] || []).each do |key|
            if key.is_a?(Hash) # recursive includes
              sub_options = key.values.first
              if sub_options.is_a?(Array) # like Rails User.includes(:address, friends: [:address, :followers])
Severity: Minor
Found in lib/ooor/relation/finder_methods.rb - About 4 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 Base has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Base < Ooor::MiniActiveResource
    include Naming, TypeCasting, Serialization, ReflectionOoor, Reflection
    include Associations, Report, FinderMethods, FieldMethods, AutosaveAssociation, NestedAttributes

    # ********************** class methods ************************************
Severity: Minor
Found in lib/ooor/base.rb - About 2 hrs to fix

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

            def parse_connection_string(cs)
              if cs.start_with?('ooor://') && ! cs.index('@')
                cs.sub!(/^ooor:\/\//, '@')
              end
      
      
      Severity: Minor
      Found in lib/ooor.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 save_collection_association has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

            def save_collection_association(reflection)
      #        if association = association_instance_get(reflection.name)
              if target = @loaded_associations[reflection.name] #TODO use a real Association wrapper
                association = OpenStruct.new(target: target)
                autosave = reflection.options[:autosave]
      Severity: Minor
      Found in lib/ooor/autosave_association.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

      Consider simplifying this complex logical expression.
      Open

                if @session.config[:force_xml_rpc]
                  domain = to_openerp_domain(options[:domain] || options[:conditions] || [])
                  ids = rpc_execute('search', domain, options[:offset] || 0, options[:limit] || false,  options[:order] || false, context.dup)
                  records = rpc_execute('read', ids, fields, context.dup)
                else
      Severity: Critical
      Found in lib/ooor/relation/finder_methods.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

        Class Relation has 21 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Relation
            attr_reader :klass, :loaded
            attr_accessor :options, :count_field, :includes_values, :eager_load_values, :preload_values,
                          :select_values, :group_values, :order_values, :reorder_flag, :joins_values, :where_values, :having_values,
                          :limit_value, :offset_value, :lock_value, :readonly_value, :create_with_value, :from_value, :page_value, :per_value
        Severity: Minor
        Found in lib/ooor/relation.rb - About 2 hrs to fix

          Method parse_connection_string has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def parse_connection_string(cs)
                  if cs.start_with?('ooor://') && ! cs.index('@')
                    cs.sub!(/^ooor:\/\//, '@')
                  end
          
          
          Severity: Major
          Found in lib/ooor.rb - About 2 hrs to fix

            Method cast_association has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def cast_association(k)
                  if self.class.one2many_associations[k]
                    if @loaded_associations[k]
                      v = @loaded_associations[k].select {|i| i.changed?}
                      v = @associations[k] if v.empty?
            Severity: Minor
            Found in lib/ooor/type_casting.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 get_dependencies has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.get_dependencies(modules)
                dependency_modules = []
                modules.select { |m| m.dependencies_id }.each do |mod|
                  mod.dependencies_id.each do |dep|
                    dep_module = self.find(:first,
            Severity: Minor
            Found in lib/ooor/helpers/core_helpers.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 get_report_data has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def get_report_data(report_name, ids, report_type='pdf', context={})
                    report_id = report(report_name, ids, report_type, context)
                    if report_id
                      state = false
                      attempt = 0
            Severity: Minor
            Found in lib/ooor/report.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 format_config has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def format_config(config)
                    if config.is_a?(String) && config.end_with?('.yml')
                      env = defined?(Rails.env) ? Rails.env : nil
                      config = load_config_file(config, env)
                    end
            Severity: Minor
            Found in lib/ooor.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 filter_password has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def filter_password(args)
                  if args[0].is_a?(String) && args[2].is_a?(String) && (args[1].is_a?(Integer) || (args[1].respond_to?(:to_i) && args[1].to_i != 0))
                    args[2] = "####"
                  end
                  args.map! do |arg|
            Severity: Minor
            Found in lib/ooor/errors.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 inject_includes! has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def inject_includes!(active_resources, options)
                      (options[:includes] || []).each do |key|
                        if key.is_a?(Hash) # recursive includes
                          sub_options = key.values.first
                          if sub_options.is_a?(Array) # like Rails User.includes(:address, friends: [:address, :followers])
            Severity: Minor
            Found in lib/ooor/relation/finder_methods.rb - About 1 hr to fix

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

                    def retrieve_session(config, id=nil, web_session={})
                      id ||= SecureRandom.hex(16)
                      if id == :noweb
                        spec = noweb_session_spec(config)
                      else
                Severity: Minor
                Found in lib/ooor/session_handler.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 sanitize_association has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def sanitize_association(skey, value)
                      if value.is_a?(Ooor::Base) || value.is_a?(Array) && value.all? {|i| i.is_a?(Ooor::Base)}
                        value
                      elsif value.is_a?(Array) && !self.class.many2one_associations.keys.index(skey)
                        value.reject {|i| i == ''}.map {|i| i.is_a?(String) ? i.to_i : i}
                Severity: Minor
                Found in lib/ooor/type_casting.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 get_ooor_session has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                      def get_ooor_session(env)
                        ruby_session_id = ::Rack::Request.new(env).session.id
                        session = Ooor.session_handler.sessions[ruby_session_id]
                        unless session # session could have been used by an other worker, try getting it
                          config = Ooor.default_config.merge(Ooor::Rack.ooor_session_config_mapper.call(env))
                Severity: Minor
                Found in lib/ooor/rack.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 columns_hash has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                      def columns_hash(view_fields=nil)
                        if view_fields || !@t.columns_hash
                          view_fields ||= {}
                          reload_fields_definition()
                          @t.columns_hash ||= {}
                Severity: Minor
                Found in lib/ooor/reflection_ooor.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

                Severity
                Category
                Status
                Source
                Language