SpeciesFileGroup/taxonworks

View on GitHub
app/models/protonym/soft_validation_extensions.rb

Summary

Maintainability
F
1 wk
Test Coverage

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

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

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

    def sv_fix_coordinated_names
      fixed = false
      gender = self.gender_class
      speech = self.part_of_speech_class

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

module Protonym::SoftValidationExtensions

  module Klass

    VALIDATIONS = {
Severity: Minor
Found in app/models/protonym/soft_validation_extensions.rb - About 6 hrs to fix

    Method sv_fix_coordinated_names has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def sv_fix_coordinated_names
          fixed = false
          gender = self.gender_class
          speech = self.part_of_speech_class
    
    
    Severity: Minor
    Found in app/models/protonym/soft_validation_extensions.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 sv_validate_coordinated_names has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        def sv_validate_coordinated_names
          r = self.iczn_set_as_incorrect_original_spelling_of_relationship
          list_of_coordinated_names.each do |t|
            soft_validations.add(:base, "The original publication does not match with the original publication of the coordinated #{t.rank_class.rank_name}",
                                 fix: :sv_fix_coordinated_names, success_message: 'Original publication was updated') if self.source && t.source && self.source.id != t.source.id
    Severity: Minor
    Found in app/models/protonym/soft_validation_extensions.rb - About 4 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. [50/25]
    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

    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. [44/25]
    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)

    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_fix_coordinated_names has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def sv_fix_coordinated_names
          fixed = false
          gender = self.gender_class
          speech = self.part_of_speech_class
    
    
    Severity: Major
    Found in app/models/protonym/soft_validation_extensions.rb - About 3 hrs to fix

      Method sv_missing_relationships has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          def sv_missing_relationships
            if  !self.cached_misspelling && !self.name_is_missapplied?
              if is_species_rank?
                soft_validations.add(:base, 'Missing relationship: Original genus is not selected') if self.original_genus.nil?
              elsif is_genus_rank?
      Severity: Minor
      Found in app/models/protonym/soft_validation_extensions.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 sv_single_sub_taxon has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def sv_single_sub_taxon
            if self.rank_class
              rank = rank_string
              if rank != 'potentially_validating rank' && self.rank_class.nomenclatural_code == :iczn && %w(subspecies subgenus subtribe tribe subfamily).include?(self.rank_class.rank_name)
                sisters = self.parent.descendants.with_rank_class(rank).select{|t| t.id == t.cached_valid_taxon_name_id}
      Severity: Minor
      Found in app/models/protonym/soft_validation_extensions.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 has too many lines. [31/25]
      Open

          def sv_validate_coordinated_names
            r = self.iczn_set_as_incorrect_original_spelling_of_relationship
            list_of_coordinated_names.each do |t|
              soft_validations.add(:base, "The original publication does not match with the original publication of the coordinated #{t.rank_class.rank_name}",
                                   fix: :sv_fix_coordinated_names, success_message: 'Original publication was updated') if self.source && t.source && self.source.id != t.source.id

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

          def sv_fix_add_nominotypical_sub
            rank  = rank_string
            p     = self.parent
            prank = p.rank_string
            if (rank =~ /Family/ && prank =~ /Family/) || (rank =~ /Genus/ && prank =~ /Genus/) || (rank =~ /Species/ && prank =~ /Species/)

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

          def sv_missing_classifications
            if !self.cached_misspelling && !self.name_is_missapplied?
              if is_species_rank?
                soft_validations.add(:base, 'Part of speech is not specified. Please select if the name is a noun or an adjective.') if self.part_of_speech_class.nil?
              elsif is_genus_rank?
      Severity: Minor
      Found in app/models/protonym/soft_validation_extensions.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 sv_fix_add_nominotypical_sub has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def sv_fix_add_nominotypical_sub
            rank  = rank_string
            p     = self.parent
            prank = p.rank_string
            if (rank =~ /Family/ && prank =~ /Family/) || (rank =~ /Genus/ && prank =~ /Genus/) || (rank =~ /Species/ && prank =~ /Species/)
      Severity: Minor
      Found in app/models/protonym/soft_validation_extensions.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 sv_potential_homonyms has 50 lines of code (exceeds 25 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 2 hrs to fix

        Method sv_homotypic_synonyms has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def sv_homotypic_synonyms
              unless self.unavailable_or_invalid?
                if self.id == self.lowest_rank_coordinated_taxon.id
                  possible_synonyms = []
                  if rank_string =~ /Species/
        Severity: Minor
        Found in app/models/protonym/soft_validation_extensions.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_species_gender_agreement has 44 lines of code (exceeds 25 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 hr to fix

          Method sv_parent_priority has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def sv_parent_priority
                if self.rank_class
                  rank_group = self.rank_class.parent
                  parent = self.parent
          
          
          Severity: Minor
          Found in app/models/protonym/soft_validation_extensions.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_validate_coordinated_names has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def sv_validate_coordinated_names
                r = self.iczn_set_as_incorrect_original_spelling_of_relationship
                list_of_coordinated_names.each do |t|
                  soft_validations.add(:base, "The original publication does not match with the original publication of the coordinated #{t.rank_class.rank_name}",
                                       fix: :sv_fix_coordinated_names, success_message: 'Original publication was updated') if self.source && t.source && self.source.id != t.source.id
          Severity: Minor
          Found in app/models/protonym/soft_validation_extensions.rb - About 1 hr to fix

            Method sv_fix_add_nominotypical_sub has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def sv_fix_add_nominotypical_sub
                  rank  = rank_string
                  p     = self.parent
                  prank = p.rank_string
                  if (rank =~ /Family/ && prank =~ /Family/) || (rank =~ /Genus/ && prank =~ /Genus/) || (rank =~ /Species/ && prank =~ /Species/)
            Severity: Minor
            Found in app/models/protonym/soft_validation_extensions.rb - About 1 hr to fix

              Method sv_primary_types has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def sv_primary_types
                    if self.rank_class
                      if self.rank_class.parent.to_s =~ /Species/ && !self.cached_misspelling && !self.name_is_missapplied?
                      if self.type_materials.primary.empty? && self.type_materials.syntypes.empty?
                          soft_validations.add(:base, 'Primary type is not selected')
              Severity: Minor
              Found in app/models/protonym/soft_validation_extensions.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_extant_children has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def sv_extant_children
                    unless self.parent_id.blank?
                      if self.is_fossil?
                        taxa = Protonym.where(parent_id: self.id)
                        z = 0
              Severity: Minor
              Found in app/models/protonym/soft_validation_extensions.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_type_placement has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def sv_type_placement
                    # type of this taxon is not included in this taxon
                    if !!self.type_taxon_name
                      soft_validations.add(:base, "#{self.rank_class.rank_name} #{self.cached_html} has the type #{self.type_taxon_name.rank_class.rank_name} #{self.type_taxon_name.cached_html} classified outside of this taxon") unless self.type_taxon_name.get_valid_taxon_name.ancestors.include?(TaxonName.find(self.cached_valid_taxon_name_id))
                    end
              Severity: Minor
              Found in app/models/protonym/soft_validation_extensions.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 sv_original_combination_relationships has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def sv_original_combination_relationships
                    if !self.cached_misspelling && !self.name_is_missapplied?
                      relationships = self.original_combination_relationships
                      unless relationships.empty?
                        relationships = relationships.sort_by{|r| r.type_class.order_index }
              Severity: Minor
              Found in app/models/protonym/soft_validation_extensions.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

              Avoid deeply nested control flow statements.
              Open

                                if rank_base =~ /Species/
                                  soft_validations.add(:base, "Missing relationship: #{self.cached_html_name_and_author_year} could be a primary homonym of #{s.cached_html_name_and_author_year} (alternative spelling)")
                                elsif
                                  soft_validations.add(:base, "Missing relationship: #{self.cached_html_name_and_author_year} could be an homonym of #{s.cached_html_name_and_author_year} (alternative spelling)")
                                end
              Severity: Major
              Found in app/models/protonym/soft_validation_extensions.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                              elsif rank_base =~ /Species/
                                name3 = self.cached_secondary_homonym ? self.cached_secondary_homonym : nil
                                possible_secondary_homonyms = name3 ? Protonym.with_secondary_homonym(name3).without_homonym_or_suppressed.without_taxon_name_classification_array(TAXON_NAME_CLASS_NAMES_UNAVAILABLE_AND_INVALID).not_self(self).with_base_of_rank_class(rank_base).with_project(self.project_id) : []
                                list3 = reduce_list_of_synonyms(possible_secondary_homonyms)
                                if !list3.empty?
                Severity: Major
                Found in app/models/protonym/soft_validation_extensions.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                            soft_validations.add(:base, 'Missing relationship: Type genus is not selected') if self.type_genus.nil?
                  Severity: Major
                  Found in app/models/protonym/soft_validation_extensions.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                soft_validations.add(:base, "Gender is not specified#{ g.nil? ? '' : ' (possible gender is ' + g + ')'}")
                    Severity: Major
                    Found in app/models/protonym/soft_validation_extensions.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                      unless e.nil?
                                        soft_validations.add(:name, "Name has non #{g.class.name} ending: -#{e}")
                                      end
                      Severity: Major
                      Found in app/models/protonym/soft_validation_extensions.rb - About 45 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                              if (rank =~ /Family/ && prank =~ /Family/) || (rank =~ /Genus/ && prank =~ /Genus/) || (rank =~ /Species/ && prank =~ /Species/)
                                begin
                                  Protonym.transaction do
                                    if rank =~ /Family/ && prank =~ /Family/
                                      name = Protonym.family_group_base(self.parent.name)
                        Severity: Major
                        Found in app/models/protonym/soft_validation_extensions.rb - About 40 mins to fix

                          Avoid more than 4 levels of block nesting.
                          Open

                                        if !list2.empty?
                                          list2.each do |s|
                                            if rank_base =~ /Species/
                                              soft_validations.add(:base, "Missing relationship: #{self.cached_html_name_and_author_year} could be a primary homonym of #{s.cached_html_name_and_author_year} (alternative spelling)")
                                            elsif

                          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.

                          Avoid more than 4 levels of block nesting.
                          Open

                                        unless e.nil?
                                          soft_validations.add(:feminine_name, "Name has a non feminine ending: -#{e}")
                                        end

                          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.

                          Avoid more than 4 levels of block nesting.
                          Open

                                        if date1 < date2
                                          soft_validations.add(:base, "#{self.rank_class.rank_name.capitalize} #{self.cached_html_name_and_author_year} should not be older than parent #{parent.rank_class.rank_name} #{parent.cached_html_name_and_author_year}")
                                        end

                          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.

                          Avoid more than 4 levels of block nesting.
                          Open

                                        unless g.nil?
                                          e = species_questionable_ending(g, self.name)
                                          unless e.nil?
                                            soft_validations.add(:name, "Name has non #{g.class.name} ending: -#{e}")
                                          end

                          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.

                          Avoid more than 4 levels of block nesting.
                          Open

                                        unless e.nil?
                                          soft_validations.add(:neuter_name, "Name has a non neuter ending: -#{e}")
                                        end

                          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.

                          Avoid more than 4 levels of block nesting.
                          Open

                                        unless e.nil?
                                          soft_validations.add(:masculine_name, "Name has a non masculine ending: -#{e}")
                                        end

                          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.

                          Avoid more than 4 levels of block nesting.
                          Open

                                          if rank_base =~ /Species/
                                            soft_validations.add(:base, "Missing relationship: #{self.cached_html_name_and_author_year} should be a primary homonym of #{s.cached_html_name_and_author_year}")
                                            #  fix: :sv_fix_add_relationship('iczn_set_as_primary_homonym_of'.to_sym, s.id),
                                            #  success_message: 'Primary homonym relationship was added',
                                            #  failure_message: 'Fail to add a relationship')

                          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.

                          Avoid more than 4 levels of block nesting.
                          Open

                                        name2 = self.cached_primary_homonym_alternative_spelling ? self.cached_primary_homonym_alternative_spelling : nil

                          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.

                          Avoid more than 4 levels of block nesting.
                          Open

                                        possible_primary_homonyms_alternative_spelling = name2 ? Protonym.with_primary_homonym_alternative_spelling(name2).without_homonym_or_suppressed.without_taxon_name_classification_array(TAXON_NAME_CLASS_NAMES_UNAVAILABLE_AND_INVALID).not_self(self).with_base_of_rank_class(rank_base).with_project(self.project_id) : []

                          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

                                      t.save

                          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: @proceps - make these individual validations !! way too complex here

                          TODO found
                          Open

                              # TODO: way too long

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

                                      if feminine_name.blank?
                                        soft_validations.add(:feminine_name, "The species name is marked as #{part_of_speech_name}, but the name spelling in feminine is not provided")
                                      else
                                        e = species_questionable_ending(TaxonNameClassification::Latinized::Gender::Feminine, feminine_name)
                                        unless e.nil?
                          Severity: Minor
                          Found in app/models/protonym/soft_validation_extensions.rb and 2 other locations - About 20 mins to fix
                          app/models/protonym/soft_validation_extensions.rb on lines 94..99
                          app/models/protonym/soft_validation_extensions.rb on lines 103..108

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

                          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

                                      if masculine_name.blank?
                                        soft_validations.add(:masculine_name, "The species name is marked as #{part_of_speech_name}, but the name spelling in masculine is not provided")
                                      else
                                        e = species_questionable_ending(TaxonNameClassification::Latinized::Gender::Masculine, masculine_name)
                                        unless e.nil?
                          Severity: Minor
                          Found in app/models/protonym/soft_validation_extensions.rb and 2 other locations - About 20 mins to fix
                          app/models/protonym/soft_validation_extensions.rb on lines 85..90
                          app/models/protonym/soft_validation_extensions.rb on lines 103..108

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

                          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

                                      if neuter_name.blank?
                                        soft_validations.add(:neuter_name, "The species name is marked as #{part_of_speech_name}, but the name spelling in neuter is not provided")
                                      else
                                        e = species_questionable_ending(TaxonNameClassification::Latinized::Gender::Neuter, neuter_name)
                                        unless e.nil?
                          Severity: Minor
                          Found in app/models/protonym/soft_validation_extensions.rb and 2 other locations - About 20 mins to fix
                          app/models/protonym/soft_validation_extensions.rb on lines 85..90
                          app/models/protonym/soft_validation_extensions.rb on lines 94..99

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

                          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

                          Use 2 (not 4) spaces for indentation.
                          Open

                                      soft_validations.add(:base, 'Primary type is not selected')

                          This cops checks for indentation that doesn't use the specified number of spaces.

                          See also the IndentationConsistency cop which is the companion to this one.

                          Example:

                          # bad
                          class A
                           def test
                            puts 'hello'
                           end
                          end
                          
                          # good
                          class A
                            def test
                              puts 'hello'
                            end
                          end

                          Example: IgnoredPatterns: ['^\s*module']

                          # bad
                          module A
                          class B
                            def test
                            puts 'hello'
                            end
                          end
                          end
                          
                          # good
                          module A
                          class B
                            def test
                              puts 'hello'
                            end
                          end
                          end

                          Use 2 (not 0) spaces for indentation.
                          Open

                                  if self.type_materials.primary.empty? && self.type_materials.syntypes.empty?

                          This cops checks for indentation that doesn't use the specified number of spaces.

                          See also the IndentationConsistency cop which is the companion to this one.

                          Example:

                          # bad
                          class A
                           def test
                            puts 'hello'
                           end
                          end
                          
                          # good
                          class A
                            def test
                              puts 'hello'
                            end
                          end

                          Example: IgnoredPatterns: ['^\s*module']

                          # bad
                          module A
                          class B
                            def test
                            puts 'hello'
                            end
                          end
                          end
                          
                          # good
                          module A
                          class B
                            def test
                              puts 'hello'
                            end
                          end
                          end

                          There are no issues that match your filters.

                          Category
                          Status