SpeciesFileGroup/taxonworks

View on GitHub

Showing 490 of 3,947 total issues

Method merge_with has a Cognitive Complexity of 148 (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 new (merged into self) 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

Class TaxonName has 126 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 942 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

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

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

        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

          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_homonyms has a Cognitive Complexity of 84 (exceeds 5 allowed). Consider refactoring.
            Open

                def sv_potential_homonyms
                  if self.parent && !self.cached_misspelling && !self.name_is_missapplied?
                    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

            Class CollectingEvent has 77 methods (exceeds 20 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

              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

                File collecting_event.rb has 628 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

                  File taxon_name_relationship.rb has 592 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require_dependency Rails.root.to_s + '/app/models/taxon_name_classification.rb'  
                  
                  # A NOMEN https://github.com/SpeciesFileGroup/nomen relationship between two Protonyms.
                  #
                  # Unless otherwise noted relationships read left to right, and can be interpreted by inserting "of" after the class name.
                  Severity: Major
                  Found in app/models/taxon_name_relationship.rb - About 1 day to fix

                    File protonym.rb has 557 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    require_dependency Rails.root.to_s + '/app/models/taxon_name_relationship.rb'  
                    #
                    # Force the loading of TaxonNameRelationships in all worlds.  This allows us to edit without restarting in development.
                    # Dir[Rails.root.to_s + '/app/models/taxon_name_relationship/**/*.rb'].sort.each {|file| require_dependency file }
                    #
                    Severity: Major
                    Found in app/models/protonym.rb - About 1 day to fix

                      Method sv_species_gender_agreement has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def sv_species_gender_agreement
                            if is_species_rank?
                              s = part_of_speech_name
                              unless part_of_speech_name.nil?
                                if %w{adjective participle}.include?(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 bibtex.rb has 512 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      require 'citeproc'
                      require 'csl/styles'
                      
                      # Bibtex - Subclass of Source that represents most references.
                      #   Cached values are formatted using the 'zootaxa' style from 'csl/styles'
                      Severity: Major
                      Found in app/models/source/bibtex.rb - About 1 day to fix

                        Class TaxonNameRelationship has 55 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        class TaxonNameRelationship < ApplicationRecord
                          include Housekeeping
                          include Shared::Citations
                          include Shared::Notes
                          include Shared::IsData
                        Severity: Major
                        Found in app/models/taxon_name_relationship.rb - About 7 hrs to fix

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

                          module Utilities::Dates
                          
                            LONG_MONTHS = %w{january february march april may june july august september october november december}.freeze
                            SHORT_MONTHS = %w{jan feb mar apr may jun jul aug sep oct nov dec}.freeze
                            ROMAN_MONTHS = %i{i ii iii iv v vi vii viii ix x xi xii}.freeze
                          Severity: Minor
                          Found in lib/utilities/dates.rb - About 7 hrs to fix

                            Function init has 194 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              init: function () {
                                var soft_validations = undefined;
                                function fillSoftValidation() {
                                  if (soft_validations == undefined) {
                                    if ($('[data-global-id]').length) {
                            Severity: Major
                            Found in app/assets/javascripts/views/tasks/nomenclature/browse.js - About 7 hrs to fix

                              File collection_object.rb has 480 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              class CollectionObject < ApplicationRecord
                              
                                include GlobalID::Identification
                                include Housekeeping
                                include Shared::Citations
                              Severity: Minor
                              Found in app/models/collection_object.rb - About 7 hrs 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
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language