lib/volt/models/model.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Model has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Model
    include LifecycleCallbacks
    include ModelWrapper
    include Models::Helpers::Base
    include ModelHashBehaviour
Severity: Minor
Found in lib/volt/models/model.rb - About 3 hrs to fix

    File model.rb has 299 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'volt/models/model_wrapper'
    require 'volt/models/array_model'
    require 'volt/models/helpers/base'
    require 'volt/models/model_hash_behaviour'
    require 'volt/models/validations/validations'
    Severity: Minor
    Found in lib/volt/models/model.rb - About 3 hrs to fix

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

          def set(attribute_name, value, &block)
            # Assign, without the =
            attribute_name = attribute_name.to_sym
      
            check_valid_field_name(attribute_name)
      Severity: Minor
      Found in lib/volt/models/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 run_initial_setup has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def run_initial_setup(initial_setup)
            # Save the changes
            if initial_setup
              # Run initial validation
              if Volt.in_mode?(:no_validate)
      Severity: Minor
      Found in lib/volt/models/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 get has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def get(attr_name, expand = false)
            # Reading an attribute, we may get back a nil model.
            attr_name = attr_name.to_sym
      
            check_valid_field_name(attr_name)
      Severity: Minor
      Found in lib/volt/models/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 method_missing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def method_missing(method_name, *args, &block)
            if method_name[0] == '_'
              # Remove underscore
              method_name = method_name[1..-1]
              if method_name[-1] == '='
      Severity: Minor
      Found in lib/volt/models/model.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 assign_all_attributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def assign_all_attributes(attrs, track_changes = false)
            # Assign each attribute using setters
            attrs.each_pair do |key, value|
              key = key.to_sym
      
      
      Severity: Minor
      Found in lib/volt/models/model.rb - About 35 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 read_new_model has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def read_new_model(method_name)
            if @persistor && @persistor.respond_to?(:read_new_model)
              return @persistor.read_new_model(method_name)
            else
              opts = @options.merge(parent: self, path: path + [method_name])
      Severity: Minor
      Found in lib/volt/models/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

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

          def assign_attributes(attrs, initial_setup = false, skip_changes = false)
            attrs = wrap_values(attrs)
      
            if attrs
              # When doing a mass-assign, we don't validate or save until the end.
      Severity: Minor
      Found in lib/volt/models/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

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

          def inspect
            Computation.run_without_tracking do
              str = "#<#{self.class}"
      
      
      
      Severity: Minor
      Found in lib/volt/models/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