mysociety/alaveteli

View on GitHub
app/models/mail_server_log.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Class MailServerLog has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

class MailServerLog < ApplicationRecord
  # `serialize` needs to be called before all other ActiveRecord code.
  # See http://stackoverflow.com/a/15610692/387558
  serialize :delivery_status, DeliveryStatusSerializer

Severity: Minor
Found in app/models/mail_server_log.rb - About 2 hrs to fix

    Method load_file has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.load_file(file_name)
        is_gz = file_name.include?(".gz")
        file_name_db = is_gz ? file_name.gsub(".gz", "") : file_name
    
        modified = File.stat(file_name).mtime
    Severity: Minor
    Found in app/models/mail_server_log.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 load_file has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.load_file(file_name)
        is_gz = file_name.include?(".gz")
        file_name_db = is_gz ? file_name.gsub(".gz", "") : file_name
    
        modified = File.stat(file_name).mtime
    Severity: Minor
    Found in app/models/mail_server_log.rb - About 1 hr to fix

      Method delivery_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def delivery_status
          unless attributes['delivery_status'].present?
            # attempt to parse the status from the log line and store if successful
            set_delivery_status
          end
      Severity: Minor
      Found in app/models/mail_server_log.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 line has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def line(opts = {})
          _line = read_attribute(:line)
      
          if opts[:redact]
            _line = strip_syslog_prefix(_line)
      Severity: Minor
      Found in app/models/mail_server_log.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

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

        def self.request_exim_sent?(ir)
          # Look for line showing request was sent
          found = false
          ir.mail_server_logs.each do |mail_server_log|
            test_outgoing = " <= " + ir.incoming_email + " "
      Severity: Minor
      Found in app/models/mail_server_log.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