GlobalNamesArchitecture/dwc-archive

View on GitHub

Showing 15 of 15 total issues

Method ingest_core has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
Open

    def ingest_core
      @normalized_data = {}
      has_name_and_id = @core_fields[:id] && @core_fields[:scientificname]
      unless has_name_and_id
        raise(DarwinCore::CoreFileError,
Severity: Minor
Found in lib/dwc_archive/classification_normalizer.rb - About 1 day 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 get_classification_path has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

    def get_classification_path(taxon)
      return unless taxon.classification_path_id.empty?

      @paths_num += 1
      if @paths_num % 10_000 == 0
Severity: Minor
Found in lib/dwc_archive/classification_normalizer.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

File classification_normalizer.rb has 339 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class DarwinCore
  # Returns tree representation of Darwin Core file with vernacular and
  # and synonyms attached to the taxon nodes
  class ClassificationNormalizer
    attr_reader :error_names, :tree, :normalized_data, :dwc
Severity: Minor
Found in lib/dwc_archive/classification_normalizer.rb - About 4 hrs to fix

    Class ClassificationNormalizer has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class ClassificationNormalizer
        attr_reader :error_names, :tree, :normalized_data, :dwc
        alias darwin_core dwc
    
        def initialize(dwc_instance)
    Severity: Minor
    Found in lib/dwc_archive/classification_normalizer.rb - About 3 hrs to fix

      Method get_classification_path has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def get_classification_path(taxon)
            return unless taxon.classification_path_id.empty?
      
            @paths_num += 1
            if @paths_num % 10_000 == 0
      Severity: Major
      Found in lib/dwc_archive/classification_normalizer.rb - About 2 hrs to fix

        Method read has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def read(batch_size = 10_000)
              DarwinCore.logger_write(@dwc.object_id, "Reading #{name} data")
              res = []
              errors = []
              args = define_csv_args
        Severity: Minor
        Found in lib/dwc_archive/ingester.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 ingest_core has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def ingest_core
              @normalized_data = {}
              has_name_and_id = @core_fields[:id] && @core_fields[:scientificname]
              unless has_name_and_id
                raise(DarwinCore::CoreFileError,
        Severity: Major
        Found in lib/dwc_archive/classification_normalizer.rb - About 2 hrs to fix

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

              def add_synonym_from_core(taxon_id, row)
                cf = @core_fields
                @synonyms[row[cf[:id]]] = taxon_id
                @normalized_data[row[taxon_id]] = DarwinCore::TaxonNormalized.new unless @normalized_data[row[taxon_id]]
          
          
          Severity: Minor
          Found in lib/dwc_archive/classification_normalizer.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 process_synonym has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def process_synonym(record, fields)
                set_scientific_name(record, fields)
                SynonymNormalized.new(
                  nil,
                  record[fields[:scientificname]],
          Severity: Minor
          Found in lib/dwc_archive/classification_normalizer.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

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

              def calculate_classification_path
                @paths_num = 0
                @normalized_data.each do |_taxon_id, taxon|
                  next unless taxon.classification_path_id.empty?
          
          
          Severity: Minor
          Found in lib/dwc_archive/classification_normalizer.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

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

              def process_csv_row(result, errors, row)
                str = row.join("")
                str = str.force_encoding("utf-8")
                if str.encoding.name == "UTF-8" && str.valid_encoding?
                  result << row.map { |f| f.nil? ? nil : f.force_encoding("utf-8") }
          Severity: Minor
          Found in lib/dwc_archive/ingester.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

          Method set_scientific_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def set_scientific_name(row, fields)
                row[fields[:scientificname]] = "N/A" unless row[fields[:scientificname]]
                canonical_name = nil
                scientific_name = row[fields[:scientificname]].strip
                if separate_canonical_and_authorship?(row, fields)
          Severity: Minor
          Found in lib/dwc_archive/classification_normalizer.rb - About 25 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

          Method search_for_file_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def search_for_file_path(entries)
                res = nil
                entries.each do |e|
                  check_path = File.join(@dir_path, e)
                  next unless FileTest.directory?(check_path) &&
          Severity: Minor
          Found in lib/dwc_archive/expander.rb - About 25 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

          Method unpack has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def unpack
                clean
                raise DarwinCore::FileNotFoundError unless File.exist?(@archive_path)
          
                success = @unpacker.call(@dir_path, @archive_path) if @unpacker
          Severity: Minor
          Found in lib/dwc_archive/expander.rb - About 25 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

          Method extract_vernaculars_from_row has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def extract_vernaculars_from_row(row, fields)
                language = find_vernacular_language(row, fields)
                locality = fields[:locality] ? row[fields[:locality]] : nil
                country_code = fields[:countrycode] ? row[fields[:countrycode]] : nil
          
          
          Severity: Minor
          Found in lib/dwc_archive/classification_normalizer.rb - About 25 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

          Severity
          Category
          Status
          Source
          Language