reactrb/reactive-record

View on GitHub

Showing 56 of 269 total issues

Method save_records has a Cognitive Complexity of 140 (exceeds 5 allowed). Consider refactoring.
Open

      def self.save_records(models, associations, acting_user, validate, save)
        reactive_records = {}
        vectors = {}
        new_models = []
        saved_models = []
Severity: Minor
Found in lib/reactive_record/active_record/reactive_record/isomorphic_base.rb - About 2 days 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 gather_records has a Cognitive Complexity of 68 (exceeds 5 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
Severity: Minor
Found in lib/reactive_record/active_record/reactive_record/isomorphic_base.rb - About 1 day 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_set! has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
Open

    def reactive_set!(attribute, value)
      @virgin = false unless data_loading?
      unless @destroyed or (!(attributes[attribute].is_a? DummyValue) and attributes.has_key?(attribute) and attributes[attribute] == value)
        if association = @model.reflect_on_association(attribute)
          if association.collection?
Severity: Minor
Found in lib/reactive_record/active_record/reactive_record/base.rb - About 1 day 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

File isomorphic_base.rb has 481 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'json'

module ReactiveRecord

  class Base
Severity: Minor
Found in lib/reactive_record/active_record/reactive_record/isomorphic_base.rb - About 7 hrs to fix

    Method load_from_json has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.load_from_json(tree, target = nil)
            ignore_all = nil
    
            # have to process *all before any other items
            # we leave the "*all" key in just for debugging purposes, and then skip it below
    Severity: Minor
    Found in lib/reactive_record/server_data_cache.rb - About 7 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 apply_method has a Cognitive Complexity of 37 (exceeds 5 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 5 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 has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

          def save(validate, force, &block)
    
            if data_loading?
    
              sync!
    Severity: Minor
    Found in lib/reactive_record/active_record/reactive_record/isomorphic_base.rb - About 5 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 apply_method_to_cache has a Cognitive Complexity of 32 (exceeds 5 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 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

    File base.rb has 358 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ReactiveRecord
      class Base
    
        # Its all about lazy loading. This prevents us from grabbing enormous association collections, or large attributes
        # unless they are explicitly requested.
    Severity: Minor
    Found in lib/reactive_record/active_record/reactive_record/base.rb - About 4 hrs to fix

      Method as_hash has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

                def as_hash(children = nil)
                  unless children
                    return {} if @ar_object.is_a?(Class) and (@ar_object < ActiveRecord::Base)
                    children = [@ar_object.is_a?(BigDecimal) ? @ar_object.to_f : @ar_object]
                  end
      Severity: Minor
      Found in lib/reactive_record/server_data_cache.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

      Method save_records has 106 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def self.save_records(models, associations, acting_user, validate, save)
              reactive_records = {}
              vectors = {}
              new_models = []
              saved_models = []
      Severity: Major
      Found in lib/reactive_record/active_record/reactive_record/isomorphic_base.rb - About 4 hrs to fix

        Class Base has 33 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Base
        
            # Its all about lazy loading. This prevents us from grabbing enormous association collections, or large attributes
            # unless they are explicitly requested.
        
        
        Severity: Minor
        Found in lib/reactive_record/active_record/reactive_record/base.rb - About 4 hrs to fix

          Method update_attribute has a Cognitive Complexity of 28 (exceeds 5 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 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

          Method find_record has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.find_record(model, id, vector, save)
                  if !save
                    found = vector[1..-1].inject(vector[0]) do |object, method|
                      if method.is_a? Array
                        if method[0] == "new"
          Severity: Minor
          Found in lib/reactive_record/active_record/reactive_record/isomorphic_base.rb - About 3 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 destroy has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

                def destroy(&block)
          
                  return if @destroyed
          
                  model.reflect_on_all_associations.each do |association|
          Severity: Minor
          Found in lib/reactive_record/active_record/reactive_record/isomorphic_base.rb - About 3 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 find_association has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def find_association(association, id)
                inverse_of = association.inverse_of
                instance = if id
                  find(association.klass, association.klass.primary_key, id)
                else
          Severity: Minor
          Found in lib/reactive_record/active_record/reactive_record/base.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 reactive_get! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def reactive_get!(attribute, reload = nil)
                @virgin = false unless data_loading?
                unless @destroyed
                  if @attributes.has_key? attribute
                    attributes[attribute].notify if @attributes[attribute].is_a? DummyValue
          Severity: Minor
          Found in lib/reactive_record/active_record/reactive_record/base.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 has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def save(validate, force, &block)
          
                  if data_loading?
          
                    sync!
          Severity: Major
          Found in lib/reactive_record/active_record/reactive_record/isomorphic_base.rb - About 2 hrs to fix

            Method load_from_json has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def self.load_from_json(tree, target = nil)
                    ignore_all = nil
            
                    # have to process *all before any other items
                    # we leave the "*all" key in just for debugging purposes, and then skip it below
            Severity: Minor
            Found in lib/reactive_record/server_data_cache.rb - About 1 hr to fix

              Method reactive_set! has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def reactive_set!(attribute, value)
                    @virgin = false unless data_loading?
                    unless @destroyed or (!(attributes[attribute].is_a? DummyValue) and attributes.has_key?(attribute) and attributes[attribute] == value)
                      if association = @model.reflect_on_association(attribute)
                        if association.collection?
              Severity: Minor
              Found in lib/reactive_record/active_record/reactive_record/base.rb - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language