codeforamerica/clientcomm-rails

View on GitHub
app/models/message.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Class Message has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class Message < ApplicationRecord
  include Rails.application.routes.url_helpers

  belongs_to :reporting_relationship, class_name: 'ReportingRelationship', foreign_key: 'reporting_relationship_id'
  belongs_to :original_reporting_relationship, class_name: 'ReportingRelationship', foreign_key: 'original_reporting_relationship_id'
Severity: Minor
Found in app/models/message.rb - About 2 hrs to fix

    Method create_from_twilio! has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.create_from_twilio!(twilio_params)
        from_phone_number = twilio_params[:From]
        to_phone_number = twilio_params[:To]
    
        department = Department.find_by(phone_number: to_phone_number)
    Severity: Minor
    Found in app/models/message.rb - About 1 hr to fix

      Method create_client_edit_markers has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.create_client_edit_markers(user:, phone_number:, reporting_relationships:, as_admin:)
          if as_admin && user.admin
            user_full_name = I18n.t('messages.admin_user_description')
            user_id = nil
          else
      Severity: Minor
      Found in app/models/message.rb - About 1 hr to fix

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

          def self.create_client_edit_markers(user:, phone_number:, reporting_relationships:, as_admin:)
            if as_admin && user.admin
              user_full_name = I18n.t('messages.admin_user_description')
              user_id = nil
            else
        Severity: Minor
        Found in app/models/message.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