Showing 52 of 135 total issues
Method import_page
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import_page(path, parent)
slug = path.split("/").last
# setting page record
page =
Method comfy_route_cms_admin
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def comfy_route_cms_admin(path: "admin")
scope module: :comfy, as: :comfy do
scope module: :admin do
namespace :cms, as: :admin_cms, path: path, except: :show do
get "/", to: "base#jump"
Method import_page
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def import_page(path, parent)
slug = path.split("/").last
# setting page record
page =
- 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!
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import!
Dir["#{path}[^_]*"].each do |file_path|
filename = ::File.basename(file_path)
file = site.files.with_attached_attachment
Method test_update_forces_page_content_reload
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_update_forces_page_content_reload
layout_a = comfy_cms_layouts(:nested)
layout_b = comfy_cms_layouts(:child)
page_a = @site.pages.create!(
label: "page_1",
Method test_creation_with_files
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_creation_with_files
assert_difference "Comfy::Cms::Page.count" do
assert_difference "Comfy::Cms::Fragment.count", 3 do
assert_difference "ActiveStorage::Attachment.count", 3 do
r :post, comfy_admin_cms_site_pages_path(site_id: @site), params: {
Method test_creation_for_page
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_creation_for_page
assert_difference -> { @page.revisions.count } do
@page.update!(
fragments_attributes: [
{ identifier: "content",
Method test_revert
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_revert
assert_difference -> { @page.revisions.count } do
r :patch, revert_comfy_admin_cms_site_page_revision_path(@site, @page, @revision)
assert_response :redirect
assert_redirected_to edit_comfy_admin_cms_site_page_path(@site, @page)
Function buildRedactorOptions
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
const buildRedactorOptions = () => {
const fileUploadPath = document.querySelector('meta[name="cms-file-upload-path"]').content;
const pagesPath = document.querySelector('meta[name="cms-pages-path"]').content;
const csrfParam = Rails.csrfParam();
const csrfToken = Rails.csrfToken();
Method test_restore_from_revision_for_page
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_restore_from_revision_for_page
revision = comfy_cms_revisions(:page)
assert_difference -> { @page.revisions.count } do
@page.restore_from_revision(revision)
Method create
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
categories_scope = @site.categories.of_type("Comfy::Cms::File")
if params[:categories]
ids = categories_scope.where(label: params[:categories]).pluck(:id)
Method nodes
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def nodes(tokens)
nodes = [[]]
tokens.each do |token|
case token
Method import_translations
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import_translations(path, page)
old_translations = page.translations.pluck(:locale)
new_translations = []
Dir["#{path}content.*.html"].each do |file_path|
Method test_seeds_enabled
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_seeds_enabled
ComfortableMexicanSofa.config.enable_seeds = true
Comfy::Cms::Layout.destroy_all
Comfy::Cms::Page.destroy_all
Comfy::Cms::Snippet.destroy_all
Method index
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
files_scope = @site.files.with_attached_attachment
case params[:source]
Method render_cms_page
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def render_cms_page(path, options = {}, locals = {}, &block)
path.gsub!(%r{^/#{@cms_site.path}}, "") if @cms_site.path.present?
unless (@cms_page = @cms_site.pages.find_by_full_path(path))
raise ComfortableMexicanSofa::MissingPage, path
- 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_site
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def load_cms_site
@cms_site ||=
if params[:site_id]
::Comfy::Cms::Site.find_by_id(params[:site_id])
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 content
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def content
return "" unless layout
base = ComfortableMexicanSofa.config.public_cms_path || ""
unless base.ends_with?("/")
- 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 reset_config
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def reset_config
ComfortableMexicanSofa.configure do |config|
config.cms_title = "ComfortableMexicanSofa CMS Engine"
config.admin_auth = "ComfortableMexicanSofa::AccessControl::AdminAuthentication"
config.admin_authorization = "ComfortableMexicanSofa::AccessControl::AdminAuthorization"
Method test_get_public_page_with_sites_with_different_paths
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_get_public_page_with_sites_with_different_paths
Comfy::Cms::Site.delete_all
site_a = Comfy::Cms::Site.create!(identifier: "site-a", hostname: "www.example.com", path: "")
site_b = Comfy::Cms::Site.create!(identifier: "site-b", hostname: "www.example.com", path: "path-b")
site_c = Comfy::Cms::Site.create!(identifier: "site-c", hostname: "www.example.com", path: "path-c/child")