SciRuby/nmatrix

View on GitHub
lib/nmatrix/math.rb

Summary

Maintainability
F
3 days
Test Coverage

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

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

        def svd_rank(tolerence="default")
          raise(ShapeError, "rank calculated only for 2-D matrices") unless
            self.dim == 2 
      
          sigmas = self.gesvd[1].to_a.flatten
      Severity: Minor
      Found in lib/nmatrix/math.rb - About 45 mins 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 matrix_norm has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def matrix_norm type = 2
          raise(NotImplementedError, "norm can be calculated only for 2D matrices") unless self.dim == 2
          raise(NotImplementedError, "norm only implemented for dense storage") unless self.stype == :dense
          raise(ArgumentError, "norm not defined for byte dtype")if self.dtype == :byte
          case type
      Severity: Minor
      Found in lib/nmatrix/math.rb - About 35 mins 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 invert! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def invert!
          raise(StorageTypeError, "invert only works on dense matrices currently") unless self.dense?
          raise(ShapeError, "Cannot invert non-square matrix") unless self.dim == 2 && self.shape[0] == self.shape[1]
          raise(DataTypeError, "Cannot invert an integer matrix in-place") if self.integer_dtype?
      
      
      Severity: Minor
      Found in lib/nmatrix/math.rb - About 25 mins 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 exact_inverse! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def exact_inverse!
          raise(ShapeError, "Cannot invert non-square matrix") unless self.dim == 2 && self.shape[0] == self.shape[1]
          raise(DataTypeError, "Cannot invert an integer matrix in-place") if self.integer_dtype?
          #No internal implementation of getri, so use this other function
          n = self.shape[0]
      Severity: Minor
      Found in lib/nmatrix/math.rb - About 25 mins 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 adjugate! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def adjugate!
          raise(StorageTypeError, "adjugate only works on dense matrices currently") unless self.dense?
          raise(ShapeError, "Cannot calculate adjugate of a non-square matrix") unless self.dim == 2 && self.shape[0] == self.shape[1]
          raise(DataTypeError, "Cannot calculate adjugate of an integer matrix in-place") if self.integer_dtype?
          d = self.det
      Severity: Minor
      Found in lib/nmatrix/math.rb - About 25 mins 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 positive_definite? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def positive_definite?
          raise(ShapeError, "positive definite calculated only for square matrices") unless
            self.dim == 2 && self.shape[0] == self.shape[1]
          cond = 0
          while cond != self.cols
      Severity: Minor
      Found in lib/nmatrix/math.rb - About 25 mins 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 max(dimen=0)
          inject_rank(dimen) do |max, sub_mat|
            if max.is_a? NMatrix then
              max * (max >= sub_mat).cast(self.stype, self.dtype) + ((max)*0.0 + (max < sub_mat).cast(self.stype, self.dtype)) * sub_mat
            else
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 50 mins to fix
      lib/nmatrix/math.rb on lines 526..532

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

      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 min(dimen=0)
          inject_rank(dimen) do |min, sub_mat|
            if min.is_a? NMatrix then
              min * (min <= sub_mat).cast(self.stype, self.dtype) + ((min)*0.0 + (min > sub_mat).cast(self.stype, self.dtype)) * sub_mat
            else
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 50 mins to fix
      lib/nmatrix/math.rb on lines 545..551

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

      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

          define_method("__yale_unary_#{meth}__") do
            return_dtype = dtype_for_floor_or_ceil
      
            if [:complex64, :complex128].include?(self.dtype)
              self.__yale_map_stored__ { |l| Complex(l.real.send(meth), l.imag.send(meth)) }.cast(stype, return_dtype)
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 50 mins to fix
      lib/nmatrix/math.rb on lines 861..867

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

      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

          define_method("__dense_unary_#{meth}__") do
            return_dtype = dtype_for_floor_or_ceil
      
            if [:complex64, :complex128].include?(self.dtype)
              self.__dense_map__ { |l| Complex(l.real.send(meth), l.imag.send(meth)) }.cast(stype, return_dtype)
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 50 mins to fix
      lib/nmatrix/math.rb on lines 851..857

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

      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

          define_method("__list_elementwise_#{ewop}__") do |rhs,order|
            if order then
              self.__list_map_merged_stored__(rhs, nil) { |r,l| Math.send(ewop,l,r) }
            else
              self.__list_map_merged_stored__(rhs, nil) { |l,r| Math.send(ewop,l,r) }
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 40 mins to fix
      lib/nmatrix/math.rb on lines 892..897

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

      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

          define_method("__yale_elementwise_#{ewop}__") do |rhs, order|
            if order then
              self.__yale_map_merged_stored__(rhs, nil) { |r,l| Math.send(ewop,l,r) }
            else
              self.__yale_map_merged_stored__(rhs, nil) { |l,r| Math.send(ewop,l,r) }
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 40 mins to fix
      lib/nmatrix/math.rb on lines 876..881

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

      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 inf_matrix_norm minus = false
          number_of_rows = self.rows
          row_sums = []
      
          number_of_rows.times do |i|
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 35 mins to fix
      lib/nmatrix/math.rb on lines 651..661

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

      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 one_matrix_norm minus = false
          #TODO: change traversing method for sparse matrices
          number_of_columns = self.cols
          col_sums = []
      
      
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 35 mins to fix
      lib/nmatrix/math.rb on lines 665..674

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

      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

          define_method("__dense_scalar_#{ewop}__") do |rhs,order|
            if order
              self.__dense_map__ { |l| Math.send(ewop, rhs, l) }
            else
              self.__dense_map__ { |l| Math.send(ewop, l, rhs) }
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 30 mins to fix
      lib/nmatrix/math.rb on lines 908..913

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

      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

          define_method("__yale_scalar_#{ewop}__") do |rhs,order|
            if order then
              self.__yale_map_stored__ { |l| Math.send(ewop, rhs, l) }
            else
              self.__yale_map_stored__ { |l| Math.send(ewop, l, rhs) }
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 30 mins to fix
      lib/nmatrix/math.rb on lines 916..921

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

      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 __dense_unary_round__(precision)
          if self.complex_dtype?
            self.__dense_map__ { |l| Complex(l.real.round(precision), l.imag.round(precision)) }
                                          .cast(stype, dtype)
          else
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 25 mins to fix
      lib/nmatrix/math.rb on lines 811..816

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

      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 __yale_unary_round__(precision)
          if self.complex_dtype?
            self.__yale_map_stored__ { |l| Complex(l.real.round(precision), l.imag.round(precision)) }
                                          .cast(stype, dtype)
          else
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 25 mins to fix
      lib/nmatrix/math.rb on lines 820..825

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

      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

      There are no issues that match your filters.

      Category
      Status