SpeciesFileGroup/taxonworks

View on GitHub
app/models/concerns/shared/matrix_hooks/member.rb

Summary

Maintainability
A
25 mins
Test Coverage

Method member_syncronize_matrices has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def member_syncronize_matrices
        # TODO: refine to eliminate other possibilities
        # Don't bother with the overhead if there are no matrices
        if ObservationMatrix.where(project_id: project_id).any?

Severity: Minor
Found in app/models/concerns/shared/matrix_hooks/member.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

TODO found
Open

      # TODO: we could `of_type` abstract this as well

TODO found
Open

        # TODO: refine to eliminate other possibilities

Use 2 (not 1) spaces for indentation.
Open

        rows.each do |mri|

This cop checks for indentation that doesn't use the specified number of spaces.

See also the IndentationConsistency cop which is the companion to this one.

Example:

# bad
class A
 def test
  puts 'hello'
 end
end

# good
class A
  def test
    puts 'hello'
  end
end

Example: IgnoredPatterns: ['^\s*module']

# bad
module A
class B
  def test
  puts 'hello'
  end
end
end

# good
module A
class B
  def test
    puts 'hello'
  end
end
end

Use 2 (not 3) spaces for indentation.
Open

       def member_add_matrix_rows(rows)

This cop checks for indentation that doesn't use the specified number of spaces.

See also the IndentationConsistency cop which is the companion to this one.

Example:

# bad
class A
 def test
  puts 'hello'
 end
end

# good
class A
  def test
    puts 'hello'
  end
end

Example: IgnoredPatterns: ['^\s*module']

# bad
module A
class B
  def test
  puts 'hello'
  end
end
end

# good
module A
class B
  def test
    puts 'hello'
  end
end
end

There are no issues that match your filters.

Category
Status