SpeciesFileGroup/taxonworks

View on GitHub
lib/export/coldp/files/name.rb

Summary

Maintainability
D
1 day
Test Coverage

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

  def self.generate(otu, reference_csv = nil)
     name_total = 0
    CSV.generate(col_sep: "\t") do |csv|
      csv << %w{
        ID
Severity: Minor
Found in lib/export/coldp/files/name.rb by rubocop

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 has too many lines. [63/25]
Open

  def self.add_original_combination(t, csv)
    e = t.original_combination_elements

    infraspecific_element = t.original_combination_infraspecific_element(e)

Severity: Minor
Found in lib/export/coldp/files/name.rb by rubocop

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

  def self.add_original_combination(t, csv)
    e = t.original_combination_elements

    infraspecific_element = t.original_combination_infraspecific_element(e)

Severity: Minor
Found in lib/export/coldp/files/name.rb - About 4 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 generate has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  def self.generate(otu, reference_csv = nil)
     name_total = 0
    CSV.generate(col_sep: "\t") do |csv|
      csv << %w{
        ID
Severity: Minor
Found in lib/export/coldp/files/name.rb - About 3 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 generate has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.generate(otu, reference_csv = nil)
     name_total = 0
    CSV.generate(col_sep: "\t") do |csv|
      csv << %w{
        ID
Severity: Major
Found in lib/export/coldp/files/name.rb - About 3 hrs to fix

    Method add_original_combination has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.add_original_combination(t, csv)
        e = t.original_combination_elements
    
        infraspecific_element = t.original_combination_infraspecific_element(e)
    
    
    Severity: Major
    Found in lib/export/coldp/files/name.rb - About 2 hrs to fix

      Method nom_status_field has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.nom_status_field(taxon_name)
          case taxon_name.type
          when 'Combination'
            nil # This is *not* 'chresonym' sensu CoL (which is this: [correct: 'Aus bus Smith 1920', chresonym: 'Aus bus Jones 1922'])
          else
      Severity: Minor
      Found in lib/export/coldp/files/name.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

      Use t.cached_original_combination.present? instead of !t.cached_original_combination.blank?.
      Open

                if !t.cached_original_combination.blank? && (is_genus_species && !t.is_combination? && (!t.is_valid? || t.has_alternate_original?))
      Severity: Minor
      Found in lib/export/coldp/files/name.rb by rubocop

      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?

      TODO found
      Open

                # TODO: Subgenus as Genus combination may break this
      Severity: Minor
      Found in lib/export/coldp/files/name.rb by fixme

      TODO found
      Open

                # TODO: consider faster ways to check for misspellings
      Severity: Minor
      Found in lib/export/coldp/files/name.rb by fixme

      TODO found
      Open

              # TODO: handle > quadranomial names (e.g. super species like `Bus (Dus aus aus) aus eus var. fus`
      Severity: Minor
      Found in lib/export/coldp/files/name.rb by fixme

      TODO found
      Open

          name&.gsub(/\s+\[sic\]/, '') # TODO: remove `&` once cached_original_combination is re-indexed
      Severity: Minor
      Found in lib/export/coldp/files/name.rb by fixme

      TODO found
      Open

                # TODO: Combinations don't have rank BUT CoL importer can interpret, so we're OK here for now
      Severity: Minor
      Found in lib/export/coldp/files/name.rb by fixme

      Use 2 (not 3) spaces for indentation.
      Open

           name_total = 0
      Severity: Minor
      Found in lib/export/coldp/files/name.rb by rubocop

      This cop checks for indentation that doesn't use the specified number of spaces.

      See also the IndentationConsistency cop which is the companion to this one.

      Example:

      # bad
      class A
       def test
        puts 'hello'
       end
      end
      
      # good
      class A
        def test
          puts 'hello'
        end
      end

      Example: IgnoredPatterns: ['^\s*module']

      # bad
      module A
      class B
        def test
        puts 'hello'
        end
      end
      end
      
      # good
      module A
      class B
        def test
          puts 'hello'
        end
      end
      end

      There are no issues that match your filters.

      Category
      Status