SysMO-DB/seek

View on GitHub
app/models/relationship.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method create_or_update_attributions has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

  def self.create_or_update_attributions(resource, attributions_from_params, predicate = Relationship::ATTRIBUTED_TO)

    # added this branching on .nil? because of the danger of loosing all attributions for a model (for example) if due to an incomplete post request attributions is nil
    # the former code interpreted a nil parameter as an empty list => remove all attributions from an asset
    unless attributions_from_params.nil?
Severity: Minor
Found in app/models/relationship.rb - About 4 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 create_or_update_attributions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.create_or_update_attributions(resource, attributions_from_params, predicate = Relationship::ATTRIBUTED_TO)

    # added this branching on .nil? because of the danger of loosing all attributions for a model (for example) if due to an incomplete post request attributions is nil
    # the former code interpreted a nil parameter as an empty list => remove all attributions from an asset
    unless attributions_from_params.nil?
Severity: Minor
Found in app/models/relationship.rb - About 1 hr to fix

    There are no issues that match your filters.

    Category
    Status