locomotivecms/mounter

View on GitHub
lib/locomotive/mounter/models/content_entry.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Class ContentEntry has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

      class ContentEntry < Base

        ## fields ##
        field :_slug,               localized: true
        field :_position,           default: 0
Severity: Minor
Found in lib/locomotive/mounter/models/content_entry.rb - About 2 hrs to fix

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

            def to_hash(nested = true)
              # no need of _position and _visible (unless it's false)
              hash = super.delete_if { |k, v| k == '_position' || (k == '_visible' && v == true) }
    
              # also no need of the content type
    Severity: Minor
    Found in lib/locomotive/mounter/models/content_entry.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 set_slug has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def set_slug
              self.translated_in.each do |locale|
                Locomotive::Mounter.with_locale(locale) do
                  # first attempt from the label
                  if self._slug.blank?
    Severity: Minor
    Found in lib/locomotive/mounter/models/content_entry.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

    Method dynamic_getter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def dynamic_getter(name)
              field = self.content_type.find_field(name)
              value = self.localized_dynamic_attribute_value(field)
    
              case field.type
    Severity: Minor
    Found in lib/locomotive/mounter/models/content_entry.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 localized_dynamic_attribute_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def localized_dynamic_attribute_value(field)
              if field.is_a?(String)
                field = self.content_type.find_field(field)
              end
    
    
    Severity: Minor
    Found in lib/locomotive/mounter/models/content_entry.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 dynamic_setter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def dynamic_setter(name, value)
              self.dynamic_attributes ||= {}
              self.dynamic_attributes[name.to_sym] ||= {}
    
              field = self.content_type.find_field(name)
    Severity: Minor
    Found in lib/locomotive/mounter/models/content_entry.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