lib/volt/models/array_model.rb

Summary

Maintainability
D
1 day
Test Coverage

Class ArrayModel has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

  class ArrayModel < ReactiveArray
    include ModelWrapper
    include Models::Helpers::Base
    include StateManager
    include Models::Helpers::ArrayModel
Severity: Minor
Found in lib/volt/models/array_model.rb - About 4 hrs to fix

    File array_model.rb has 273 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'volt/reactive/reactive_array'
    require 'volt/models/model_wrapper'
    require 'volt/models/helpers/base'
    require 'volt/models/state_manager'
    require 'volt/models/helpers/array_model'
    Severity: Minor
    Found in lib/volt/models/array_model.rb - About 2 hrs to fix

      Method proxy_with_load has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.proxy_with_load(*method_names)
            imethods = instance_methods(false)
            method_names.each do |method_name|
              # Sometimes we want to alias a method_missing method, so we use super
              # instead to call it, if its not defined locally.
      Severity: Minor
      Found in lib/volt/models/array_model.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 create_new_model has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def create_new_model(model, from_method)
            if model.is_a?(Model)
              if model.buffer?
                fail "The #{from_method} does not take a buffer.  Call .save! on buffer's to persist them."
              end
      Severity: Minor
      Found in lib/volt/models/array_model.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 create_new_model has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def create_new_model(model, from_method)
            if model.is_a?(Model)
              if model.buffer?
                fail "The #{from_method} does not take a buffer.  Call .save! on buffer's to persist them."
              end
      Severity: Minor
      Found in lib/volt/models/array_model.rb - About 1 hr to fix

        Method proxy_with_load has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.proxy_with_load(*method_names)
              imethods = instance_methods(false)
              method_names.each do |method_name|
                # Sometimes we want to alias a method_missing method, so we use super
                # instead to call it, if its not defined locally.
        Severity: Minor
        Found in lib/volt/models/array_model.rb - About 1 hr to fix

          Method delete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def delete(val)
                # Check to make sure the models are allowed to be deleted
                if !val.is_a?(Model)
                  # Not a model, return as a Promise
                  super(val).then
          Severity: Minor
          Found in lib/volt/models/array_model.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

          There are no issues that match your filters.

          Category
          Status