47colborne/dynamini

View on GitHub
lib/dynamini/attributes.rb

Summary

Maintainability
A
1 hr
Test Coverage

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

    def attribute_updates
      changes.reduce({}) do |updates, (key, value)|
        # TODO: remove this ternary once aws-sdk accepts empty set pull request
        current_value = value[1].is_a?(Set) && value[1].empty? ? nil : value[1]
        updates[key] = { action: value[2] || 'PUT' }
Severity: Minor
Found in lib/dynamini/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 add_to has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def add_to(attribute, value)
      complain_about(attribute) unless self.class.handles[attribute]
      old_value = read_attribute(attribute)
      add_value = self.class.attribute_callback(TypeHandler::SETTER_PROCS,  self.class.handles[attribute], value, true)
      if ADDABLE_TYPES.include? self.class.handles[attribute][:format]
Severity: Minor
Found in lib/dynamini/attributes.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_attribute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def read_attribute(name)
      value = @attributes[name]
      if (handle = self.class.handles[name.to_sym])
        value = handle[:options][:default] if value.nil?
        value = self.class.attribute_callback(TypeHandler::GETTER_PROCS, handle, value, false) unless value.nil?
Severity: Minor
Found in lib/dynamini/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