File incoming_message.rb
has 379 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'rexml/document'
require 'zip'
class IncomingMessage < ApplicationRecord
include MessageProminence
Class IncomingMessage
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
class IncomingMessage < ApplicationRecord
include MessageProminence
include CacheAttributesFromRawEmail
include Taggable
Method remove_quoted_sections
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.remove_quoted_sections(text, replacement = "FOLDED_QUOTED_SECTION")
text = text.dup
replacement = "\n" + replacement + "\n"
# First do this peculiar form of quoting, as the > single line quoting
Method extract_attachments
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def extract_attachments
_mail = raw_email.mail!
attachment_attributes = MailHandler.get_attachment_attributes(_mail)
attachment_attributes = attachment_attributes.inject({}) do |memo, attrs|
attrs.delete(:original_body)
Method get_main_body_text_part
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_main_body_text_part(leaves=[])
leaves = foi_attachments if leaves.empty?
# Find first part which is text/plain or text/html
# (We have to include HTML, as increasingly there are mail clients that
- Read upRead up
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 get_body_for_html_display
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_body_for_html_display(collapse_quoted_sections = true)
# Find the body text and remove emails for privacy/anti-spam reasons
text = get_main_body_text_unfolded
folded_quoted_text = get_main_body_text_folded
- Read upRead up
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 get_present_file_extensions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_present_file_extensions
ret = {}
get_attachments_for_display.each do |attachment|
ext = AlaveteliFileTypes.mimetype_to_extension(attachment.content_type)
if ext.nil? && !attachment.filename.nil?
- Read upRead up
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 _convert_part_body_to_text
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _convert_part_body_to_text(part)
if part.nil?
text = "[ Email has no body, please see attachments ]"
else
# whatever kind of attachment it is, get the UTF-8 encoded text
- Read upRead up
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 find_all_unknown_mime_types
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.find_all_unknown_mime_types
IncomingMessage.find_each do |incoming_message|
incoming_message.get_attachments_for_display.each do |attachment|
if attachment.content_type.nil?
raise "internal error incoming_message " + incoming_message.id.to_s
- Read upRead up
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"