SciRuby/statsample

View on GitHub
lib/statsample/matrix.rb

Summary

Maintainability
B
4 hrs
Test Coverage

File matrix.rb has 256 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class ::Vector
  def to_matrix
    ::Matrix.columns([self.to_a])
  end
  def to_vector
Severity: Minor
Found in lib/statsample/matrix.rb - About 2 hrs to fix

    Method submatrix has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def submatrix(rows,columns = nil)
          raise ArgumentError, "rows shouldn't be empty" if rows.respond_to? :size and rows.size == 0
          columns ||= rows
          # Convert all fields on index
          row_index = rows.collect do |v|
    Severity: Minor
    Found in lib/statsample/matrix.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 correlation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def correlation
          if(_type==:covariance)
            matrix=Matrix.rows(row_size.times.collect { |i|
              column_size.times.collect { |j|
                if i==j
    Severity: Minor
    Found in lib/statsample/matrix.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 report_building has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def report_building(generator)
          @name||= (_type==:correlation ? _("Correlation"):_("Covariance"))+_(" Matrix")
          generator.table(:name=>@name, :header=>[""]+fields_y) do |t|
            row_size.times {|i|
              t.row([fields_x[i]]+row(i).to_a.collect {|i1|
    Severity: Minor
    Found in lib/statsample/matrix.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

    There are no issues that match your filters.

    Category
    Status