SpeciesFileGroup/taxonworks

View on GitHub

Showing 3,856 of 3,856 total issues

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

Object.assign(TW.views.filter.area_picker, {

  initialize_area_picker: function (form, area_type) {
    this.initialize_autocomplete(form);
    this.bind_remove_links(form.find('.remove_area'));
Severity: Major
Found in app/assets/javascripts/views/filter/_area_picker.js and 1 other location - About 6 days to fix
app/assets/javascripts/views/filter/author_picker.js on lines 6..112

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

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

Object.assign(TW.views.filter.author_picker, {

  initialize_author_picker: function (form, author_type) {
    this.initialize_autocomplete(form);
    this.bind_remove_links(form.find('.remove_author'));
Severity: Major
Found in app/assets/javascripts/views/filter/author_picker.js and 1 other location - About 6 days to fix
app/assets/javascripts/views/filter/_area_picker.js on lines 6..112

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

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

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

      def handle_species_lepindex
        # VIADOCS.txt
        #
        # TaxonNo
        # SCIENTIFIC_NAME_on_card

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. [229/25]
Open

      def handle_tstat_ucd

        relationship = {
          'AC' => 'TaxonNameRelationship::Iczn::Invalidating::Usage::IncorrectOriginalSpelling', # 'Alternative original combination of',
          'AS' => 'TaxonNameRelationship::Iczn::Invalidating::Usage::IncorrectOriginalSpelling', # 'Alternative original spelling of',
Severity: Minor
Found in lib/tasks/import/ucd/ucd.rake 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 merge_with has a Cognitive Complexity of 156 (exceeds 5 allowed). Consider refactoring.
Open

  def merge_with(person_id)
    if r_person = Person.find(person_id) # get the new (merged into self) person
      # r_err         = nil
      begin
        ApplicationRecord.transaction do
Severity: Minor
Found in app/models/person.rb - About 3 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

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

      def handle_taxon_name_relationships_3i
        path = @args[:data_directory] + 'taxon.txt'
        print "\nHandling taxon name relationships\n"
        raise "file #{path} not found" if not File.exists?(path)
        file = CSV.foreach(path, col_sep: "\t", headers: true)
Severity: Minor
Found in lib/tasks/import/3i/3i.rake 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.

Class TaxonName has 123 methods (exceeds 20 allowed). Consider refactoring.
Open

class TaxonName < ApplicationRecord

  has_closure_tree

  include Housekeeping
Severity: Major
Found in app/models/taxon_name.rb - About 2 days to fix

    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 taxon_name.rb has 927 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class TaxonName < ApplicationRecord
    
      has_closure_tree
    
      include Housekeeping
    Severity: Major
    Found in app/models/taxon_name.rb - About 2 days to fix

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

            def handle_taxonomy_3i
      
              handle_nouns_3i
      
      
      
      Severity: Minor
      Found in lib/tasks/import/3i/3i.rake 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. [150/25]
      Open

        def merge_with(person_id)
          if r_person = Person.find(person_id) # get the new (merged into self) person
            # r_err         = nil
            begin
              ApplicationRecord.transaction do
      Severity: Minor
      Found in app/models/person.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.

      File routes.rb has 834 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      TaxonWorks::Application.routes.draw do
      
        get :ping, controller: 'ping',  defaults: { format: :json }
        get :pingz, controller: 'ping',  defaults: { format: :json }
      
      
      Severity: Major
      Found in config/routes.rb - About 2 days to fix

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

              def handle_controlled_vocabulary_3i
                print "\nHandling CV \n"
        
                @accession_namespace = Namespace.create(institution: '3i Auchenorrhyncha', name: 'Accession Code', short_name: 'Accession Code')
        
        
        Severity: Minor
        Found in lib/tasks/import/3i/3i.rake 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. [136/25]
        Open

              def invalid_relationship_remove
        
                fixed = 0
                combinations = 0
                i = 0
        Severity: Minor
        Found in lib/tasks/import/ucd/ucd.rake 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.

        File geographic_item.rb has 749 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'rgeo'
        
        # A GeographicItem is one and only one of [point, line_string, polygon, multi_point, multi_line_string,
        # multi_polygon, geometry_collection] which describes a position, path, or area on the globe, generally associated
        # with a geographic_area (through a geographic_area_geographic_item entry), and sometimes only with a georeference.
        Severity: Major
        Found in app/models/geographic_item.rb - About 1 day to fix

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

                def find_or_create_collecting_event_insects(ce, data)
                  tmp_ce = { }
                  LOCALITY_COLUMNS.each do |c|
                    tmp_ce[c] = ce[c] unless ce[c].blank?
                  end

          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.

          Class GeographicItem has 89 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class GeographicItem < ApplicationRecord
            include Housekeeping::Users
            include Housekeeping::Timestamps
            include Shared::IsData
            include Shared::SharedAcrossProjects
          Severity: Major
          Found in app/models/geographic_item.rb - About 1 day to fix

            Method sv_potential_homonyms has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring.
            Open

                def sv_potential_homonyms
                  if self.parent
                    unless classification_invalid_or_unavailable? || !Protonym.with_taxon_name_relationships_as_subject.with_homonym_or_suppressed.empty? #  self.unavailable_or_invalid?
                      if self.id == self.lowest_rank_coordinated_taxon.id
                        rank_base = self.rank_class.parent.to_s
            Severity: Minor
            Found in app/models/protonym/soft_validation_extensions.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

            File collecting_event.rb has 679 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class CollectingEvent < ApplicationRecord
              include Housekeeping
              include Shared::Citations
              include Shared::DataAttributes
              include Shared::HasRoles
            Severity: Major
            Found in app/models/collecting_event.rb - About 1 day to fix

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

                      def read_shape(filename, index)
                        # TODO: For some reason, Gis::FACTORY does not seem to be the default factory, so we are being specific here, to get the lenient polygon tests.  This gets us past the problem polygons, but does not actually deal with the problem.
                        # See http://dazuma.github.io/rgeo-shapefile/rdoc/RGeo/Shapefile/Reader.html for reader options.
              
                        # ne10 = RGeo::Shapefile::Reader.open('G:\Share\Downloads\PostgreSQL\PostGIS\10m_cultural\10m_cultural\ne_10m_admin_0_countries.shp', factory: Gis::FACTORY)

              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.

              Severity
              Category
              Status
              Source
              Language