SciRuby/nmatrix

View on GitHub
lib/nmatrix/homogeneous.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method quaternion has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  def quaternion
    raise(ShapeError, "Expected square matrix") if self.shape[0] != self.shape[1]
    raise(ShapeError, "Expected 3x3 rotation (or 4x4 homogeneous) matrix") if self.shape[0] > 4 || self.shape[0] < 3

    q = NMatrix.new([4], dtype: self.dtype == :float32 ? :float32: :float64)
Severity: Minor
Found in lib/nmatrix/homogeneous.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 quaternion has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def quaternion
    raise(ShapeError, "Expected square matrix") if self.shape[0] != self.shape[1]
    raise(ShapeError, "Expected 3x3 rotation (or 4x4 homogeneous) matrix") if self.shape[0] > 4 || self.shape[0] < 3

    q = NMatrix.new([4], dtype: self.dtype == :float32 ? :float32: :float64)
Severity: Minor
Found in lib/nmatrix/homogeneous.rb - About 1 hr to fix

    Method translation has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def translation *args
          xyz = args.shift if args.first.is_a?(NMatrix) || args.first.is_a?(Array)
          default_dtype = xyz.respond_to?(:dtype) ? xyz.dtype : NMatrix.guess_dtype(xyz)
          opts = {dtype: default_dtype}
          opts = opts.merge(args.pop) if args.size > 0 && args.last.is_a?(Hash)
    Severity: Minor
    Found in lib/nmatrix/homogeneous.rb - About 55 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