GlobalNamesArchitecture/dwca-hunter

View on GitHub
lib/dwca_hunter/resources/mammal_divdb.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method generate_dwca has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def generate_dwca
      DwcaHunter.logger_write(object_id,
                              "Creating DarwinCore Archive file")
      @core = [["http://rs.tdwg.org/dwc/terms/taxonID",
                "http://rs.tdwg.org/dwc/terms/scientificName",
Severity: Major
Found in lib/dwca_hunter/resources/mammal_divdb.rb - About 2 hrs to fix

    Method collect_names has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def collect_names
          @names_index = {}
          file = CSV.open(File.join(@download_dir, find_csv_file),
                          headers: true)
          file.each do |row|
    Severity: Minor
    Found in lib/dwca_hunter/resources/mammal_divdb.rb - About 1 hr to fix

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

          def collect_names
            @names_index = {}
            file = CSV.open(File.join(@download_dir, find_csv_file),
                            headers: true)
            file.each do |row|
      Severity: Minor
      Found in lib/dwca_hunter/resources/mammal_divdb.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

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

          def vernaculars(row)
            id = row["id"]
            res = []
            vern = row["mainCommonName"].to_s
            res << vern  if vern != ""
      Severity: Major
      Found in lib/dwca_hunter/resources/mammal_divdb.rb and 2 other locations - About 1 hr to fix
      lib/dwca_hunter/resources/algaebase.rb on lines 60..71
      lib/dwca_hunter/resources/wcvp.rb on lines 60..71

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 49.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 5 locations. Consider refactoring.
      Open

          def assemble_synonym(row)
            name = row["originalNameCombination"].gsub("_", " ")
            auth = "#{row['authoritySpeciesAuthor']} #{row['aurhoritySpeciesYear']}".
              strip
            name = "#{name} #{auth}".strip
      Severity: Major
      Found in lib/dwca_hunter/resources/mammal_divdb.rb and 4 other locations - About 40 mins to fix
      lib/dwca_hunter/resources/algaebase.rb on lines 52..57
      lib/dwca_hunter/resources/disc_life_bees.rb on lines 51..56
      lib/dwca_hunter/resources/tropicos.rb on lines 45..50
      lib/dwca_hunter/resources/wcvp.rb on lines 52..57

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 38.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

            @names.each do |n|
              @core << [n[:taxon_id], n[:name_string],
                        n[:kingdom], n[:phylum], n[:klass], n[:order], n[:family],
                        n[:genus], n[:rank], n[:code]]
      Severity: Minor
      Found in lib/dwca_hunter/resources/mammal_divdb.rb and 2 other locations - About 40 mins to fix
      lib/dwca_hunter/resources/ictv.rb on lines 113..116
      lib/dwca_hunter/resources/wcvp.rb on lines 146..149

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 37.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 8 locations. Consider refactoring.
      Open

          def initialize(opts = {})
            @command = "mammal-div-db"
            @title = "ASM Mammal Diversity Database"
            @url = "https://www.mammaldiversity.org/assets/data/MDD.zip"
            @UUID = "94270cdd-5424-4bb1-8324-46ccc5386dc7"
      Severity: Major
      Found in lib/dwca_hunter/resources/mammal_divdb.rb and 7 other locations - About 35 mins to fix
      lib/dwca_hunter/resources/aos-birds.rb on lines 5..20
      lib/dwca_hunter/resources/arctos.rb on lines 5..22
      lib/dwca_hunter/resources/clements.rb on lines 5..20
      lib/dwca_hunter/resources/how-moore-birds.rb on lines 5..20
      lib/dwca_hunter/resources/ioc_word_bird.rb on lines 5..20
      lib/dwca_hunter/resources/mcz.rb on lines 5..20
      lib/dwca_hunter/resources/sherborn.rb on lines 5..20

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 34.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status