biotcm/biotcm

View on GitHub
lib/biotcm/table.rb

Summary

Maintainability
D
2 days
Test Coverage

Class Table has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Table
    # Version
    VERSION = '0.6.1'.freeze

    # Primary key
Severity: Minor
Found in lib/biotcm/table.rb - About 3 hrs to fix

    File table.rb has 311 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module BioTCM
      # One of the basic data models used in BioTCM to process
      # {https://github.com/biotcm/biotcm/wiki/Formats#tab .tab files},
      # developed under <b>"strict entry and tolerant exit"</b> philosophy.
      #
    Severity: Minor
    Found in lib/biotcm/table.rb - About 3 hrs to fix

      Method set_row has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_row(row, val)
            # Setter
            if !row.is_a?(String) || (!val.is_a?(Hash) && !val.is_a?(Array))
              raise ArgumentError, 'Illegal argument type'
            elsif val.is_a?(Array) && val.size != col_keys.size
      Severity: Minor
      Found in lib/biotcm/table.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 set_col has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_col(col, val)
            if !col.is_a?(String) || (!val.is_a?(Hash) && !val.is_a?(Array))
              raise ArgumentError, 'Illegal argument type'
            elsif val.is_a?(Array) && val.size != row_keys.size
              raise ArgumentError, 'Row size not match'
      Severity: Minor
      Found in lib/biotcm/table.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 merge has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def merge(tab)
            raise ArgumentError, 'Only tables could be merged' unless tab.is_a?(self.class)
            raise ArgumentError, 'Primary keys not the same' unless tab.primary_key == primary_key
      
            # Empty content
      Severity: Minor
      Found in lib/biotcm/table.rb - About 1 hr to fix

        Method to_table has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

                def to_table(seperator: "\t")
                  stuff = split(/\r\n|\n/)
        
                  # Comments
                  comments = []
        Severity: Minor
        Found in lib/biotcm/table.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 to_table has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def to_table(seperator: "\t")
                  stuff = split(/\r\n|\n/)
        
                  # Comments
                  comments = []
        Severity: Minor
        Found in lib/biotcm/table.rb - About 1 hr to fix

          Method select has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def select(rows, cols)
                # Prune rows
                if rows == :all
                  row_keys = @row_keys.clone
                  content = @content.collect(&:clone)
          Severity: Minor
          Found in lib/biotcm/table.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 set_col has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def set_col(col, val)
                if !col.is_a?(String) || (!val.is_a?(Hash) && !val.is_a?(Array))
                  raise ArgumentError, 'Illegal argument type'
                elsif val.is_a?(Array) && val.size != row_keys.size
                  raise ArgumentError, 'Row size not match'
          Severity: Minor
          Found in lib/biotcm/table.rb - About 1 hr to fix

            Method set_row has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def set_row(row, val)
                  # Setter
                  if !row.is_a?(String) || (!val.is_a?(Hash) && !val.is_a?(Array))
                    raise ArgumentError, 'Illegal argument type'
                  elsif val.is_a?(Array) && val.size != col_keys.size
            Severity: Minor
            Found in lib/biotcm/table.rb - About 1 hr to fix

              Method set_ele has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def set_ele(row, col, val)
                    unless row.is_a?(String) && col.is_a?(String) && val.respond_to?(:to_s)
                      raise ArgumentError, 'Illegal argument type'
                    end
              
              
              Severity: Minor
              Found in lib/biotcm/table.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

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

                    if !col.is_a?(String) || (!val.is_a?(Hash) && !val.is_a?(Array))
                      raise ArgumentError, 'Illegal argument type'
                    elsif val.is_a?(Array) && val.size != row_keys.size
                      raise ArgumentError, 'Row size not match'
                    end
              Severity: Minor
              Found in lib/biotcm/table.rb and 1 other location - About 25 mins to fix
              lib/biotcm/table.rb on lines 189..193

              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

                    if !row.is_a?(String) || (!val.is_a?(Hash) && !val.is_a?(Array))
                      raise ArgumentError, 'Illegal argument type'
                    elsif val.is_a?(Array) && val.size != col_keys.size
                      raise ArgumentError, 'Column size not match'
                    end
              Severity: Minor
              Found in lib/biotcm/table.rb and 1 other location - About 25 mins to fix
              lib/biotcm/table.rb on lines 251..255

              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 each_col
                    if block_given?
                      @col_keys.each_key { |c| yield(c, col(c)) }
                      self
                    else
              Severity: Minor
              Found in lib/biotcm/table.rb and 1 other location - About 20 mins to fix
              lib/biotcm/table.rb on lines 283..289

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

              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 col_keys=(val)
                    raise ArgumentError, 'Illegal agrument type' unless val.is_a?(Array)
                    raise ArgumentError, 'Unmatched size' if val.size < @col_keys.size
                    @col_keys = val.map.with_index { |v, i| [v, i] }.to_h
              Severity: Minor
              Found in lib/biotcm/table.rb and 1 other location - About 20 mins to fix
              lib/biotcm/table.rb on lines 77..80

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

              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 each_row
                    if block_given?
                      @row_keys.each_key { |r| yield(r, row(r)) }
                      self
                    else
              Severity: Minor
              Found in lib/biotcm/table.rb and 1 other location - About 20 mins to fix
              lib/biotcm/table.rb on lines 295..301

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

              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 row_keys=(val)
                    raise ArgumentError, 'Illegal agrument type' unless val.is_a?(Array)
                    raise ArgumentError, 'Unmatched size' if val.size < @row_keys.size
                    @row_keys = val.map.with_index { |v, i| [v, i] }.to_h
              Severity: Minor
              Found in lib/biotcm/table.rb and 1 other location - About 20 mins to fix
              lib/biotcm/table.rb on lines 91..94

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

              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