rapidftr/RapidFTR

View on GitHub
app/models/enquiry.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Class Enquiry has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

class Enquiry < BaseModel
  use_database :enquiry

  require 'uuidtools'
  include Searchable
Severity: Minor
Found in app/models/enquiry.rb - About 3 hrs to fix

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

      def mark_or_unmark_as_reunited(reunited)
        without_updating_matches do
          Enquiry.skip_callback(:save, :after, :find_matching_children)
          self['reunited'] = reunited
          save!
    Severity: Minor
    Found in app/models/enquiry.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 mark_or_unmark_as_reunited has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def mark_or_unmark_as_reunited(reunited)
        without_updating_matches do
          Enquiry.skip_callback(:save, :after, :find_matching_children)
          self['reunited'] = reunited
          save!
    Severity: Minor
    Found in app/models/enquiry.rb - About 1 hr to fix

      Method update_from has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def update_from(properties)
          attributes_to_update = {}
          properties.each_pair do |name, value|
            if value.instance_of?(HashWithIndifferentAccess) || value.instance_of?(ActionController::Parameters)
              attributes_to_update[name] = self[name] if attributes_to_update[name].nil?
      Severity: Minor
      Found in app/models/enquiry.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

      There are no issues that match your filters.

      Category
      Status