Showing 40 of 80 total issues
Method sync_mirror
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def sync_mirror
return if self.is_mirrored || !self.site.is_mirrored?
(Cms::Site.mirrored - [self.site]).each do |site|
mirror = case self
- 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 create
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create
@slides = []
# Sometimes params[:file] comes in as a single file object
unless params[:file].is_a?(Hash)
- 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 create
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@files = []
# Sometimes params[:file] comes in as a single file object
unless params[:file].is_a?(Hash)
Method initialize
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize
@cms_title = 'ComfyPress CMS Engine'
@admin_auth = 'ComfyPress::HttpAuth'
@public_auth = 'ComfyPress::DummyAuth'
@seed_data_path = nil
Method create
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@slides = []
# Sometimes params[:file] comes in as a single file object
unless params[:file].is_a?(Hash)
Method render
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render
files = block.files
case self.type
when 'url'
return '' if files.blank?
Method initialize_tag
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def initialize_tag(page, tag_signature)
if match = tag_signature.match(regex_tag_signature)
params = begin
(CSV.parse_line(match[2].to_s, :col_sep => ':') || []).compact
- 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 import_pages
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.import_pages(to_site, from_folder = nil, path = nil, root = true, parent = nil, page_ids = [], force_import = false)
Method import_layouts
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.import_layouts(to_site, from_folder = nil, path = nil, root = true, parent = nil, layout_ids = [], force_import = false)
Method options_for_select
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.options_for_select(site, page = nil, current_page = nil, depth = 0, exclude_self = true, spacer = '. . ')
Consider simplifying this complex logical expression. Open
if layout.new_record? || File.mtime(file_path) > layout.updated_at || force_import
attributes = YAML.load_file(file_path).try(:symbolize_keys!) || { }
layout.label = attributes[:label] || identifier.titleize
layout.app_layout = attributes[:app_layout] || parent.try(:app_layout)
layout.position = attributes[:position] if attributes[:position]
Consider simplifying this complex logical expression. Open
if page.new_record? || File.mtime(file_path) > page.updated_at || force_import
attributes = YAML.load_file(file_path).try(:symbolize_keys!) || { }
page.label = attributes[:label] || slug.titleize
page.layout = site.layouts.find_by_identifier(attributes[:layout]) || parent.try(:layout)
page.target_page = site.pages.find_by_full_path(attributes[:target_page])
Method options_for_select
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.options_for_select(site, layout = nil, current_layout = nil, depth = 0, spacer = '. . ')
Method content
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def content
return unless (layout = Cms::Layout.find_by_identifier(identifier))
type = params[0]
format = params[1]
- 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 options_for_select
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.options_for_select(site, page = nil, current_page = nil, depth = 0, exclude_self = true, spacer = '. . ')
return [] if (current_page ||= site.pages.root) == page && exclude_self || !current_page
out = []
out << [ "#{spacer*depth}#{current_page.label}", current_page.id ] unless current_page == page
current_page.children.each do |child|
- 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 cms_page_content
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def cms_page_content(identifier, page = nil)
return '' unless page ||= @cms_page
return '' unless block = page.blocks.find_by_identifier(identifier)
# If block is a page_file(s) we will return objects instead of attempting
# to render them out
- 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 sync_categories
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def sync_categories
(self.category_ids || {}).each do |category_id, flag|
case flag.to_i
when 1
if category = Cms::Category.find_by_id(category_id)
- 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 assign_parent
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def assign_parent
return unless site
self.parent ||= site.pages.root unless self == site.pages.root || site.pages.count == 0
end
- 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 render_html
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def render_html(status = 200)
if @cms_layout = @cms_page.layout
app_layout = (@cms_layout.app_layout.blank? || request.xhr?) ? false : @cms_layout.app_layout
render :inline => @cms_page.content, :layout => app_layout, :status => status, :content_type => 'text/html'
else
- 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 load_cms_page
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def load_cms_page
@cms_page = @cms_site.pages.published.find_by_full_path!("/#{params[:cms_path]}")
return redirect_to(@cms_page.target_page.url) if @cms_page.target_page
rescue ActiveRecord::RecordNotFound
- 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"