mysociety/alaveteli

View on GitHub
app/models/outgoing_message.rb

Summary

Maintainability
D
2 days
Test Coverage

Class OutgoingMessage has 50 methods (exceeds 20 allowed). Consider refactoring.
Open

class OutgoingMessage < ApplicationRecord
  include MessageProminence
  include Rails.application.routes.url_helpers
  include LinkToHelper
  include Taggable
Severity: Minor
Found in app/models/outgoing_message.rb - About 7 hrs to fix

    File outgoing_message.rb has 418 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class OutgoingMessage < ApplicationRecord
      include MessageProminence
      include Rails.application.routes.url_helpers
      include LinkToHelper
      include Taggable
    Severity: Minor
    Found in app/models/outgoing_message.rb - About 6 hrs to fix

      Method default_message_replacements has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def default_message_replacements
          opts = {}
      
          if info_request
            opts[:url] = request_url(info_request) if info_request.url_title
      Severity: Minor
      Found in app/models/outgoing_message.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 template_changed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def template_changed
          if raw_body.empty? || HTMLEntities.new.decode(raw_body) =~
                                /\A#{template_regex(letter_template.body(default_message_replacements))}/
            if message_type == 'followup'
              if what_doing == 'internal_review'
      Severity: Minor
      Found in app/models/outgoing_message.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 sendable? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def sendable?
          if status == 'ready'
            if message_type == 'initial_request'
              true
            elsif message_type == 'followup'
      Severity: Minor
      Found in app/models/outgoing_message.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 set_info_request_described_state has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def set_info_request_described_state
          if status == 'failed'
            info_request.set_described_state('error_message')
          elsif message_type == 'initial_request'
            info_request.set_described_state('waiting_response')
      Severity: Minor
      Found in app/models/outgoing_message.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

      There are no issues that match your filters.

      Category
      Status