Class Newsletter
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class NewsletterPlugin::Newsletter < ApplicationRecord
belongs_to :environment, optional: true
belongs_to :person, optional: true
validates_presence_of :environment, :person
validates_uniqueness_of :environment_id
Method import_recipients
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def import_recipients(file, name_column = nil, email_column = nil, headers = nil)
name_column ||= 1
email_column ||= 2
headers ||= false
- 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 body
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def body(data = {})
mailing_link = data[:mailing] ? public_view_link : ""
content_tag(:div, mailing_link.html_safe + content_tag(:table, (self.image.nil? ? "" : content_tag(:tr, content_tag(:th, tag(:img, src: "#{self.environment.top_url}#{self.image.public_filename}", style: CSS["header-image"]), colspan: 2), style: CSS["newsletter-header"])).html_safe + self.posts(data).map do |post|
if post.image
post_with_image(post)
- 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 posts
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def posts(data = {})
limit = self.posts_per_blog.zero? ? nil : self.posts_per_blog
posts = if self.last_send_at.nil?
self.blogs.flat_map do |blog|
blog.posts
- 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"