SpeciesFileGroup/taxonworks

View on GitHub
app/models/taxon_name.rb

Summary

Maintainability
F
1 wk
Test Coverage

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

        def iczn_author_and_year
          ay = nil
          p = nil
      
          misapplication = TaxonNameRelationship.where_subject_is_taxon_name(self).with_type_string('TaxonNameRelationship::Iczn::Invalidating::Misapplication')
      Severity: Minor
      Found in app/models/taxon_name.rb - About 5 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

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

        def iczn_author_and_year
          ay = nil
          p = nil
      
          misapplication = TaxonNameRelationship.where_subject_is_taxon_name(self).with_type_string('TaxonNameRelationship::Iczn::Invalidating::Misapplication')
      Severity: Minor
      Found in app/models/taxon_name.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 sv_validate_name has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

        def sv_validate_name
          correct_name_format = false
      
          if rank_class
            # TODO: name these Regexp somewhere
      Severity: Minor
      Found in app/models/taxon_name.rb - About 3 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

      Method sv_missing_fields has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

        def sv_missing_fields
          if !self.cached_misspelling && !self.name_is_missapplied?
            if self.source.nil?
              soft_validations.add(:base, 'Original publication is not selected')
            elsif self.origin_citation.pages.nil?
      Severity: Minor
      Found in app/models/taxon_name.rb - About 3 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

      Method nomenclature_date has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

        def nomenclature_date
          return nil if self.id.nil?
           family_before_1961 = TaxonNameRelationship.where_subject_is_taxon_name(self).with_type_string('TaxonNameRelationship::Iczn::PotentiallyValidating::FamilyBefore1961').first
      
          # family_before_1961 = taxon_name_relationships.with_type_string('TaxonNameRelationship::Iczn::PotentiallyValidating::FamilyBefore1961').first
      Severity: Minor
      Found in app/models/taxon_name.rb - About 3 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

      Consider simplifying this complex logical expression.
      Open

            if (name =~ /^[a-zA-Z]*$/) || # !! should reference NOT_LATIN
                (nomenclatural_code == :iczn && name =~ /^[a-zA-Z]-[a-zA-Z]*$/) ||
                (nomenclatural_code == :icnp && name =~ /^[a-zA-Z]-[a-zA-Z]*$/) ||
                (nomenclatural_code == :icn && name =~  /^[a-zA-Z]*-[a-zA-Z]*$/) ||
                (nomenclatural_code == :icn && name =~  /^[a-zA-Z]*\s×\s[a-zA-Z]*$/) ||
      Severity: Critical
      Found in app/models/taxon_name.rb - About 2 hrs to fix

        Method list_of_invalid_taxon_names has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          def list_of_invalid_taxon_names
            first_pass = true
            list = {}
            while first_pass || !list.keys.select{|t| list[t] == false}.empty? do
              first_pass = false
        Severity: Minor
        Found in app/models/taxon_name.rb - About 2 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

        Method icn_author_and_year has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

          def icn_author_and_year
            ay = nil
        
            basionym = TaxonNameRelationship.where_object_is_taxon_name(self).
              with_type_string('TaxonNameRelationship::Icn::Unaccepting::Usage::Basionym')
        Severity: Minor
        Found in app/models/taxon_name.rb - About 2 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

        Method iczn_author_and_year has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def iczn_author_and_year
            ay = nil
            p = nil
        
            misapplication = TaxonNameRelationship.where_subject_is_taxon_name(self).with_type_string('TaxonNameRelationship::Iczn::Invalidating::Misapplication')
        Severity: Minor
        Found in app/models/taxon_name.rb - About 1 hr to fix

          Method full_name_hash has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def full_name_hash
              gender = nil
              data   = {}
              safe_self_and_ancestors.each do |i| # !! You can not use self.self_and_ancestors because (this) record is not saved off.
                rank   = i.rank
          Severity: Minor
          Found in app/models/taxon_name.rb - About 1 hr 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 sv_fix_parent_is_valid_name has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def sv_fix_parent_is_valid_name
              if self.parent.unavailable_or_invalid?
                new_parent = self.parent.get_valid_taxon_name
                if self.parent != new_parent
                  self.parent = new_parent
          Severity: Minor
          Found in app/models/taxon_name.rb - About 1 hr 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 get_full_name has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_full_name
              return verbatim_name if type != 'Combination' && !GENUS_AND_SPECIES_RANK_NAMES.include?(rank_string) && !verbatim_name.nil?
              return name if type != 'Combination' && !GENUS_AND_SPECIES_RANK_NAMES.include?(rank_string)
              return name if rank_class =~ /Ictv/
              return verbatim_name if !verbatim_name.nil? && type == 'Combination'
          Severity: Minor
          Found in app/models/taxon_name.rb - About 55 mins 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 check_new_parent_class has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def check_new_parent_class
              if is_protonym? && parent_id != parent_id_was && !parent_id_was.nil? && nomenclatural_code == :iczn
                if old_parent = TaxonName.find_by(id: parent_id_was)
                  if (rank_name == 'subgenus' || rank_name == 'subspecies') && old_parent.name == name
                    errors.add(:parent_id, "The nominotypical #{rank_name} #{name} can not be moved out of the nominal #{old_parent.rank_name}")
          Severity: Minor
          Found in app/models/taxon_name.rb - About 55 mins 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 create_new_combination_if_absent has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def create_new_combination_if_absent
              return true unless type == 'Protonym'
              if !TaxonName.with_cached_html(cached_html).count == 0
                begin
                  TaxonName.transaction do
          Severity: Minor
          Found in app/models/taxon_name.rb - About 55 mins 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

          Consider simplifying this complex logical expression.
          Open

              if data['species'].nil? && (!data['subspecies'].nil? || !data['variety'].nil? || !data['subvariety'].nil? || !data['form'].nil? || !data['subform'].nil?)
                data['species'] = [nil, '[SPECIES NOT SPECIFIED]']
              end
          Severity: Major
          Found in app/models/taxon_name.rb - About 40 mins to fix

            Method sv_parent_is_valid_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def sv_parent_is_valid_name
                return if parent.nil?
                if parent.unavailable_or_invalid?
                  # parent of a taxon is unavailable or invalid
                  soft_validations.add(:parent_id, 'Parent should be a valid taxon',
            Severity: Minor
            Found in app/models/taxon_name.rb - About 35 mins 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 sv_fix_missing_author has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def sv_fix_missing_author
                if self.source
                  unless self.source.author.blank?
                    self.verbatim_author = self.source.authority_name
                    begin
            Severity: Minor
            Found in app/models/taxon_name.rb - About 35 mins 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 sv_incomplete_combination has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def sv_incomplete_combination
                soft_validations.add(:base, 'The genus in the combination is not specified') if !cached.nil? && cached.include?('GENUS NOT SPECIFIED')
                soft_validations.add(:base, 'The species in the combination is not specified') if !cached.nil? && cached.include?('SPECIES NOT SPECIFIED')
                soft_validations.add(:base, 'The variety in the combination is not specified') if !cached.nil? && cached.include?('VARIETY NOT SPECIFIED')
                soft_validations.add(:base, 'The form in the combination is not specified') if !cached.nil? && cached.include?('FORM NOT SPECIFIED')
            Severity: Minor
            Found in app/models/taxon_name.rb - About 35 mins 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 check_new_rank_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def check_new_rank_class
                # rank_class_was is a AR macro
            
                if (rank_class != rank_class_was) && !rank_class_was.nil?
            
            
            Severity: Minor
            Found in app/models/taxon_name.rb - About 25 mins 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 get_full_name_html has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def get_full_name_html(name = nil)
                name = get_full_name if name.nil? 
                return name unless is_italicized?
                n = name 
                # n = verbatim_name.blank? ? name : verbatim_name
            Severity: Minor
            Found in app/models/taxon_name.rb - About 25 mins 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 sv_fix_missing_year has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def sv_fix_missing_year
                if self.source
                  if self.source.year
                    self.year_of_publication = self.source.year
                    begin
            Severity: Minor
            Found in app/models/taxon_name.rb - About 25 mins 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 validate_parent_rank_is_higher has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def validate_parent_rank_is_higher
                if parent && !rank_class.blank? && rank_string != 'NomenclaturalRank'
                  if RANKS.index(rank_string) <= RANKS.index(parent.rank_string)
                    errors.add(:parent_id, "The parent rank (#{parent.rank_class.rank_name}) is not higher than the rank (#{rank_name}) of this taxon")
                  end
            Severity: Minor
            Found in app/models/taxon_name.rb - About 25 mins 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

            Avoid more than 4 levels of block nesting.
            Open

                      ay = '(' + ay + ')' unless ay.empty? if og.name != cg.name
            Severity: Minor
            Found in app/models/taxon_name.rb by rubocop

            This cop checks for excessive nesting of conditional and looping constructs.

            You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

            The maximum level of nesting allowed is configurable.

            Use save! instead of save if the return value is not checked.
            Open

                        self.save
            Severity: Minor
            Found in app/models/taxon_name.rb by rubocop

            This cop identifies possible cases where Active Record save! or related should be used instead of save because the model might have failed to save and an exception is better than unhandled failure.

            This will ignore calls that return a boolean for success if the result is assigned to a variable or used as the condition in an if/unless statement. It will also ignore calls that return a model assigned to a variable that has a call to persisted?. Finally, it will ignore any call with more than 2 arguments as that is likely not an Active Record call or a Model.update(id, attributes) call.

            Example:

            # bad
            user.save
            user.update(name: 'Joe')
            user.find_or_create_by(name: 'Joe')
            user.destroy
            
            # good
            unless user.save
              # ...
            end
            user.save!
            user.update!(name: 'Joe')
            user.find_or_create_by!(name: 'Joe')
            user.destroy!
            
            user = User.find_or_create_by(name: 'Joe')
            unless user.persisted?
              # ...
            end

            Use save! instead of save if the return value is not checked.
            Open

                    self.save
            Severity: Minor
            Found in app/models/taxon_name.rb by rubocop

            This cop identifies possible cases where Active Record save! or related should be used instead of save because the model might have failed to save and an exception is better than unhandled failure.

            This will ignore calls that return a boolean for success if the result is assigned to a variable or used as the condition in an if/unless statement. It will also ignore calls that return a model assigned to a variable that has a call to persisted?. Finally, it will ignore any call with more than 2 arguments as that is likely not an Active Record call or a Model.update(id, attributes) call.

            Example:

            # bad
            user.save
            user.update(name: 'Joe')
            user.find_or_create_by(name: 'Joe')
            user.destroy
            
            # good
            unless user.save
              # ...
            end
            user.save!
            user.update!(name: 'Joe')
            user.find_or_create_by!(name: 'Joe')
            user.destroy!
            
            user = User.find_or_create_by(name: 'Joe')
            unless user.persisted?
              # ...
            end

            Use save! instead of save if the return value is not checked.
            Open

                        self.save
            Severity: Minor
            Found in app/models/taxon_name.rb by rubocop

            This cop identifies possible cases where Active Record save! or related should be used instead of save because the model might have failed to save and an exception is better than unhandled failure.

            This will ignore calls that return a boolean for success if the result is assigned to a variable or used as the condition in an if/unless statement. It will also ignore calls that return a model assigned to a variable that has a call to persisted?. Finally, it will ignore any call with more than 2 arguments as that is likely not an Active Record call or a Model.update(id, attributes) call.

            Example:

            # bad
            user.save
            user.update(name: 'Joe')
            user.find_or_create_by(name: 'Joe')
            user.destroy
            
            # good
            unless user.save
              # ...
            end
            user.save!
            user.update!(name: 'Joe')
            user.find_or_create_by!(name: 'Joe')
            user.destroy!
            
            user = User.find_or_create_by(name: 'Joe')
            unless user.persisted?
              # ...
            end

            Use save! instead of save if the return value is not checked.
            Open

                        self.save
            Severity: Minor
            Found in app/models/taxon_name.rb by rubocop

            This cop identifies possible cases where Active Record save! or related should be used instead of save because the model might have failed to save and an exception is better than unhandled failure.

            This will ignore calls that return a boolean for success if the result is assigned to a variable or used as the condition in an if/unless statement. It will also ignore calls that return a model assigned to a variable that has a call to persisted?. Finally, it will ignore any call with more than 2 arguments as that is likely not an Active Record call or a Model.update(id, attributes) call.

            Example:

            # bad
            user.save
            user.update(name: 'Joe')
            user.find_or_create_by(name: 'Joe')
            user.destroy
            
            # good
            unless user.save
              # ...
            end
            user.save!
            user.update!(name: 'Joe')
            user.find_or_create_by!(name: 'Joe')
            user.destroy!
            
            user = User.find_or_create_by(name: 'Joe')
            unless user.persisted?
              # ...
            end

            TODO found
            Open

              # TODO: move to Protonym when we eliminate TaxonName.new()
            Severity: Minor
            Found in app/models/taxon_name.rb by fixme

            TODO found
            Open

                  # TODO: name these Regexp somewhere
            Severity: Minor
            Found in app/models/taxon_name.rb by fixme

            TODO found
            Open

              # TODO: move some of these down to Protonym when they don't apply to Combination
            Severity: Minor
            Found in app/models/taxon_name.rb by fixme

            TODO found
            Open

              # TODO: Can't we just use #valid_id now?
            Severity: Minor
            Found in app/models/taxon_name.rb by fixme

            TODO found
            Open

              # TODO: does this make sense now, with #valid_taxon_name_id in place?
            Severity: Minor
            Found in app/models/taxon_name.rb by fixme

            TODO found
            Open

              # TODO: think of a different name, and test
            Severity: Minor
            Found in app/models/taxon_name.rb by fixme

            TODO found
            Open

              # TODO: deprecate all of these for where()
            Severity: Minor
            Found in app/models/taxon_name.rb by fixme

            TODO found
            Open

              #    TODO: provide a default to gender (but do NOT eliminate param)
            Severity: Minor
            Found in app/models/taxon_name.rb by fixme

            TODO found
            Open

              # TODO: Protonym check only?  Why can't we reference #cached_valid_taxon_name_id?
            Severity: Minor
            Found in app/models/taxon_name.rb by fixme

            TODO found
            Open

              # TODO: Move to taxon name classification.rb
            Severity: Minor
            Found in app/models/taxon_name.rb by fixme

            TODO found
            Open

              #    TODO: does this form of the name contain parens for subgenus?
            Severity: Minor
            Found in app/models/taxon_name.rb by fixme

            TODO found
            Open

              #    TODO: on third thought- eliminate this mess
            Severity: Minor
            Found in app/models/taxon_name.rb by fixme

            TODO found
            Open

                else # TODO: This seems like a different validation, split with above?
            Severity: Minor
            Found in app/models/taxon_name.rb by fixme

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

              def check_new_parent_class
                if is_protonym? && parent_id != parent_id_was && !parent_id_was.nil? && nomenclatural_code == :iczn
                  if old_parent = TaxonName.find_by(id: parent_id_was)
                    if (rank_name == 'subgenus' || rank_name == 'subspecies') && old_parent.name == name
                      errors.add(:parent_id, "The nominotypical #{rank_name} #{name} can not be moved out of the nominal #{old_parent.rank_name}")
            Severity: Major
            Found in app/models/taxon_name.rb and 1 other location - About 1 hr to fix
            app/models/protonym.rb on lines 657..664

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

            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

                if data['species'].nil? && (!data['subspecies'].nil? || !data['variety'].nil? || !data['subvariety'].nil? || !data['form'].nil? || !data['subform'].nil?)
                  data['species'] = [nil, '[SPECIES NOT SPECIFIED]']
                end
            Severity: Minor
            Found in app/models/taxon_name.rb and 1 other location - About 45 mins to fix
            app/models/combination.rb on lines 246..248

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

            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

              scope :ancestors_and_descendants_of, -> (taxon_name) do
                a = TaxonName.self_and_ancestors_of(taxon_name)
                b = TaxonName.descendants_of(taxon_name)
                TaxonName.from("((#{a.to_sql}) UNION (#{b.to_sql})) as taxon_names")
              end
            Severity: Minor
            Found in app/models/taxon_name.rb and 1 other location - About 15 mins to fix
            app/models/geographic_area.rb on lines 96..100

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

            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

            Prefer single-quoted strings when you don't need string interpolation or special symbols.
            Open

                  errors.add(:project_id, "The parent taxon is not from the same project") if project_id != parent.project_id
            Severity: Minor
            Found in app/models/taxon_name.rb by rubocop

            Checks if uses of quotes match the configured preference.

            Example: EnforcedStyle: single_quotes (default)

            # bad
            "No special symbols"
            "No string interpolation"
            "Just text"
            
            # good
            'No special symbols'
            'No string interpolation'
            'Just text'
            "Wait! What's #{this}!"

            Example: EnforcedStyle: double_quotes

            # bad
            'Just some text'
            'No special chars or interpolation'
            
            # good
            "Just some text"
            "No special chars or interpolation"
            "Every string in #{project} uses double_quotes"

            There are no issues that match your filters.

            Category
            Status