SpeciesFileGroup/taxonworks

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

Summary

Maintainability
B
5 hrs
Test Coverage

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

  def self.generate(otus, project_members, root_otu_id = nil, reference_csv = nil, prefer_unlabelled_otus: true)

    # Until we have RC5 articulations we are simplifying handling the fact
    # that one taxon name can be used for many OTUs. Track to see that
    # an OTU with a given taxon name does not already exist
Severity: Minor
Found in lib/export/coldp/files/taxon.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 generate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def self.generate(otus, project_members, root_otu_id = nil, reference_csv = nil, prefer_unlabelled_otus: true)

    # Until we have RC5 articulations we are simplifying handling the fact
    # that one taxon name can be used for many OTUs. Track to see that
    # an OTU with a given taxon name does not already exist
Severity: Minor
Found in lib/export/coldp/files/taxon.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

Method generate has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.generate(otus, project_members, root_otu_id = nil, reference_csv = nil, prefer_unlabelled_otus: true)

    # Until we have RC5 articulations we are simplifying handling the fact
    # that one taxon name can be used for many OTUs. Track to see that
    # an OTU with a given taxon name does not already exist
Severity: Major
Found in lib/export/coldp/files/taxon.rb - About 2 hrs to fix

    Do not write to stdout. Use Rails's logger if you want to log.
    Open

                puts 'WARNING no parent!!'
    Severity: Minor
    Found in lib/export/coldp/files/taxon.rb by rubocop

    This cop checks for the use of output calls like puts and print

    Example:

    # bad
    puts 'A debug message'
    pp 'A debug message'
    print 'A debug message'
    
    # good
    Rails.logger.debug 'A debug message'

    TODO found
    Open

            # TODO: This was excluding OTUs that were being excluded downstream previously
    Severity: Minor
    Found in lib/export/coldp/files/taxon.rb by fixme

    TODO found
    Open

        # TODO: optional Taxon.alternativeID field allows inclusion of external identifiers: https://github.com/CatalogueOfLife/coldp#alternativeid-1 https://github.com/CatalogueOfLife/coldp#identifiers
    Severity: Minor
    Found in lib/export/coldp/files/taxon.rb by fixme

    TODO found
    Open

            # TODO: alter way parent is set to conform to CoLDP status
    Severity: Minor
    Found in lib/export/coldp/files/taxon.rb by fixme

    TODO found
    Open

            # TODO: remove once RC5 better modelled
    Severity: Minor
    Found in lib/export/coldp/files/taxon.rb by fixme

    TODO found
    Open

    # TODO: create map of all possible CoLDP used IRIs and ability to populate project with them automatically
    Severity: Minor
    Found in lib/export/coldp/files/taxon.rb by fixme

    TODO found
    Open

      #  TODO - reason in TW this is provisional name
    Severity: Minor
    Found in lib/export/coldp/files/taxon.rb by fixme

    TODO found
    Open

            # TODO: Use o.coordinate_otus to summarize accross different instances of the OTU
    Severity: Minor
    Found in lib/export/coldp/files/taxon.rb by fixme

    Freeze mutable objects assigned to constants.
    Open

      IRI_MAP = {
        extinct: 'https://api.checklistbank.org/datapackage#Taxon.extinct',                         # 1,0
        temporal_range_end: 'https://api.checklistbank.org/datapackage#Taxon.temporal_range_end',   # from https://api.checklistbank.org/vocab/geotime
        temporal_range_start: 'https://api.checklistbank.org/datapackage#Taxon.temporal_range_end', # from https://api.checklistbank.org/vocab/geotime
        lifezone: 'https://api.checklistbank.org/datapackage#Taxon.lifezone',                       # from https://api.checklistbank.org/vocab/lifezone
    Severity: Minor
    Found in lib/export/coldp/files/taxon.rb by rubocop

    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 = <<~TESTING.freeze
      This is a heredoc
    TESTING
    
    # good
    CONST = Something.new

    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

    Freeze mutable objects assigned to constants.
    Open

      SKIPPED_RANKS = %w{
        NomenclaturalRank::Iczn::SpeciesGroup::Superspecies
        NomenclaturalRank::Iczn::SpeciesGroup::Supersuperspecies
      }
    Severity: Minor
    Found in lib/export/coldp/files/taxon.rb by rubocop

    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 = <<~TESTING.freeze
      This is a heredoc
    TESTING
    
    # good
    CONST = Something.new

    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