SpeciesFileGroup/taxonworks

View on GitHub

Showing 4,586 of 4,586 total issues

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

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

Method has too many lines. [285/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 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 merge_with has a Cognitive Complexity of 153 (exceeds 5 allowed). Consider refactoring.
Open

  def merge_with(person_id)
    return false if person_id == id
    if r_person = Person.find(person_id) # get the person to merge to this person
      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. [195/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 135 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

    File taxon_name.rb has 1009 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_dependency Rails.root.to_s + '/app/models/taxon_name_classification.rb'
    require_dependency Rails.root.to_s + '/app/models/taxon_name_relationship.rb'
    
    # A taxonomic name (nomenclature only). See also NOMEN.
    #
    Severity: Major
    Found in app/models/taxon_name.rb - About 2 days to fix

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

      const vueAnnotator = {
        props: {
          type: {
            type: String,
            required: true
      app/javascript/vue/components/otu/otu_radial/components/annotatorExtend.js on lines 1..62

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

      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

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

      const vueAnnotator = {
        props: {
          type: {
            type: String,
            required: true
      app/javascript/vue/components/annotator/components/annotatorExtend.js on lines 1..62

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

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

              def invalid_relationship_remove_sf(project_id)
      
                fixed = 0
                combinations = 0
                i = 0

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

      module Protonym::SoftValidationExtensions
      
        module Klass
      
          VALIDATIONS = {
      Severity: Major
      Found in app/models/protonym/soft_validation_extensions.rb - About 2 days to fix

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

              def handle_taxonomy_3i
        
                handle_nouns_3i
        
                # Key !
        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. [148/25]
        Open

          def merge_with(person_id)
            return false if person_id == id
            if r_person = Person.find(person_id) # get the person to merge to this person
              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.

        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.

        File geographic_item.rb has 766 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 90 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_species_homonyms has a Cognitive Complexity of 84 (exceeds 5 allowed). Consider refactoring.
            Open

                def sv_potential_species_homonyms
                  if persisted? && is_species_rank? && is_available?
                    if TaxonNameRelationship.where_subject_is_taxon_name(self).homonym_or_suppressed.empty?
                      if self.id == self.lowest_rank_coordinated_taxon.id
                        name1 = self.cached_primary_homonym ? self.cached_primary_homonym : nil
            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

            Severity
            Category
            Status
            Source
            Language