team-umlaut/umlaut

View on GitHub
app/models/referent.rb

Summary

Maintainability
D
2 days
Test Coverage

Method to_citation has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

  def to_citation
    citation = {}
    # call self.metadata once and use the array for efficiency, don't
    # keep calling it. profiling shows it DOES make a difference. 
    my_metadata = self.metadata
Severity: Minor
Found in app/models/referent.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 create_by_context_object has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

  def self.create_by_context_object(co, options = {})    
    self.clean_up_context_object(co)    
    
    rft = Referent.new

Severity: Minor
Found in app/models/referent.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

File referent.rb has 277 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'i18n'
require 'truncate_to_db_limit'

# Note: There are a few actual attributes stored as Columns in referent --
# these were originally used for identifying a Referent identifying the
Severity: Minor
Found in app/models/referent.rb - About 2 hrs to fix

    Method to_citation has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def to_citation
        citation = {}
        # call self.metadata once and use the array for efficiency, don't
        # keep calling it. profiling shows it DOES make a difference. 
        my_metadata = self.metadata
    Severity: Major
    Found in app/models/referent.rb - About 2 hrs to fix

      Class Referent has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Referent < ActiveRecord::Base
        # for shortcut metadata manipulations
        include MetadataHelper
        
        has_many :requests
      Severity: Minor
      Found in app/models/referent.rb - About 2 hrs to fix

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

          def enhance_referent(key, value, metadata=true, private_data=false, options = {})
        
        
            ActiveRecord::Base.connection_pool.with_connection do
              return if value.nil?
        Severity: Minor
        Found in app/models/referent.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 create_by_context_object has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.create_by_context_object(co, options = {})    
            self.clean_up_context_object(co)    
            
            rft = Referent.new
        
        
        Severity: Minor
        Found in app/models/referent.rb - About 1 hr to fix

          Method enhance_referent has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def enhance_referent(key, value, metadata=true, private_data=false, options = {})
          
          
              ActiveRecord::Base.connection_pool.with_connection do
                return if value.nil?
          Severity: Minor
          Found in app/models/referent.rb - About 1 hr to fix

            Method clean_up_context_object has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.clean_up_context_object(co)
                # First, remove any empty DOIs! or other empty identifiers?
                # LOTS of sources send awful empty identifiers. 
                # That's not a valid identifier!
                empty_ids = co.referent.identifiers.find_all { |i| i =~ Regexp.new('^[^:]+:[^/:]*(/|:)?$')}
            Severity: Minor
            Found in app/models/referent.rb - About 45 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 enhance_referent has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def enhance_referent(key, value, metadata=true, private_data=false, options = {})
            Severity: Minor
            Found in app/models/referent.rb - About 35 mins to fix

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

                def set_values_from_context_object(co)
                  rft = co.referent
                
                  # Multiple identifiers are possible! 
                  rft.identifiers.each do |id_string|
              Severity: Minor
              Found in app/models/referent.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