mysociety/alaveteli

View on GitHub
lib/mail_handler/reply_handler.rb

Summary

Maintainability
C
1 day
Test Coverage

Method permanently_failed_addresses has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def self.permanently_failed_addresses(message)
      if MailHandler.empty_return_path?(message)
        # Some sort of auto-response

        # Check for Exim’s X-Failed-Recipients header
Severity: Minor
Found in lib/mail_handler/reply_handler.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

Method is_oof? has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def self.is_oof?(message)
      # Check for out-of-office

      if MailHandler.get_header_string("X-POST-MessageClass", message) == "9; Autoresponder"
        return true
Severity: Minor
Found in lib/mail_handler/reply_handler.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 permanently_failed_addresses has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.permanently_failed_addresses(message)
      if MailHandler.empty_return_path?(message)
        # Some sort of auto-response

        # Check for Exim’s X-Failed-Recipients header
Severity: Minor
Found in lib/mail_handler/reply_handler.rb - About 1 hr to fix

    Method is_oof? has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.is_oof?(message)
          # Check for out-of-office
    
          if MailHandler.get_header_string("X-POST-MessageClass", message) == "9; Autoresponder"
            return true
    Severity: Minor
    Found in lib/mail_handler/reply_handler.rb - About 1 hr to fix

      Avoid too many return statements within this method.
      Open

              return true
      Severity: Major
      Found in lib/mail_handler/reply_handler.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return true
        Severity: Major
        Found in lib/mail_handler/reply_handler.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return true
          Severity: Major
          Found in lib/mail_handler/reply_handler.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return true
            Severity: Major
            Found in lib/mail_handler/reply_handler.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return false
              Severity: Major
              Found in lib/mail_handler/reply_handler.rb - About 30 mins to fix

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

                    def self.get_forward_to_address(message)
                      forward_to = AlaveteliConfiguration.forward_nonbounce_responses_to
                      if AlaveteliConfiguration.enable_alaveteli_pro
                        pro_contact_email = AlaveteliConfiguration.pro_contact_email
                        original_to = message ? MailHandler.get_all_addresses(message) : []
                Severity: Minor
                Found in lib/mail_handler/reply_handler.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