Showing 52 of 73 total issues
Method page_title
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def page_title(options = {})
object = options.fetch(:object, @meta)
options.delete(:object)
options = Refinery::Pages.page_title.merge(options)
- 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 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@images = []
begin
if params[:image].present? && params[:image][:image].is_a?(Array)
params[:image][:image].each do |image|
Function onload
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
window.onload = function () {
'use strict';
const image = document.getElementById('crop');
const ratios = document.getElementById('ratios');
- 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 insert
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def insert
self.new if @resource.nil?
@url_override = refinery.admin_resources_path(request.query_parameters.merge(insert: true))
if params[:conditions].present?
- 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 sanity_check_heroku_application_name!
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def sanity_check_heroku_application_name!
if heroku? && options[:heroku].to_s.include?('_') || options[:heroku].to_s.length > 30
message = ["\nThe application name '#{options[:heroku]}' that you specified is invalid for Heroku."]
suggested_name = options[:heroku].dup.to_s
if suggested_name.include?('_')
- 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
Consider simplifying this complex logical expression. Open
if (!o.isAllowed(this.currentItem, parentItem) ||
parentItem && parentItem.hasClass(o.disableNesting) ||
o.protectRoot && (parentItem == null && !isRoot || isRoot && level > 1)) {
this.placeholder.addClass(o.errorClass);
if (maxLevels < levels && maxLevels != 0) {
Method link_to
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def link_to
# Get the switch_local variable to determine the locale we're currently editing
# Set up Mobility with our current locale
Mobility.locale = if params[:switch_locale].present? && Refinery::I18n.built_in_locales.keys.map(&:to_s).include?(params[:switch_locale])
Mobility.locale = params[:switch_locale]
Method update
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def update
if @page.update(page_params)
flash.notice = t('refinery.crudify.updated', what: "'#{@page.title}'")
if from_dialog?
- 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 update
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
@image.attributes = image_params
if @image.valid? && @image.save
flash.notice = t('refinery.crudify.updated', what: "'#{@image.title}'")
Method uncrudify
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def uncrudify(controller, action)
unless (controller_name = controller).present? && (action = action).present?
abort <<-HELPDOC.strip_heredoc
You didn't specify anything to uncrudify. Here's some examples:
rake refinery:uncrudify controller=refinery/admin/pages action=create
Method update
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
if @page.update(page_params)
flash.notice = t('refinery.crudify.updated', what: "'#{@page.title}'")
if from_dialog?
Method insert
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def insert
self.new if @image.nil?
@url_override = refinery.admin_images_path(request.query_parameters.merge(insert: true))
if params[:conditions].present?
- 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 pagination_css_class
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def pagination_css_class
if request.xhr? and params[:from_page].present?
"frame_#{params[:from_page] > (params[:page] ? params[:page] : "1") ? 'left' : 'right'}"
else
"frame_center"
- 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 page_title
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def page_title(options = {})
object = options.fetch(:object, @meta)
options.delete(:object)
options = Refinery::Pages.page_title.merge(options)
Method prepare_database!
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def prepare_database!
unless self.options[:skip_migrations]
command = %w[railties:install:migrations]
unless self.options[:skip_db]
command |= %w[db:create db:migrate]
- 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 route_for_model
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def route_for_model(klass, options = {})
options = {:plural => false, :admin => true}.merge options
klass = klass.constantize if klass.respond_to?(:constantize)
active_name = ::ActiveModel::Name.new(
- 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 run_additional_generators!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def run_additional_generators!
generator_args = []
generator_args << '--quiet' if self.options[:quiet]
generator_args << '--skip-migrations' if self.options[:skip_migrations]
Refinery::CoreGenerator.start generator_args
- 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 8 (exceeds 5 allowed). Consider refactoring. Open
def create
@resources = Resource.create_resources(resource_params)
@resource = @resources.detect { |r| !r.valid? }
if params[:insert]
- 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
Consider simplifying this complex logical expression. Open
if (parentItem != null && nextItem == null &&
(o.rtl && (this.positionAbs.left + this.helper.outerWidth() > parentItem.offset().left + parentItem.outerWidth()) ||
!o.rtl && (this.positionAbs.left < parentItem.offset().left))) {
parentItem.after(this.placeholder[0]);
this._clearEmpty(parentItem[0]);
Method action_icon_label
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def action_icon_label(action, url, title, options={}, label = true)