aeolusproject/conductor

View on GitHub
src/app/models/hardware_profile.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method match_hardware_profile_property has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  def self.match_hardware_profile_property(front_end_property, back_end_property)
    # if the front_end_property is nil, we don't care about it, so everything matches:
    return true if front_end_property.nil? || front_end_property.value.to_s.empty?
    # if the back_end_property is nil, it only matches if front-end is also nil:
    return false if back_end_property.nil? || back_end_property.value.to_s.empty?
Severity: Minor
Found in src/app/models/hardware_profile.rb - About 3 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 generate_override_property_value has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def self.generate_override_property_value(front_end_property, back_end_property)
    case back_end_property.kind
      when "fixed"
        return back_end_property.value
      when "range"
Severity: Minor
Found in src/app/models/hardware_profile.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 match_hardware_profile_property has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.match_hardware_profile_property(front_end_property, back_end_property)
    # if the front_end_property is nil, we don't care about it, so everything matches:
    return true if front_end_property.nil? || front_end_property.value.to_s.empty?
    # if the back_end_property is nil, it only matches if front-end is also nil:
    return false if back_end_property.nil? || back_end_property.value.to_s.empty?
Severity: Minor
Found in src/app/models/hardware_profile.rb - About 1 hr to fix

    Avoid too many return statements within this method.
    Open

                return value
    Severity: Major
    Found in src/app/models/hardware_profile.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return nil
      Severity: Major
      Found in src/app/models/hardware_profile.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                  return val
        Severity: Major
        Found in src/app/models/hardware_profile.rb - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status