Showing 9 of 21 total issues
Function taxons_jstree
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
function taxons_jstree(data) {
var create_or_update_url = data['create_or_update_url'];
$('#taxonomy_tree').jstree({
core: {
Class ResourceController
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class ResourceController < BaseController
before_action :authenticate_admin_user!
before_action :load_resource
Function initDatepicker
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initDatepicker(elem){
$(elem).datepicker({
language: 'fr',
todayBtn: "linked",
keyboardNavigation: false,
Method update
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def update
@object.assign_attributes permitted_resource_params
if @object.send current_action
flash_message(@object, (current_action == :save ? :update : current_action), :success)
- 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 object.respond_to? :seo
fields['og:title'] = object.og_title || Setting.current.og_title
fields['og:description'] = object.og_description || Setting.current.og_description
fields['og:keywords'] = object.og_keywords || Setting.current.og_keywords
fields['og:image'] = object.og_image&.attachment&.url(:regular) || Setting.current.og_image&.attachment&.url(:regular)
Function check_callback
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
check_callback: function (op, node, par, pos, more) {
Method main_sidebar_menu_simple_item
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def main_sidebar_menu_simple_item(current_main_tree, target, icon, path, label)
Method content_header_page_title
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def content_header_page_title
# Work arround with Ransack issue, where all helpers are available
# even with our initializer : include_all_helpers = false
if @object && try(:member_action?)
# TODO : Parent data ?
- 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 translated_field
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def translated_field(form_object, field, options = {})
concat form_object.input field, options
current_settings.available_locales.each do |locale|
unless locale.to_sym == current_settings.default_locale.to_sym
options[:label] = form_object.object.class.human_attribute_name(field) + ' ' + EmojiFlag.new(locale)
- 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"