SciRuby/nmatrix

View on GitHub

Showing 130 of 196 total issues

File nmatrix_java.rb has 625 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'java'
require_relative '../../../ext/nmatrix_java/vendor/commons-math3-3.6.1.jar'
require_relative '../../../ext/nmatrix_java/target/nmatrix.jar'

java_import 'org.apache.commons.math3.linear.ArrayRealVector'
Severity: Major
Found in lib/nmatrix/jruby/nmatrix_java.rb - About 1 day to fix

    Method initialize has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
    Open

      def initialize(*args)
        if args[-1] == :copy
          @shape = [2,2]
          @s = [0,0,0,0]
          @dim = shape.is_a?(Array) ? shape.length : 2
    Severity: Minor
    Found in lib/nmatrix/jruby/nmatrix_java.rb - About 1 day 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

    File nmatrix.rb has 547 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    def jruby?
      /java/ === RUBY_PLATFORM
    end
    
    if jruby?
    Severity: Major
    Found in lib/nmatrix/nmatrix.rb - About 1 day to fix

      Class NMatrix has 58 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class NMatrix
        include_package 'org.apache.commons.math3.analysis.function'
        attr_accessor :shape, :dim, :dtype, :stype, :s
      
        def initialize(*args)
      Severity: Major
      Found in lib/nmatrix/jruby/nmatrix_java.rb - About 1 day to fix

        Class NMatrix has 56 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class NMatrix
          # Read and write extensions for NMatrix.
          module IO
            extend AutoloadPatch
        
        
        Severity: Major
        Found in lib/nmatrix/nmatrix.rb - About 1 day to fix

          File math.rb has 500 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          class NMatrix
          
            module NMMath #:nodoc:
              METHODS_ARITY_2 = [:atan2, :ldexp, :hypot]
              METHODS_ARITY_1 = [:cos, :sin, :tan, :acos, :asin, :atan, :cosh, :sinh, :tanh, :acosh,
          Severity: Minor
          Found in lib/nmatrix/math.rb - About 1 day to fix

            Method geev has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
            Open

                  def geev(matrix, which=:both)
                    raise(StorageTypeError, "LAPACK functions only work on dense matrices") \
                     unless matrix.dense?
            
                    raise(ShapeError, "eigenvalues can only be computed for square matrices") \
            Severity: Minor
            Found in lib/nmatrix/atlas.rb - About 5 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 geev has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
            Open

                  def geev(matrix, which=:both)
                    raise(StorageTypeError, "LAPACK functions only work on dense matrices") unless matrix.dense?
                    raise(ShapeError, "eigenvalues can only be computed for square matrices") unless matrix.dim == 2 && matrix.shape[0] == matrix.shape[1]
            
                    jobvl = (which == :both || which == :left) ? :t : false
            Severity: Minor
            Found in lib/nmatrix/lapacke.rb - About 5 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

            Class NMatrix has 41 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class NMatrix
            
              module NMMath #:nodoc:
                METHODS_ARITY_2 = [:atan2, :ldexp, :hypot]
                METHODS_ARITY_1 = [:cos, :sin, :tan, :acos, :asin, :atan, :cosh, :sinh, :tanh, :acosh,
            Severity: Minor
            Found in lib/nmatrix/math.rb - About 5 hrs to fix

              Method get_slice has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
              Open

                def get_slice(dim, args, shape_array)
                  slice = {}
                  slice[:coords]=[]
                  slice[:lengths]=[]
                  slice[:single] = true
              Severity: Minor
              Found in lib/nmatrix/jruby/slice.rb - About 5 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 gemm has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
              Open

                  def gemm(a, b, c = nil, alpha = 1.0, beta = 0.0,
                           transpose_a = false, transpose_b = false, m = nil,
                           n = nil, k = nil, lda = nil, ldb = nil, ldc = nil)
              
                    raise(ArgumentError, 'Expected dense NMatrices as first two arguments.') \
              Severity: Minor
              Found in lib/nmatrix/blas.rb - About 5 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

              File mat5_reader.rb has 353 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require_relative './mat_reader.rb'
              
              module NMatrix::IO::Matlab
              
                # Reader (and eventual writer) for a version 5 .mat file.
              Severity: Minor
              Found in lib/nmatrix/io/mat5_reader.rb - About 4 hrs to fix

                Class NMatrix has 34 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class NMatrix
                
                  # A dummy matrix is a matrix without the elements atrribute.
                  # NMatrix#create_dummy_matrix prevents creating copies as @s is set explicitly.
                  def +(other)
                Severity: Minor
                Found in lib/nmatrix/jruby/operators.rb - About 4 hrs to fix

                  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 gemv has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def gemv(a, x, y = nil, alpha = 1.0, beta = 0.0,
                               transpose_a = false, m = nil, n = nil, lda = nil,
                               incx = nil, incy = nil)
                        raise(ArgumentError, 'Expected dense NMatrices as first two arguments.') \
                         unless a.is_a?(NMatrix) and x.is_a?(NMatrix) and \
                  Severity: Minor
                  Found in lib/nmatrix/blas.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

                  File shortcuts.rb has 308 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  class NMatrix
                  
                    # Methods for generating magic matrix.
                    module MagicHelpers
                      class << self
                  Severity: Minor
                  Found in lib/nmatrix/shortcuts.rb - About 3 hrs to fix

                    Method to_nm has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def to_nm(shape = nil, dtype = nil, stype = :dense)
                        elements = self.dup
                    
                        guess_dtype = ->(type) {
                          case type
                    Severity: Minor
                    Found in lib/nmatrix/monkeys.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

                    Class NMatrix has 25 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class NMatrix
                    
                      #
                      # call-seq:
                      #     getrf! -> Array
                    Severity: Minor
                    Found in lib/nmatrix/cruby/math.rb - About 2 hrs to fix

                      Method initialize has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def initialize(*args)
                          if args[-1] == :copy
                            @shape = [2,2]
                            @s = [0,0,0,0]
                            @dim = shape.is_a?(Array) ? shape.length : 2
                      Severity: Major
                      Found in lib/nmatrix/jruby/nmatrix_java.rb - About 2 hrs to fix

                        Method read_packed has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def read_packed(packedio, options)
                                flags_class, self.nonzero_max = packedio.read([Element, options]).data
                        
                                self.matlab_class   = MatReader::MCLASSES[flags_class % 16]
                        
                        
                        Severity: Minor
                        Found in lib/nmatrix/io/mat5_reader.rb - About 2 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

                        Severity
                        Category
                        Status
                        Source
                        Language