Showing 3 of 7 total issues
Method harvest!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def harvest!
return unless Settings.email.user
Gmail.connect!(Settings.email.user, Settings.email.password) do |gmail|
gmail.inbox.emails(:unread, after: Date.parse('2017-03-01')).each do |message|
- 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 harvest!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def harvest!
email.message.body.decoded.split('=========================================================================').each do |msg|
m = EmailParser.new(Struct.new(:message).new(Mail.new(msg)))
Rails.logger.debug "[#{m.message_id}] Loaded message #{m.subject}"
if m.job? && m.valid?
- 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 nav_link
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def nav_link text, url, options = {}
current = current_page?(url)
content_tag :li, class: ['nav-item', ('active' if current)].join(' ') do
link_to url, options.merge(class: "#{options[:class]} nav-link") do
safe_join [text, ((content_tag(:span, ' (current)', class: 'visually-hidden') if current) || '')]
- 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"