unepwcmc/SAPI

View on GitHub
app/models/taxon_concept.rb

Summary

Maintainability
D
2 days
Test Coverage

File taxon_concept.rb has 490 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class TaxonConcept < ApplicationRecord
  include Deletable
  extend Mobility
  include TrackWhoDoesIt
  has_paper_trail versions: { class_name: "TaxonConceptVersion" }, on: :destroy,
Severity: Minor
Found in app/models/taxon_concept.rb - About 7 hrs to fix

    Class TaxonConcept has 45 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class TaxonConcept < ApplicationRecord
      include Deletable
      extend Mobility
      include TrackWhoDoesIt
      has_paper_trail versions: { class_name: "TaxonConceptVersion" }, on: :destroy,
    Severity: Minor
    Found in app/models/taxon_concept.rb - About 6 hrs to fix

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

        def before_validate_full_name
          self.full_name =
            if rank && parent && ['A', 'N'].include?(name_status)
              rank_name = rank.name
              parent_full_name = parent.full_name
      Severity: Minor
      Found in app/models/taxon_concept.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 expected_full_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def expected_full_name(parent)
          if self.rank &&
            Rank.in_range(Rank::VARIETY, Rank::SPECIES).include?(self.rank.name)
            parent.full_name +
              if self.rank.name == Rank::VARIETY
      Severity: Minor
      Found in app/models/taxon_concept.rb - About 35 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

      Method ensure_taxonomic_position has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def ensure_taxonomic_position
          if new_record? && fixed_order_required? && taxonomic_position.blank?
            prev_taxonomic_position =
              if parent
                last_sibling = TaxonConcept.where(:parent_id => parent_id).
      Severity: Minor
      Found in app/models/taxon_concept.rb - About 25 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

      There are no issues that match your filters.

      Category
      Status