Showing 16 of 16 total issues
Class Message
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class Message
PREFETCH_ATTRS = ["UID", "ENVELOPE", "BODY.PEEK[]", "FLAGS", "X-GM-LABELS", "X-GM-MSGID", "X-GM-THRID"].freeze
# Raised when given label doesn't exists.
class NoLabelError < RuntimeError; end
Consider simplifying this complex logical expression. Open
if args.first.is_a?(Symbol)
search = MAILBOX_ALIASES[args.shift].dup
opts = args.first.is_a?(Hash) ? args.first : {}
opts[:after] and search.concat ['SINCE', Net::IMAP.format_date(opts[:after])]
Method patch_net_imap_response_parser
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.patch_net_imap_response_parser(klass = Net::IMAP::ResponseParser)
# https://github.com/ruby/ruby/blob/4d426fc2e03078d583d5d573d4863415c3e3eb8d/lib/net/imap.rb#L2258
klass.class_eval do
def msg_att(n = -1)
match(Net::IMAP::ResponseParser::T_LPAR)
Method extract_labels_response
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def extract_labels_response
special, quoted = false, false
index, paren_count = 0, 0
# Start parsing response string for the labels section, parentheses inclusive
- 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
Class Base
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Base
# Gmail IMAP defaults
GMAIL_IMAP_HOST = 'imap.gmail.com'.freeze
GMAIL_IMAP_PORT = 993
Method wait_once
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def wait_once(options = {})
options[:idle_timeout] ||= 29 * 60
response = nil
loop do
- 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 unescape
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def unescape
unesc = ''
special = false
escapes = { '\\' => '\\',
'"' => '"',
- 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 fetch_uids
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def fetch_uids(*args)
args << :all if args.empty?
if args.first.is_a?(Symbol)
search = MAILBOX_ALIASES[args.shift].dup
- 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 msg_att
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def msg_att(n = -1)
match(Net::IMAP::ResponseParser::T_LPAR)
attr = {}
while true
token = lookahead
- 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 fetch_uids
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fetch_uids(*args)
args << :all if args.empty?
if args.first.is_a?(Symbol)
search = MAILBOX_ALIASES[args.shift].dup
Method add_unescape
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.add_unescape(klass = String)
klass.class_eval do
# Add a method to string which unescapes special characters
# We use a simple state machine to ensure that specials are not
# themselves escaped
Method mailbox
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def mailbox(name, &block)
@mailbox_mutex.synchronize do
name = labels.localize(name)
mailbox = (mailboxes[name] ||= Mailbox.new(self, name))
switch_to_mailbox(mailbox) if @current_mailbox != mailbox
- 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 x_gm_label_list
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def x_gm_label_list
if @str.index(/\(([^)]*)\)/ni, @pos)
resp = extract_labels_response
# We need to manually update the position of the regexp to prevent trip-ups
- 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
Identical blocks of code found in 3 locations. Consider refactoring. Open
rescue Net::IMAP::NoResponseError => e
if raise_errors
message = "Couldn't login to given Gmail account: #{username}"
message += " (#{e.response.data.text.strip})"
raise(AuthorizationError.new(e.response), message, e.backtrace)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 33.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 3 locations. Consider refactoring. Open
rescue Net::IMAP::NoResponseError => e
if raise_errors
message = "Couldn't login to given Gmail account: #{username}"
message += " (#{e.response.data.text.strip})"
raise(AuthorizationError.new(e.response), message, e.backtrace)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 33.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 3 locations. Consider refactoring. Open
rescue Net::IMAP::NoResponseError => e
if raise_errors
message = "Couldn't login to given Gmail account: #{username}"
message += " (#{e.response.data.text.strip})"
raise(AuthorizationError.new(e.response), message, e.backtrace)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 33.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76