SciRuby/nmatrix

View on GitHub

Showing 130 of 196 total issues

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

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

class NMatrix

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

    Method geev has 61 lines of code (exceeds 25 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: Major
    Found in lib/nmatrix/atlas.rb - About 2 hrs to fix

      Method pretty_print has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def pretty_print(q) #:nodoc:
          if self.shape.size > 1 and self.shape[1] > 100
            self.inspect.pretty_print(q)
          elsif self.dim > 3 || self.dim == 1
            self.to_a.pretty_print(q)
      Severity: Minor
      Found in lib/nmatrix/nmatrix.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

      Method load_coordinate has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def load_coordinate file, converter, dtype, entry_type, symmetry
      
            mat = nil
      
            # Read until we get the dimensions and nonzeros
      Severity: Minor
      Found in lib/nmatrix/io/market.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

      Method dot has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def dot(right_v)
          if (right_v.is_a?(NMatrix) && self.stype == :dense && right_v.stype == :dense &&
              self.dim == 2 && right_v.dim == 2 && self.shape[1] == right_v.shape[0])
      
            result_dtype = NMatrix.upcast(self.dtype,right_v.dtype)
      Severity: Minor
      Found in lib/nmatrix/lapack_ext_common.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

      Method cast has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def cast(*params)
          if (params.size > 0 && params[0].is_a?(Hash))
            opts = {
                :stype => self.stype,
                :dtype => self.dtype,
      Severity: Minor
      Found in lib/nmatrix/nmatrix.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

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

            def read_packed(packedio, options)
              raise(ArgumentError, 'Missing mandatory option :endian.') \
               unless options.has_key?(:endian)
      
              tag = packedio.read([Tag, {:endian => options[:endian]}])
      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

      Method geev has 50 lines of code (exceeds 25 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 2 hrs to fix

        Method block_diagonal has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def block_diagonal(*params)
              options = params.last.is_a?(Hash) ? params.pop : {}
        
              params.each_index do |i|
                params[i] = params[i].to_nm if params[i].is_a?(Array) # Convert Array to NMatrix
        Severity: Minor
        Found in lib/nmatrix/shortcuts.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 inject_rank has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def inject_rank(dimen=0, initial=nil, dtype=nil)
        
            raise(RangeError, "requested dimension (#{dimen}) does not exist (shape: #{shape})") if dimen > self.dim
        
            return enum_for(:inject_rank, dimen, initial, dtype) unless block_given?
        Severity: Minor
        Found in lib/nmatrix/enumerate.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 get_slice has 45 lines of code (exceeds 25 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 1 hr to fix

          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 dense_storage_get has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def dense_storage_get(slice,stride)
                if slice[:single]
                  return dense_storage_pos(slice[:coords],stride)
                else
                  shape = @shape.dup
            Severity: Minor
            Found in lib/nmatrix/jruby/slice.rb - About 1 hr to fix

              Method save_coordinate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  def save_coordinate matrix, file, symmetry, pattern
                    # Convert to a hash in order to store
                    rows = matrix.to_h
              
                    # Count non-zeros
              Severity: Minor
              Found in lib/nmatrix/io/market.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 gemm has 13 arguments (exceeds 4 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)
              Severity: Major
              Found in lib/nmatrix/blas.rb - About 1 hr to fix

                Method to_hash has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                  def to_hash
                    if stype == :yale
                      h = {}
                      each_stored_with_indices do |val,i,j|
                        next if val == 0 # Don't bother storing the diagonal zero values -- only non-zeros.
                Severity: Minor
                Found in lib/nmatrix/nmatrix.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 lapack_gesvd has 12 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                      def lapack_gesvd(jobu, jobvt, m, n, a, lda, s, u, ldu, vt, ldvt, lwork)
                Severity: Major
                Found in lib/nmatrix/lapack_core.rb - About 1 hr to fix

                  Method lapack_geev has 12 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                        def lapack_geev(jobvl, jobvr, n, a, lda, w, wi, vl, ldvl, vr, ldvr, lwork)
                  Severity: Major
                  Found in lib/nmatrix/lapack_core.rb - About 1 hr to fix

                    Method cblas_trmm has 12 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def cblas_trmm(order, side, uplo, trans_a, diag, m, n, alpha, a, lda, b, ldb)
                    Severity: Major
                    Found in lib/nmatrix/blas.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language