SpeciesFileGroup/taxonworks

View on GitHub

Showing 649 of 6,140 total issues

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

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

    Class TaxonName has 124 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)
      #       when https://github.com/ClosureTree/closure_tree/issues/346 is fixed.
    Severity: Major
    Found in app/models/taxon_name.rb - About 2 days to fix

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

          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

            File dates.rb has 728 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 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

              File protonym.rb has 698 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

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

                  Class CollectingEvent has 79 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 632 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

                      Function init has 234 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 1 day to fix

                        Method date_regex_from_verbatim_label has 228 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def self.date_regex_from_verbatim_label(text)
                            return nil if text.blank?
                            text = ' ' + text.downcase + ' '
                        
                            date = {}
                        Severity: Major
                        Found in lib/utilities/dates.rb - About 1 day to fix

                          File data.rb has 542 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          concern :data_routes do |options|
                            collection do
                              get 'download'
                              get 'list'
                              post 'batch_create'
                          Severity: Major
                          Found in config/routes/data.rb - About 1 day to fix

                            File bibtex.rb has 521 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            require 'citeproc'
                            require 'csl/styles'
                            require 'namecase'
                            
                            # Bibtex - Subclass of Source that represents most references.
                            Severity: Major
                            Found in app/models/source/bibtex.rb - About 1 day to fix

                              Class Protonym has 57 methods (exceeds 20 allowed). Consider refactoring.
                              Open

                              class Protonym < TaxonName
                              
                                extend Protonym::SoftValidationExtensions::Klass
                                include Protonym::SoftValidationExtensions::Instance
                                include Protonym::Becomes
                              Severity: Major
                              Found in app/models/protonym.rb - About 1 day to fix

                                Class TaxonNameRelationship has 56 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 1 day to fix

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

                                      def sv_species_gender_agreement
                                        if is_species_rank?
                                          s = part_of_speech_name
                                          if !s.nil? && is_available?
                                            if %w{adjective participle}.include?(s)
                                  Severity: Minor
                                  Found in app/models/protonym/soft_validation_extensions.rb - About 7 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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language