SciRuby/nmatrix

View on GitHub

Showing 196 of 196 total issues

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

  public static float[] getArrayColMajorFloat(float[][] matrix, int col, int row)
  {
    float[] array = new float[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 30..41

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 double[][] getMatrixDouble(double[] array, int row, int col)
  {
    double[][] matrix = 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/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 33..45

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[][] getMatrixFloat(float[] array, int row, int col)
  {
    float[][] matrix = 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/MatrixGenerator.java and 2 other locations - About 1 hr to fix
ext/nmatrix_java/nmatrix/util/MatrixGenerator.java on lines 19..31
ext/nmatrix_java/nmatrix/util/MatrixGenerator.java on lines 33..45

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

Method doubly_even_magic has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def doubly_even_magic(nm, shape)
        mini_square_num = shape / 4
        count = 1     
        inv_count = shape * shape
        shape.times do |row|
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 dense_storage_set has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def dense_storage_set(slice, right)
    stride = get_stride(self)
    v_size = 1

    if right.is_a?(NMatrix)
Severity: Minor
Found in lib/nmatrix/jruby/slice.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 solve has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def solve(b, opts = {})
    raise(ShapeError, "Must be called on square matrix") unless self.dim == 2 && self.shape[0] == self.shape[1]
    raise(ShapeError, "number of rows of b must equal number of cols of self") if 
      self.shape[1] != b.shape[0]
    raise(ArgumentError, "only works with dense matrices") if self.stype != :dense
Severity: Minor
Found in lib/nmatrix/lapacke.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 transpose has a Cognitive Complexity of 12 (exceeds 5 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

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

  def solve(b, opts = {})
    raise(ShapeError, "Must be called on square matrix") unless self.dim == 2 && self.shape[0] == self.shape[1]
    raise(ShapeError, "number of rows of b must equal number of cols of self") if
      self.shape[1] != b.shape[0]
    raise(ArgumentError, "only works with dense matrices") if self.stype != :dense
Severity: Minor
Found in lib/nmatrix/cruby/math.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 pow has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def pow n
    raise ShapeError, "Only works with 2D square matrices." if
      shape[0] != shape[1] or shape.size != 2
    raise TypeError, "Only works with integer powers" unless n.is_a?(Integer)

Severity: Minor
Found in lib/nmatrix/math.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 singly_even_magic has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def singly_even_magic(nm, shape)
        half_shape = shape / 2
        complementary_pair = (shape - 2) / 4
        swap_col = NMatrix.new([shape])
        index = 0 
Severity: Minor
Found in lib/nmatrix/shortcuts.rb - About 1 hr to fix

    Method cblas_syrk has 11 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def cblas_syrk(order, uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
    Severity: Major
    Found in lib/nmatrix/blas.rb - About 1 hr to fix

      Method lapack_gesdd has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def lapack_gesdd(jobz, 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 gemv has 11 arguments (exceeds 4 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)
        Severity: Major
        Found in lib/nmatrix/blas.rb - About 1 hr to fix

          Method cblas_herk has 11 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def cblas_herk(order, uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
          Severity: Major
          Found in lib/nmatrix/blas.rb - About 1 hr to fix

            Method solve has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def solve(b, opts = {})
                raise(ShapeError, "Must be called on square matrix") unless self.dim == 2 && self.shape[0] == self.shape[1]
                raise(ShapeError, "number of rows of b must equal number of cols of self") if
                  self.shape[1] != b.shape[0]
                raise(ArgumentError, "only works with dense matrices") if self.stype != :dense
            Severity: Minor
            Found in lib/nmatrix/cruby/math.rb - About 1 hr to fix

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

                Method solve has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def solve(b, opts = {})
                    raise(ShapeError, "Must be called on square matrix") unless self.dim == 2 && self.shape[0] == self.shape[1]
                    raise(ShapeError, "number of rows of b must equal number of cols of self") if 
                      self.shape[1] != b.shape[0]
                    raise(ArgumentError, "only works with dense matrices") if self.stype != :dense
                Severity: Minor
                Found in lib/nmatrix/lapacke.rb - About 1 hr to fix

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

                    Method concat has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def concat(*matrices)
                        rank = nil
                        rank = matrices.pop unless matrices.last.is_a?(NMatrix)
                    
                        # Find the first matching dimension and concatenate along that (unless rank is specified)
                    Severity: Minor
                    Found in lib/nmatrix/nmatrix.rb - About 1 hr to fix

                      Method dense_storage_set has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def dense_storage_set(slice, right)
                          stride = get_stride(self)
                          v_size = 1
                      
                          if right.is_a?(NMatrix)
                      Severity: Minor
                      Found in lib/nmatrix/jruby/slice.rb - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language