SpeciesFileGroup/taxonworks

View on GitHub
lib/batch_load/import/otus/data_attributes_interpreter.rb

Summary

Maintainability
C
1 day
Test Coverage

Method has too many lines. [72/25]
Open

    def build_da_for_otus
      @total_data_lines = 0
      i = 0
      import_klass = type_select.start_with?('im')
      att_klass = (type_select.capitalize + 'Attribute').safe_constantize

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method build_da_for_otus has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    def build_da_for_otus
      @total_data_lines = 0
      i = 0
      import_klass = type_select.start_with?('im')
      att_klass = (type_select.capitalize + 'Attribute').safe_constantize
Severity: Minor
Found in lib/batch_load/import/otus/data_attributes_interpreter.rb - About 6 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 build_da_for_otus has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def build_da_for_otus
      @total_data_lines = 0
      i = 0
      import_klass = type_select.start_with?('im')
      att_klass = (type_select.capitalize + 'Attribute').safe_constantize
Severity: Major
Found in lib/batch_load/import/otus/data_attributes_interpreter.rb - About 2 hrs to fix

    Method create has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def create
          sorted_processed_rows.each_value do |processed_row|
            otu = processed_row.objects[:otu].first
            d_a = processed_row.objects[:data_attribute].first
            cvt = processed_row.objects[:predicate].first
    Severity: Minor
    Found in lib/batch_load/import/otus/data_attributes_interpreter.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

    TODO found
    Open

    # TODO: THIS IS A GENERATED STUB, it does not function

    Freeze mutable objects assigned to constants.
    Open

        SAVE_ORDER = [:predicate, :otu, :data_attribute, :citation]

    This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

    Strict mode can be used to freeze all constants, rather than just literals. Strict mode is considered an experimental feature. It has not been updated with an exhaustive list of all methods that will produce frozen objects so there is a decent chance of getting some false positives. Luckily, there is no harm in freezing an already frozen object.

    Example: EnforcedStyle: literals (default)

    # bad
    CONST = [1, 2, 3]
    
    # good
    CONST = [1, 2, 3].freeze
    
    # good
    CONST = <

    Example: EnforcedStyle: strict

    # bad
    CONST = Something.new
    
    # bad
    CONST = Struct.new do
      def foo
        puts 1
      end
    end
    
    # good
    CONST = Something.new.freeze
    
    # good
    CONST = Struct.new do
      def foo
        puts 1
      end
    end.freeze

    There are no issues that match your filters.

    Category
    Status