SpeciesFileGroup/taxonworks

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

Summary

Maintainability
F
1 wk
Test Coverage

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? && 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

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.

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

    def sv_species_gender_agreement
      if is_species_rank?
        s = part_of_speech_name
        if !s.nil? && available?
          if %w{adjective participle}.include?(s)
Severity: Minor
Found in app/models/protonym/soft_validation_extensions.rb - About 1 day to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File soft_validation_extensions.rb has 498 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 7 hrs to fix

    Method sv_potential_family_homonyms has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        def sv_potential_family_homonyms
          if persisted? && is_family_rank? && 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 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_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 30 (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. [41/25]
    Open

        def sv_potential_species_homonyms
          if persisted? && is_species_rank? && 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

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

              def sv_potential_genus_homonyms
            if persisted? && is_genus_rank? && 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 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 sv_species_gender_agreement_not_required has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def sv_species_gender_agreement_not_required
            if is_species_rank? && ((!feminine_name.blank? || !masculine_name.blank? || !neuter_name.blank?)) && available?
              s = part_of_speech_name
              if !s.nil? && !%w{adjective participle}.include?(s)
                soft_validations.add(:feminine_name, 'Alternative spelling is not required for the name which is not adjective or participle.') unless feminine_name.blank?
      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 has too many lines. [29/25]
      Open

          def sv_species_gender_agreement
            if is_species_rank?
              s = part_of_speech_name
              if !s.nil? && available?
                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_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_homotypic_synonyms has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def sv_homotypic_synonyms
            unless 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_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_potential_species_homonyms has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def sv_potential_species_homonyms
            if persisted? && is_species_rank? && 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 hr to fix

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

                def sv_species_gender_agreement
                  if is_species_rank?
                    s = part_of_speech_name
                    if !s.nil? && available?
                      if %w{adjective participle}.include?(s)
            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/ && available?
                        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

              Avoid deeply nested control flow statements.
              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)
                              soft_validations.add(:masculine_name, "Name has a non masculine ending: -#{e}") unless e.nil?
              Severity: Major
              Found in app/models/protonym/soft_validation_extensions.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                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)
                                soft_validations.add(:neuter_name, "Name has a non neuter ending: -#{e}") unless e.nil?
                Severity: Major
                Found in app/models/protonym/soft_validation_extensions.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                name2 = self.cached_primary_homonym_alternative_spelling ? self.cached_primary_homonym_alternative_spelling : nil
                  Severity: Major
                  Found in app/models/protonym/soft_validation_extensions.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    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('NomenclaturalRank::Iczn::FamilyGroup').with_project(self.project_id) : []
                    Severity: Major
                    Found in app/models/protonym/soft_validation_extensions.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      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)
                                      soft_validations.add(:feminine_name, "Name has a non feminine ending: -#{e}") unless e.nil?
                      Severity: Major
                      Found in app/models/protonym/soft_validation_extensions.rb - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                      name2 = self.cached_primary_homonym_alternative_spelling ? self.cached_primary_homonym_alternative_spelling : nil
                        Severity: Major
                        Found in app/models/protonym/soft_validation_extensions.rb - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                        if !list2.empty?
                                          list2.each do |s|
                                            soft_validations.add(:base, "Missing relationship: #{self.cached_html_name_and_author_year} should be a homonym or duplicate of #{s.cached_html_name_and_author_year}")
                                          end
                                        end
                          Severity: Major
                          Found in app/models/protonym/soft_validation_extensions.rb - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                          if !list2.empty?
                                            list2.each do |s|
                                              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)")
                                            end
                                          else
                            Severity: Major
                            Found in app/models/protonym/soft_validation_extensions.rb - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              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('NomenclaturalRank::Iczn::SpeciesGroup').with_project(self.project_id) : []
                              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

                                  Consider simplifying this complex logical expression.
                                  Open

                                              if !feminine_name.blank? && !masculine_name.blank? && !neuter_name.blank? && (name == masculine_name || name == feminine_name || name == neuter_name)
                                                soft_validations.add(:base, 'Species name does not match with either of three alternative forms')
                                              else
                                                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")
                                  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 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

                                                  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('NomenclaturalRank::Iczn::FamilyGroup').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.

                                    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

                                                  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)
                                                    soft_validations.add(:neuter_name, "Name has a non neuter ending: -#{e}") unless e.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

                                                  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

                                                  if !list2.empty?
                                                    list2.each do |s|
                                                      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)")
                                                    end
                                                  else

                                    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('NomenclaturalRank::Iczn::SpeciesGroup').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.

                                    Avoid more than 4 levels of block nesting.
                                    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)
                                                    soft_validations.add(:feminine_name, "Name has a non feminine ending: -#{e}") unless e.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

                                                  if !list2.empty?
                                                    list2.each do |s|
                                                      soft_validations.add(:base, "Missing relationship: #{self.cached_html_name_and_author_year} should be a homonym or duplicate of #{s.cached_html_name_and_author_year}")
                                                    end
                                                  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 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)
                                                    soft_validations.add(:masculine_name, "Name has a non masculine ending: -#{e}") unless e.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.

                                    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: way too long

                                    TODO found
                                    Open

                                        # !! TODO: @proceps - make these individual validations !! way too complex here

                                    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)
                                                    soft_validations.add(:masculine_name, "Name has a non masculine ending: -#{e}") 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 105..109
                                    app/models/protonym/soft_validation_extensions.rb on lines 119..123

                                    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)
                                                    soft_validations.add(:neuter_name, "Name has a non neuter ending: -#{e}") 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 105..109
                                    app/models/protonym/soft_validation_extensions.rb on lines 112..116

                                    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 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)
                                                    soft_validations.add(:feminine_name, "Name has a non feminine ending: -#{e}") 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 112..116
                                    app/models/protonym/soft_validation_extensions.rb on lines 119..123

                                    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 2 locations. Consider refactoring.
                                    Open

                                            soft_validations.add(:base, "The gender status does not match with the gender of the coordinated #{t.rank_class.rank_name}",
                                                                 fix: :sv_fix_coordinated_names, success_message: 'Gender was updated') if rank_string =~ /Genus/ && self.gender_class != t.gender_class && !has_misspelling_relationship?
                                            soft_validations.add(:base, "The part of speech status does not match with the part of speech of the coordinated #{t.rank_class.rank_name}",
                                    Severity: Minor
                                    Found in app/models/protonym/soft_validation_extensions.rb and 1 other location - About 15 mins to fix
                                    app/models/protonym/soft_validation_extensions.rb on lines 154..156

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

                                    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

                                            soft_validations.add(:base, "The part of speech status does not match with the part of speech of the coordinated #{t.rank_class.rank_name}",
                                                                 fix: :sv_fix_coordinated_names, success_message: 'Gender was updated') if rank_string =~ /Species/ && self.part_of_speech_class != t.part_of_speech_class && !has_misspelling_relationship?
                                            soft_validations.add(:base, "The original genus does not match with the original genus of coordinated #{t.rank_class.rank_name}",
                                    Severity: Minor
                                    Found in app/models/protonym/soft_validation_extensions.rb and 1 other location - About 15 mins to fix
                                    app/models/protonym/soft_validation_extensions.rb on lines 152..154

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

                                    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 -2) spaces for indentation.
                                    Open

                                          if persisted? && is_genus_rank? && available?

                                    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