SpeciesFileGroup/taxonworks

View on GitHub

Showing 12,165 of 12,165 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

File csl_styles.rb has 2014 lines of code (exceeds 250 allowed). Consider refactoring.
Open

CSL_STYLES = {
"http://www.zotero.org/styles/vancouver-brackets-only-year-no-issue" => "Vancouver (brackets, only year in date, no issue numbers)",
"http://www.zotero.org/styles/orthopedic-clinics-of-north-america" => "Orthopedic Clinics of North America",
"http://www.zotero.org/styles/asa-cssa-sssa" => "American Society of Agronomy, Crop Science Society of America, Soil Science Society of America",
"http://www.zotero.org/styles/acta-orthopaedica-belgica" => "Acta Orthopædica Belgica",
Severity: Major
Found in config/initializers/constants/_controlled_vocabularies/csl_styles.rb - About 5 days to fix

    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.

    File taxon_name.rb has 997 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

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

      class TaxonName < ApplicationRecord
        
        # @return class
        #   this method calls Module#module_parent
        # TODO: This method can be placed elsewhere inside this class (or even removed if not used)
      Severity: Major
      Found in app/models/taxon_name.rb - About 2 days to fix

        File soft_validation_extensions.rb has 981 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. [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

          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 768 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

            File dates.rb has 753 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Utilities::Dates
            
              EARLIEST_DATE = '1700/01/10'.freeze # Reconcile with in-app
            
              LONG_MONTHS = %w{january february march april may june july august september october november december}.freeze
            Severity: Major
            Found in lib/utilities/dates.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

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

                const ActionFunctions = {
                  [ActionNames.AddToContainer]: addToContainer,
                  [ActionNames.LoadDigitalization]: loadDigitalization,
                  [ActionNames.LoadContainer]: loadContainer,
                  [ActionNames.GetTaxon]: getTaxon,
                Severity: Major
                Found in app/javascript/vue/tasks/digitize/store/actions/actions.js and 2 other locations - About 1 day to fix
                app/javascript/vue/tasks/matrix_row_coder/store/mutations/mutations.js on lines 71..105
                app/javascript/vue/tasks/nomenclature/new_taxon_name/store/getters/getters.js on lines 71..105

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

                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

                const GetterFunctions = {
                  [GetterNames.ActiveModalStatus]: activeModalStatus,
                  [GetterNames.ActiveModalType]: activeModalType,
                  [GetterNames.ActiveModalRelationship]: activeModalRelationship,
                  [GetterNames.GetAllRanks]: getAllRanks,
                app/javascript/vue/tasks/digitize/store/actions/actions.js on lines 37..71
                app/javascript/vue/tasks/matrix_row_coder/store/mutations/mutations.js on lines 71..105

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

                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

                Severity
                Category
                Status
                Source
                Language