mdoza/mongoid_multiparams

View on GitHub

Showing 3 of 3 total issues

Method process_attributes has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def process_attributes(attrs = nil)
      if attrs
        errors = []
        attributes = attrs.class.new
        attributes.permit! if attrs.respond_to?(:permitted?) && attrs.permitted?
Severity: Minor
Found in lib/mongoid_multiparams.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 process_attributes has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def process_attributes(attrs = nil)
      if attrs
        errors = []
        attributes = attrs.class.new
        attributes.permit! if attrs.respond_to?(:permitted?) && attrs.permitted?
Severity: Minor
Found in lib/mongoid_multiparams.rb - About 1 hr to fix

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

        def instantiate_object(field, values_with_empty_parameters)
          return nil if values_with_empty_parameters.all? { |v| v.nil? }
          values = values_with_empty_parameters.collect { |v| v.nil? ? 1 : v }
          klass = field.type
          if klass == DateTime || klass == Date || klass == Time
    Severity: Minor
    Found in lib/mongoid_multiparams.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

    Severity
    Category
    Status
    Source
    Language