SciRuby/nmatrix

View on GitHub

Showing 196 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

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

                        if !matrix.complex_dtype?
                          complex_indices = []
                          n.times do |i|
                            complex_indices << i if imag_eigenvalues[i] != 0.0
                          end
                Severity: Major
                Found in lib/nmatrix/lapacke.rb and 1 other location - About 4 hrs to fix
                lib/nmatrix/atlas.rb on lines 130..157

                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 149.

                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

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

                        if !matrix.complex_dtype?
                          complex_indices = []
                          n.times do |i|
                            complex_indices << i if imag_eigenvalues[i] != 0.0
                          end
                Severity: Major
                Found in lib/nmatrix/atlas.rb and 1 other location - About 4 hrs to fix
                lib/nmatrix/lapacke.rb on lines 110..131

                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 149.

                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

                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
                      Severity
                      Category
                      Status
                      Source
                      Language