SciRuby/nmatrix

View on GitHub

Showing 196 of 196 total issues

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def each_with_indices
    nmatrix = create_dummy_nmatrix
    stride = get_stride(self)
    offset = 0
    #Create indices and initialize them to zero
Severity: Major
Found in lib/nmatrix/jruby/nmatrix_java.rb and 1 other location - About 1 hr to fix
lib/nmatrix/jruby/nmatrix_java.rb on lines 376..401

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 74.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def each_stored_with_indices
    nmatrix = create_dummy_nmatrix
    stride = get_stride(self)
    offset = 0
    #Create indices and initialize them to zero
Severity: Major
Found in lib/nmatrix/jruby/nmatrix_java.rb and 1 other location - About 1 hr to fix
lib/nmatrix/jruby/nmatrix_java.rb on lines 347..372

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 74.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

                Method read_packed has 37 lines of code (exceeds 25 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 1 hr to fix

                  Method to_nm has 37 lines of code (exceeds 25 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 1 hr to fix

                    Method pretty_print has 37 lines of code (exceeds 25 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 1 hr to fix

                      Method transpose has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def transpose(permute = nil)
                          if permute.nil?
                            if self.dim == 1
                              return self.clone
                            elsif self.dim == 2
                      Severity: Minor
                      Found in lib/nmatrix/nmatrix.rb - About 1 hr to fix

                        Similar blocks of code found in 4 locations. Consider refactoring.
                        Open

                          public static double[] getArrayDouble(double[][] matrix, int row, int col)
                          {
                            double[] array = new double[row * col];
                            for (int index=0, i=0; i < row ; i++){
                                for (int j=0; j < col; j++){
                        Severity: Major
                        Found in ext/nmatrix_java/nmatrix/util/ArrayGenerator.java and 3 other locations - About 1 hr to fix
                        ext/nmatrix_java/nmatrix/util/ArrayGenerator.java on lines 17..28
                        ext/nmatrix_java/nmatrix/util/ArrayGenerator.java on lines 30..41
                        ext/nmatrix_java/nmatrix/util/ArrayGenerator.java on lines 43..54

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 96.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 4 locations. Consider refactoring.
                        Open

                          public static double[] getArrayColMajorDouble(double[][] matrix, int col, int row)
                          {
                            double[] array = new double[row * col];
                            for (int index=0, i=0; i < col ; i++){
                                for (int j=0; j < row; j++){
                        Severity: Major
                        Found in ext/nmatrix_java/nmatrix/util/ArrayGenerator.java and 3 other locations - About 1 hr to fix
                        ext/nmatrix_java/nmatrix/util/ArrayGenerator.java on lines 4..15
                        ext/nmatrix_java/nmatrix/util/ArrayGenerator.java on lines 17..28
                        ext/nmatrix_java/nmatrix/util/ArrayGenerator.java on lines 43..54

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 96.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 3 locations. Consider refactoring.
                        Open

                          public static float[][] getMatrixColMajorFloat(float[] array, int col, int row)
                          {
                            float[][] matrix = new float[col][row];
                            for (int index=0, i=0; i < col ; i++){
                                for (int j=0; j < row; j++){
                        Severity: Major
                        Found in ext/nmatrix_java/nmatrix/util/MatrixGenerator.java and 2 other locations - About 1 hr to fix
                        ext/nmatrix_java/nmatrix/util/MatrixGenerator.java on lines 5..17
                        ext/nmatrix_java/nmatrix/util/MatrixGenerator.java on lines 19..31

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 96.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 4 locations. Consider refactoring.
                        Open

                          public static float[] getArrayFloat(float[][] matrix, int row, int col)
                          {
                            float[] array = new float[row * col];
                            for (int index=0, i=0; i < row ; i++){
                                for (int j=0; j < col; j++){
                        Severity: Major
                        Found in ext/nmatrix_java/nmatrix/util/ArrayGenerator.java and 3 other locations - About 1 hr to fix
                        ext/nmatrix_java/nmatrix/util/ArrayGenerator.java on lines 4..15
                        ext/nmatrix_java/nmatrix/util/ArrayGenerator.java on lines 30..41
                        ext/nmatrix_java/nmatrix/util/ArrayGenerator.java on lines 43..54

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 96.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Severity
                        Category
                        Status
                        Source
                        Language