SciRuby/nmatrix

View on GitHub

Showing 196 of 196 total issues

Method repacked_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def repacked_data(to_dtype = nil)

        real_mdtype = self.real_part.tag.data_type

        # Figure out what dtype to use based on the MATLAB data-types
Severity: Minor
Found in lib/nmatrix/io/mat5_reader.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 read_entry has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def read_entry f, entry, assign=nil, convert=nil
      assign ||= (entry.to_s + "=").to_sym

      while line = f.gets
        next if line =~ /^\s*#/ # ignore comment lines
Severity: Minor
Found in lib/nmatrix/io/point_cloud.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 det has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def det
    raise(ShapeError, "determinant can be calculated only for square matrices") unless self.dim == 2 && self.shape[0] == self.shape[1]

    # Cast to a dtype for which getrf is implemented
    new_dtype = self.integer_dtype? ? :float64 : self.dtype
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 dense_storage_get has a Cognitive Complexity of 11 (exceeds 5 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

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 29 lines of code (exceeds 25 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 1 hr to fix

    Method header has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def header
              return @header if !@header.empty?
              @file = File.open @file_name, "r"
    
              line = @file.gets
    Severity: Minor
    Found in lib/nmatrix/io/harwell_boeing.rb - About 1 hr to fix

      Method concat has a Cognitive Complexity of 10 (exceeds 5 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

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

            def posv(uplo, a, b)
              raise(ShapeError, "a must be square") unless a.dim == 2 && a.shape[0] == a.shape[1]
              raise(ShapeError, "number of rows of b must equal number of cols of a") unless a.shape[1] == b.shape[0]
              raise(StorageTypeError, "only works with dense matrices") unless a.stype == :dense && b.stype == :dense
              raise(DataTypeError, "only works for non-integer, non-object dtypes") if 
      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 =~ has a Cognitive Complexity of 10 (exceeds 5 allowed). 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: Minor
      Found in lib/nmatrix/jruby/nmatrix_java.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 < has a Cognitive Complexity of 10 (exceeds 5 allowed). 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: Minor
      Found in lib/nmatrix/jruby/nmatrix_java.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 posv has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def posv(uplo, a, b)
              raise(ShapeError, "a must be square") unless a.dim == 2 \
               && a.shape[0] == a.shape[1]
      
              raise(ShapeError, "number of rows of b must equal number of cols of a") \
      Severity: Minor
      Found in lib/nmatrix/atlas.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 pinv has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def pinv(tolerance = 1e-15)
          raise DataTypeError, "pinv works only with matrices of float or complex data type" unless
            [:float32, :float64, :complex64, :complex128].include?(dtype)
          if self.complex_dtype?
            u, s, vt = self.complex_conjugate.gesvd # singular value decomposition
      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 !~ has a Cognitive Complexity of 10 (exceeds 5 allowed). 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: Minor
      Found in lib/nmatrix/jruby/nmatrix_java.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 is_symmetric has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def is_symmetric(hermitian)
          is_symmetric = true
      
          if (@shape[0] == @shape[1] and @dim == 2)
            if @stype == :dense
      Severity: Minor
      Found in lib/nmatrix/jruby/nmatrix_java.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 > has a Cognitive Complexity of 10 (exceeds 5 allowed). 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: Minor
      Found in lib/nmatrix/jruby/nmatrix_java.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 >= has a Cognitive Complexity of 10 (exceeds 5 allowed). 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: Minor
      Found in lib/nmatrix/jruby/nmatrix_java.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 slice_set has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def slice_set(dest, lengths, pdest, rank, v, v_size, v_offset)
          if (dim - rank > 1)
            (0...lengths[rank]).each do |i|
              slice_set(dest, lengths, pdest + dest[:stride][rank] * i, rank + 1, v, v_size, v_offset);
            end
      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 <= has a Cognitive Complexity of 10 (exceeds 5 allowed). 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: Minor
      Found in lib/nmatrix/jruby/nmatrix_java.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 4 locations. Consider refactoring.
      Open

        def +(other)
          result = create_dummy_nmatrix
          if (other.is_a?(NMatrix))
            #check dimension
            raise(ShapeError, "Cannot add matrices with different dimension") if (@dim != other.dim)
      Severity: Major
      Found in lib/nmatrix/jruby/operators.rb and 3 other locations - About 1 hr to fix
      lib/nmatrix/jruby/operators.rb on lines 21..34
      lib/nmatrix/jruby/operators.rb on lines 37..50
      lib/nmatrix/jruby/operators.rb on lines 53..66

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

      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

        def /(other)
          result = create_dummy_nmatrix
          if (other.is_a?(NMatrix))
            #check dimension
            raise(ShapeError, "Cannot divide matrices with different dimension") if (@dim != other.dim)
      Severity: Major
      Found in lib/nmatrix/jruby/operators.rb and 3 other locations - About 1 hr to fix
      lib/nmatrix/jruby/operators.rb on lines 5..18
      lib/nmatrix/jruby/operators.rb on lines 21..34
      lib/nmatrix/jruby/operators.rb on lines 37..50

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

      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