SpeciesFileGroup/taxonworks

View on GitHub
lib/batch_load/import/taxonifi_to_taxonworks.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

    def build_protonyms
      if name_collection.nil?
        @file_errors.push 'No names were readable in the file.'
        return
      end

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

    def build_protonyms
      if name_collection.nil?
        @file_errors.push 'No names were readable in the file.'
        return
      end
Severity: Minor
Found in lib/batch_load/import/taxonifi_to_taxonworks.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 build_protonyms has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def build_protonyms
      if name_collection.nil?
        @file_errors.push 'No names were readable in the file.'
        return
      end
Severity: Minor
Found in lib/batch_load/import/taxonifi_to_taxonworks.rb - About 1 hr to fix

    Use @parent_taxon_name_id.present? instead of !@parent_taxon_name_id.blank?.
    Open

          if !@parent_taxon_name_id.blank?

    This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

    Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

    Example: NotNilAndNotEmpty: true (default)

    # Converts usages of `!nil? && !empty?` to `present?`
    
    # bad
    !foo.nil? && !foo.empty?
    
    # bad
    foo != nil && !foo.empty?
    
    # good
    foo.present?

    Example: NotBlank: true (default)

    # Converts usages of `!blank?` to `present?`
    
    # bad
    !foo.blank?
    
    # bad
    not foo.blank?
    
    # good
    foo.present?

    Example: UnlessBlank: true (default)

    # Converts usages of `unless blank?` to `if present?`
    
    # bad
    something unless foo.blank?
    
    # good
    something if foo.present?

    There are no issues that match your filters.

    Category
    Status