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 31 (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 35 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

    Avoid too many return statements within this method.
    Open

          return true if subject == "out of office"
    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 if subject.start_with? "out of office autoreply:"
      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 if subject == "out of office reply"
        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 if subject.end_with? "is out of the office"
          Severity: Major
          Found in lib/mail_handler/reply_handler.rb - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status