locomotivecms/steam

View on GitHub
lib/locomotive/steam/repositories/content_entry_repository.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Class ContentEntryRepository has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

    class ContentEntryRepository

      include Models::Repository

      attr_accessor :content_type_repository, :content_type
Severity: Minor
Found in lib/locomotive/steam/repositories/content_entry_repository.rb - About 2 hrs to fix

    Method _prepare has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def _prepare(fields, &block)
              fields.each do |field|
                name      = field.name.to_s
                operator  = @operators[name]
                _name     = operator ? "#{name}.#{operator}" : name
    Severity: Minor
    Found in lib/locomotive/steam/repositories/content_entry_repository.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 value_to_id has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def value_to_id(value, target_id)
              return values_to_ids(value, target_id) if value.kind_of?(Array)
    
              _value = if value.is_a?(Hash)
                value['_id'] || value[:_id]
    Severity: Minor
    Found in lib/locomotive/steam/repositories/content_entry_repository.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 value_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def value_for(entry, name, conditions = {})
            return nil if entry.nil?
    
            if field = content_type.fields_by_name[name]
              value = entry.send(name)
    Severity: Minor
    Found in lib/locomotive/steam/repositories/content_entry_repository.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 next_or_previous has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def next_or_previous(entry, asc_op, desc_op)
            return nil if entry.nil?
    
            with(entry.content_type)
    
    
    Severity: Minor
    Found in lib/locomotive/steam/repositories/content_entry_repository.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