SciRuby/nmatrix

View on GitHub

Showing 196 of 196 total issues

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

        def meshgrid(vectors, options = {})
          raise(ArgumentError, 'Expected at least 2 arrays.') if vectors.size < 2
          options[:indexing] ||= :xy
          raise(ArgumentError, 'Indexing must be :xy of :ij') unless [:ij, :xy].include? options[:indexing]
          mats = vectors.map { |arr| arr.respond_to?(:flatten) ? arr.flatten : arr.to_flat_array }
    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 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

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

          def <= (other)
            lha = @s.toArray.to_a
            rha = other.s.toArray.to_a
            resultArray = Array.new(lha.length)
            if (other.is_a?(NMatrix))
        Severity: Major
        Found in lib/nmatrix/jruby/nmatrix_java.rb and 5 other locations - About 2 hrs to fix
        lib/nmatrix/jruby/nmatrix_java.rb on lines 516..542
        lib/nmatrix/jruby/nmatrix_java.rb on lines 545..571
        lib/nmatrix/jruby/nmatrix_java.rb on lines 603..629
        lib/nmatrix/jruby/nmatrix_java.rb on lines 632..658
        lib/nmatrix/jruby/nmatrix_java.rb on lines 661..687

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

        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 6 locations. Consider refactoring.
        Open

          def !~ (other)
            lha = @s.toArray.to_a
            rha = other.s.toArray.to_a
            resultArray = Array.new(lha.length)
            if (other.is_a?(NMatrix))
        Severity: Major
        Found in lib/nmatrix/jruby/nmatrix_java.rb and 5 other locations - About 2 hrs to fix
        lib/nmatrix/jruby/nmatrix_java.rb on lines 516..542
        lib/nmatrix/jruby/nmatrix_java.rb on lines 574..600
        lib/nmatrix/jruby/nmatrix_java.rb on lines 603..629
        lib/nmatrix/jruby/nmatrix_java.rb on lines 632..658
        lib/nmatrix/jruby/nmatrix_java.rb on lines 661..687

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

        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 6 locations. Consider refactoring.
        Open

          def >= (other)
            lha = @s.toArray.to_a
            rha = other.s.toArray.to_a
            resultArray = Array.new(lha.length)
            if (other.is_a?(NMatrix))
        Severity: Major
        Found in lib/nmatrix/jruby/nmatrix_java.rb and 5 other locations - About 2 hrs to fix
        lib/nmatrix/jruby/nmatrix_java.rb on lines 516..542
        lib/nmatrix/jruby/nmatrix_java.rb on lines 545..571
        lib/nmatrix/jruby/nmatrix_java.rb on lines 574..600
        lib/nmatrix/jruby/nmatrix_java.rb on lines 632..658
        lib/nmatrix/jruby/nmatrix_java.rb on lines 661..687

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

        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 6 locations. Consider refactoring.
        Open

          def < (other)
            lha = @s.toArray.to_a
            rha = other.s.toArray.to_a
            resultArray = Array.new(lha.length)
            if (other.is_a?(NMatrix))
        Severity: Major
        Found in lib/nmatrix/jruby/nmatrix_java.rb and 5 other locations - About 2 hrs to fix
        lib/nmatrix/jruby/nmatrix_java.rb on lines 516..542
        lib/nmatrix/jruby/nmatrix_java.rb on lines 545..571
        lib/nmatrix/jruby/nmatrix_java.rb on lines 574..600
        lib/nmatrix/jruby/nmatrix_java.rb on lines 603..629
        lib/nmatrix/jruby/nmatrix_java.rb on lines 661..687

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

        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 6 locations. Consider refactoring.
        Open

          def =~ (other)
            lha = @s.toArray.to_a
            rha = other.s.toArray.to_a
            resultArray = Array.new(lha.length)
            if (other.is_a?(NMatrix))
        Severity: Major
        Found in lib/nmatrix/jruby/nmatrix_java.rb and 5 other locations - About 2 hrs to fix
        lib/nmatrix/jruby/nmatrix_java.rb on lines 545..571
        lib/nmatrix/jruby/nmatrix_java.rb on lines 574..600
        lib/nmatrix/jruby/nmatrix_java.rb on lines 603..629
        lib/nmatrix/jruby/nmatrix_java.rb on lines 632..658
        lib/nmatrix/jruby/nmatrix_java.rb on lines 661..687

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

        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 6 locations. Consider refactoring.
        Open

          def > (other)
            lha = @s.toArray.to_a
            rha = other.s.toArray.to_a
            resultArray = Array.new(lha.length)
            if (other.is_a?(NMatrix))
        Severity: Major
        Found in lib/nmatrix/jruby/nmatrix_java.rb and 5 other locations - About 2 hrs to fix
        lib/nmatrix/jruby/nmatrix_java.rb on lines 516..542
        lib/nmatrix/jruby/nmatrix_java.rb on lines 545..571
        lib/nmatrix/jruby/nmatrix_java.rb on lines 574..600
        lib/nmatrix/jruby/nmatrix_java.rb on lines 603..629
        lib/nmatrix/jruby/nmatrix_java.rb on lines 632..658

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

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

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

            def ormqr(tau, side=:left, transpose=false, c=nil)
              raise(StorageTypeError, "LAPACK functions only work on dense matrices") unless self.dense?
              raise(TypeError, "Works only on floating point matrices, use unmqr for complex types") if self.complex_dtype?
              raise(TypeError, "c must have the same dtype as the calling NMatrix") if c and c.dtype != self.dtype
          
          
          Severity: Major
          Found in lib/nmatrix/lapacke.rb and 1 other location - About 1 hr to fix
          lib/nmatrix/lapacke.rb on lines 340..349

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

          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 unmqr(tau, side=:left, transpose=false, c=nil)
              raise(StorageTypeError, "ATLAS functions only work on dense matrices") unless self.dense?
              raise(TypeError, "Works only on complex matrices, use ormqr for normal floating point matrices") unless self.complex_dtype?
              raise(TypeError, "c must have the same dtype as the calling NMatrix") if c and c.dtype != self.dtype
          
          
          Severity: Major
          Found in lib/nmatrix/lapacke.rb and 1 other location - About 1 hr to fix
          lib/nmatrix/lapacke.rb on lines 299..309

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

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

          Severity
          Category
          Status
          Source
          Language