SpeciesFileGroup/taxonworks

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

Summary

Maintainability
F
1 wk
Test Coverage

Method build_dwca has a Cognitive Complexity of 113 (exceeds 5 allowed). Consider refactoring.
Open

    def build_dwca
      line_counter = 1 # accounting for headers

      tasks = triage(csv.headers, tasks_)
      csv.each do |row|
Severity: Minor
Found in lib/batch_load/import/dwca.rb - About 2 days 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 dwca.rb has 634 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module BatchLoad
  # TODO: Originally transliterated from Import::CollectingEvents: Remove this to-do after successful operation.
  class Import::DWCA < BatchLoad::Import

    attr_accessor :collecting_events
Severity: Major
Found in lib/batch_load/import/dwca.rb - About 1 day to fix

    Method build_dwca has 184 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def build_dwca
          line_counter = 1 # accounting for headers
    
          tasks = triage(csv.headers, tasks_)
          csv.each do |row|
    Severity: Major
    Found in lib/batch_load/import/dwca.rb - About 7 hrs to fix

      Method make_ce has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
      Open

          def make_ce(row)
            ret_val     = {}
            kees        = [:yyyy_mm_dd, :mm_dd_yy]
            d_s         = row['eventdate']
            v_l         = [row['municipality'], row['locality']].select {|name| name.present?}.join(':')
      Severity: Minor
      Found in lib/batch_load/import/dwca.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

      Method make_tn has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def make_tn(row)
            ret_val      = {species: nil, genus: nil, tribe: nil}
            this_kingdom = row['kingdom']
            if @kingdom.try(:name) != this_kingdom
              @kingdom = Protonym.find_or_create_by(name:       this_kingdom,
      Severity: Major
      Found in lib/batch_load/import/dwca.rb - About 2 hrs to fix

        Class DWCA has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Import::DWCA < BatchLoad::Import
        
            attr_accessor :collecting_events
        
            attr_accessor :dwca_namespace
        Severity: Minor
        Found in lib/batch_load/import/dwca.rb - About 2 hrs to fix

          Method make_tn has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def make_tn(row)
                ret_val      = {species: nil, genus: nil, tribe: nil}
                this_kingdom = row['kingdom']
                if @kingdom.try(:name) != this_kingdom
                  @kingdom = Protonym.find_or_create_by(name:       this_kingdom,
          Severity: Minor
          Found in lib/batch_load/import/dwca.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 make_ce has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def make_ce(row)
                ret_val     = {}
                kees        = [:yyyy_mm_dd, :mm_dd_yy]
                d_s         = row['eventdate']
                v_l         = [row['municipality'], row['locality']].select {|name| name.present?}.join(':')
          Severity: Major
          Found in lib/batch_load/import/dwca.rb - About 2 hrs to fix

            Method make_co has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def make_co(row)
                  ret_val = {}
                  warn    = []
                  err     = []
                  ic      = row['individualcount']
            Severity: Minor
            Found in lib/batch_load/import/dwca.rb - About 1 hr to fix

              Method make_notes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def make_notes(row)
                    ret_val = {}
                    begin
                      notes      = {}
                      geo_remark = row['georeferenceremarks']
              Severity: Minor
              Found in lib/batch_load/import/dwca.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 make_notes has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def make_notes(row)
                    ret_val = {}
                    begin
                      notes      = {}
                      geo_remark = row['georeferenceremarks']
              Severity: Minor
              Found in lib/batch_load/import/dwca.rb - About 1 hr to fix

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

                    def make_gr(row)
                      geo_by = row['georeferencedby']
                      # lat, long           = (lat.length > 0) ? lat : nil, (long.length > 0) ? long : nil
                      lat, long = row['decimallatitude'], row['decimallongitude']
                      if lat.nil? and long.nil?
                Severity: Minor
                Found in lib/batch_load/import/dwca.rb - About 1 hr to fix

                  Method make_ident has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def make_ident(row)
                        ident  = {}
                        cat_no = row['catalognumber'].split(' ')
                        unless cat_no.blank?
                          if @namespace.short_name != cat_no[0]
                  Severity: Minor
                  Found in lib/batch_load/import/dwca.rb - About 55 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 make_gr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def make_gr(row)
                        geo_by = row['georeferencedby']
                        # lat, long           = (lat.length > 0) ? lat : nil, (long.length > 0) ? long : nil
                        lat, long = row['decimallatitude'], row['decimallongitude']
                        if lat.nil? and long.nil?
                  Severity: Minor
                  Found in lib/batch_load/import/dwca.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 make_co has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def make_co(row)
                        ret_val = {}
                        warn    = []
                        err     = []
                        ic      = row['individualcount']
                  Severity: Minor
                  Found in lib/batch_load/import/dwca.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

                  Consider simplifying this complex logical expression.
                  Open

                            if test_list.include?(:start_date_day) or
                              test_list.include?(:start_date_month) or
                              test_list.include?(:start_date_year) or
                              test_list.include?(:end_date_day) or
                              test_list.include?(:end_date_month) or
                  Severity: Major
                  Found in lib/batch_load/import/dwca.rb - About 40 mins to fix

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

                        def make_ba(row)
                          # for each associatedTaxa, find or create an otu, and creata a biological association for it,
                          # connecting it to a collection_object
                          retval = {}
                          bas    = row['associatedtaxa']
                    Severity: Minor
                    Found in lib/batch_load/import/dwca.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 save_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def save_hash(objects)
                          l_errs = []
                          objects.each_key {|kee|
                            object = objects[kee]
                            unless object.blank?
                    Severity: Minor
                    Found in lib/batch_load/import/dwca.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

                    TODO found
                    Open

                      # TODO: Originally transliterated from Import::CollectingEvents: Remove this to-do after successful operation.
                    Severity: Minor
                    Found in lib/batch_load/import/dwca.rb by fixme

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

                              unless c_e_notes.blank?
                                apply_note = false
                                c_e_notes.each_key {|kee|
                                  c_e_n = c_e_notes[kee]
                                  if c_e.notes.present?
                    Severity: Minor
                    Found in lib/batch_load/import/dwca.rb and 1 other location - About 55 mins to fix
                    lib/batch_load/import/dwca.rb on lines 249..265

                    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 46.

                    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 2 locations. Consider refactoring.
                    Open

                            unless g_r_notes.blank?
                              apply_note = false
                              g_r_notes.each_key {|kee|
                                g_r_n = g_r_notes[kee]
                                if g_r.notes.present?
                    Severity: Minor
                    Found in lib/batch_load/import/dwca.rb and 1 other location - About 55 mins to fix
                    lib/batch_load/import/dwca.rb on lines 152..168

                    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 46.

                    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 2 locations. Consider refactoring.
                    Open

                          if @kingdom.try(:name) != this_kingdom
                            @kingdom = Protonym.find_or_create_by(name:       this_kingdom,
                                                                  rank_class: Ranks.lookup(:iczn, :kingdom),
                                                                  project_id: @project_id)
                    
                    
                    Severity: Minor
                    Found in lib/batch_load/import/dwca.rb and 1 other location - About 30 mins to fix
                    lib/batch_load/import/dwca.rb on lines 694..701

                    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 33.

                    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 2 locations. Consider refactoring.
                    Open

                          if @family.try(:name) != this_family
                            @family = Protonym.find_or_create_by(name:       this_family,
                                                                 rank_class: Ranks.lookup(:iczn, :family),
                                                                 project_id: @project_id)
                            if @family.new_record?
                    Severity: Minor
                    Found in lib/batch_load/import/dwca.rb and 1 other location - About 30 mins to fix
                    lib/batch_load/import/dwca.rb on lines 681..689

                    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 33.

                    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 2 locations. Consider refactoring.
                    Open

                              when :genus
                                genus           = snp[:scientificName][:details][0][:uninomial]
                                t_n.parent      = @family
                                t_n.rank_class  = Ranks.lookup(:iczn, :genus)
                                t_n.name        = genus[:string]
                    Severity: Minor
                    Found in lib/batch_load/import/dwca.rb and 1 other location - About 25 mins to fix
                    lib/batch_load/import/dwca.rb on lines 745..750

                    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 31.

                    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 2 locations. Consider refactoring.
                    Open

                              when :tribe
                                tribe           = snp[:scientificName][:details][0][:uninomial]
                                t_n.parent      = @family
                                t_n.rank_class  = Ranks.lookup(:iczn, :tribe)
                                t_n.name        = tribe[:string]
                    Severity: Minor
                    Found in lib/batch_load/import/dwca.rb and 1 other location - About 25 mins to fix
                    lib/batch_load/import/dwca.rb on lines 739..744

                    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 31.

                    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 2 locations. Consider refactoring.
                    Open

                          begin # collection object notes
                            notes      = {}
                            occ_remark = row['occurrenceremarks']
                            unless occ_remark.blank?
                              notes[:remark] = Note.new(text:       occ_remark,
                    Severity: Minor
                    Found in lib/batch_load/import/dwca.rb and 1 other location - About 20 mins to fix
                    lib/batch_load/import/dwca.rb on lines 509..516

                    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 27.

                    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 2 locations. Consider refactoring.
                    Open

                          begin
                            notes      = {}
                            geo_remark = row['georeferenceremarks']
                            unless geo_remark.blank?
                              notes[:remark] = Note.new(text:       geo_remark,
                    Severity: Minor
                    Found in lib/batch_load/import/dwca.rb and 1 other location - About 20 mins to fix
                    lib/batch_load/import/dwca.rb on lines 530..537

                    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 27.

                    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