mysociety/alaveteli

View on GitHub
app/models/outgoing_message.rb

Summary

Maintainability
D
1 day
Test Coverage

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

class OutgoingMessage < ActiveRecord::Base
  include AdminColumn
  include MessageProminence
  include Rails.application.routes.url_helpers
  include LinkToHelper
Severity: Minor
Found in app/models/outgoing_message.rb - About 5 hrs to fix

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

    class OutgoingMessage < ActiveRecord::Base
      include AdminColumn
      include MessageProminence
      include Rails.application.routes.url_helpers
      include LinkToHelper
    Severity: Minor
    Found in app/models/outgoing_message.rb - About 4 hrs to fix

      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 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 sendable? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def sendable?
          if status == 'ready'
            if message_type == 'initial_request'
              return 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 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def set_info_request_described_state
          if message_type == 'initial_request'
            info_request.set_described_state('waiting_response')
          elsif message_type == 'followup'
            if info_request.described_state == 'waiting_clarification'
      Severity: Minor
      Found in app/models/outgoing_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