reactrb/reactive-record

View on GitHub

Showing 56 of 269 total issues

Method gather_records has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.gather_records(records_to_process, force, record_being_saved)
        # we want to pass not just the model data to save, but also enough information so that on return from the server
        # we can update the models on the client

        # input

    Method update_attribute has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def update_attribute(attribute, *args)
          value = args[0]
          if args.count != 0 and data_loading?
            if (aggregation = model.reflect_on_aggregation(attribute)) and !(aggregation.klass < ActiveRecord::Base)
              @synced_attributes[attribute] = aggregation.deserialize(aggregation.serialize(value))
    Severity: Minor
    Found in lib/reactive_record/active_record/reactive_record/base.rb - About 1 hr to fix

      Method replace has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def replace(new_array)
      
            # not tested if you do all[n] where n > 0... this will create additional dummy items, that this will not sync up.
            # probably just moving things around so the @dummy_collection and @dummy_record are updated AFTER the new items are pushed
            # should work.
      Severity: Minor
      Found in lib/reactive_record/active_record/reactive_record/collection.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 schedule_fetch has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.schedule_fetch
            @fetch_scheduled ||= after(0) do
              if @pending_fetches.count > 0  # during testing we might reset the context while there are pending fetches otherwise this would never normally happen
                last_fetch_at = @last_fetch_at
                @last_fetch_at = Time.now

        Method _react_param_conversion has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def _react_param_conversion(param, opt = nil)
              # defines how react will convert incoming json to this ActiveRecord model
              #TIMING times = {start: Time.now.to_f, json_start: 0, json_end: 0, db_load_start: 0, db_load_end: 0}
              #TIMING times[:json_start] = Time.now.to_f
              param = Native(param)
        Severity: Minor
        Found in lib/reactive_record/active_record/class_methods.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 apply_method has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def apply_method(method)
              # Fills in the value returned by sending "method" to the corresponding server side db instance
              if on_opal_server? and changed?
                log("Warning fetching virtual attributes (#{model.name}.#{method}) during prerendering on a changed or new model is not implemented.", :warning)
                # to implement this we would have to sync up any changes during prererendering with a set the cached models (see server_data_cache)
        Severity: Minor
        Found in lib/reactive_record/active_record/reactive_record/base.rb - About 1 hr to fix

          Method << has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def <<(item)
                return delete(item) if item.destroyed? # pushing a destroyed item is the same as removing it
                backing_record = item.backing_record
                all << item unless all.include? item # does this use == if so we are okay...
                if backing_record and @owner and @association and inverse_of = @association.inverse_of and item.attributes[inverse_of] != @owner
          Severity: Minor
          Found in lib/reactive_record/active_record/reactive_record/collection.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 find has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.find(model, attribute, value)
                # will return the unique record with this attribute-value pair
                # value cannot be an association or aggregation
          
                model = model.base_class
          Severity: Minor
          Found in lib/reactive_record/active_record/reactive_record/base.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 apply_method_to_cache has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                    def apply_method_to_cache(method)
                      @db_cache.inject(nil) do | representative, cache_item |
                        if cache_item.vector == vector
                          if @ar_object.class < ActiveRecord::Base and @ar_object.attributes.has_key?(method)
                            @ar_object.check_permission_with_acting_user(acting_user, :view_permitted?, method)
          Severity: Minor
          Found in lib/reactive_record/server_data_cache.rb - About 1 hr to fix

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

                  def destroy(&block)
            
                    return if @destroyed
            
                    model.reflect_on_all_associations.each do |association|

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

                def self.run_blocks_to_load(fetch_id, failure = nil)
                  if @blocks_to_load
                    blocks_to_load_now = @blocks_to_load.select { |data| data.first == fetch_id }
                    @blocks_to_load = @blocks_to_load.reject { |data| data.first == fetch_id }
                    @load_stack ||= []
              Severity: Minor
              Found in lib/reactive_record/active_record/reactive_record/while_loading.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 reactive_record_link_set_while_loading_container_class has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def reactive_record_link_set_while_loading_container_class
              
                    %x{
              
                      var node = #{dom_node};
              Severity: Minor
              Found in lib/reactive_record/active_record/reactive_record/while_loading.rb - About 1 hr to fix

                Method apply_star has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                          def apply_star
                            if value && value.length > 0
                              i = -1
                              value.inject(nil) do | representative, ar_object |
                                i += 1
                Severity: Minor
                Found in lib/reactive_record/server_data_cache.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

                Avoid deeply nested control flow statements.
                Open

                              elsif method == "*all"
                                @parent.as_hash({jsonize(method) => children.first})
                              else
                                @parent.as_hash({jsonize(method) => children})
                Severity: Major
                Found in lib/reactive_record/server_data_cache.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if cache_item.value and cache_item.value != []
                                        ReactiveRecord::Pry::rescued(e)
                                        raise e, "ReactiveRecord exception caught when applying #{method} to db object #{cache_item.value}: #{e}", e.backtrace
                                      else
                                        representative
                  Severity: Major
                  Found in lib/reactive_record/server_data_cache.rb - About 45 mins to fix

                    Method initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def initialize(hash = {})
                    
                          if hash.is_a? ReactiveRecord::Base
                            @backing_record = hash
                          else
                    Severity: Minor
                    Found in lib/reactive_record/active_record/instance_methods.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

                    Avoid deeply nested control flow statements.
                    Open

                                  if association.collection?
                                    value.each do |assoc|
                                      add_new_association.call(record, attribute, assoc.backing_record) if assoc.changed?(association.inverse_of) or assoc.new?
                                    end
                                  elsif record.new? || record.changed?(attribute) || (record == record_being_saved && force)
                    Severity: Major
                    Found in lib/reactive_record/active_record/reactive_record/isomorphic_base.rb - About 45 mins to fix

                      Method load_from_db has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def self.load_from_db(record, *vector)
                            return nil unless on_opal_client? # this can happen when we are on the server and a nil value is returned for an attribute
                            # only called from the client side
                            # pushes the value of vector onto the a list of vectors that will be loaded from the server when the next
                            # rendering cycle completes.
                      Severity: Minor
                      Found in lib/reactive_record/active_record/reactive_record/isomorphic_base.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def initialize(owner_class, macro, name, options = {})
                              owner_class.reflect_on_all_associations << self
                              @owner_class = owner_class
                              @macro =       macro
                              @options =     options
                      Severity: Minor
                      Found in lib/reactive_record/active_record/associations.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

                      Avoid deeply nested control flow statements.
                      Open

                                  elsif !value.nil?
                                    attributes[attribute].attributes[inverse_of] = nil unless attributes[attribute].nil?
                                    value.attributes[inverse_of] = @ar_instance
                                    React::State.set_state(value.backing_record, inverse_of, @ar_instance) unless data_loading?
                                  elsif attributes[attribute]
                      Severity: Major
                      Found in lib/reactive_record/active_record/reactive_record/base.rb - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language