artirix/browsercms

View on GitHub
lib/cms/behaviors/dynamic_attributes.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method has_dynamic_attributes has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        def has_dynamic_attributes(options={})
          @has_dynamic_attributes = true
          include InstanceMethods

          # Provide default options
Severity: Minor
Found in lib/cms/behaviors/dynamic_attributes.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 has_dynamic_attributes has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def has_dynamic_attributes(options={})
          @has_dynamic_attributes = true
          include InstanceMethods

          # Provide default options
Severity: Minor
Found in lib/cms/behaviors/dynamic_attributes.rb - About 1 hr to fix

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

          def write_attribute_with_dynamic_attributes(attr_name, value)
            attr_name = attr_name.to_s
            exec_if_related attr_name do |model|
              value_field = dynamic_options[model.name][:value_field]
              @save_dynamic_attr ||= []
    Severity: Minor
    Found in lib/cms/behaviors/dynamic_attributes.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_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def assign_attributes(new_attributes, options = {})
              return unless new_attributes
    
              attributes = new_attributes.stringify_keys
              role = options[:as] || :default
    Severity: Minor
    Found in lib/cms/behaviors/dynamic_attributes.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 save_modified_dynamic_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def save_modified_dynamic_attributes
            return if new_record?
            return if @save_dynamic_attr.nil?
            @save_dynamic_attr.each do |s|
              model, attr_name = s
    Severity: Minor
    Found in lib/cms/behaviors/dynamic_attributes.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