Showing 34 of 166 total issues
Function setConfigs
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
setConfigs: function () {
'use strict';
this.setConfig('link',
{
toolbar: [
Class BlocksController
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Admin::Communication::BlocksController < Admin::Communication::ApplicationController
load_and_authorize_resource class: Communication::Block,
through: :current_university,
through_association: :communication_blocks
Method filter_by
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def filter_by(params, language)
return all unless params
params.to_unsafe_hash.reduce(all) do |scope, (name, value)|
value = value.strip if value.is_a?(String)
# params might contain an array with an empty value [""] if it has been reset by select2
- 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 find_cohorts
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def find_cohorts
# based on https://stackoverflow.com/questions/3579924/accepts-nested-attributes-for-with-find-or-create
cohorts = []
cohorts_ids = []
self.cohorts.map do |object|
- 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
Function initSortable
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
initSortable: function () {
'use strict';
var nestedSortables,
i;
Method build_person
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_person
if @email.present?
person = find_person_with_email
elsif @first_name.present? && @last_name.present?
person = find_person_with_name_in_current_language
Method extranet_params
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def extranet_params
allowed_params = [
:color
]
localizations_attributes = [
Method organization
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def organization
unless @organization
if @siren.present? && @nic.present?
@organization = find_organization_with_siren_and_nic
elsif @siren.present?
Method import_blocks
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import_blocks
heading = nil
blocks.each do |b|
migration_identifier = b[:migration_identifier]
template_kind = b[:template_kind]
Method render_select_filter
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render_select_filter(f, name, value, options)
options[:multiple] ||= false
options[:collection] = options[:collection].map { |elmt|
if elmt.is_a?(String)
[elmt, elmt]
Method clean_html
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.clean_html(html)
# invalid byte sequence in UTF-8
# https://stackoverflow.com/questions/32826781/invalid-byte-sequence-in-utf-8-when-sanitizing-wordpress-export-content
html = html.force_encoding('UTF-8').scrub
# Relaxed config : https://github.com/rgrove/sanitize/blob/main/lib/sanitize/config/relaxed.rb
Method send_confirmation_instructions
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.send_confirmation_instructions(attributes = {})
confirmable = find_by_unconfirmed_email_with_errors(attributes) if reconfirmable
unless confirmable.try(:persisted?)
confirmable = find_or_initialize_with_errors(confirmation_keys, attributes, :not_found)
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 reorder
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def reorder
ids = params[:ids] || []
first_object = model.find_by(id: ids.first)
ids.each.with_index do |id, index|
object = model.find_by(id: 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
Function sanitizeElementAttributes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
sanitizeElementAttributes: function (elmt, allowedAttributes) {
'use strict';
var children = elmt.children,
child,
i,
- 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 organization
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def organization
unless @organization
if @siren.present? && @nic.present?
@organization = find_organization_with_siren_and_nic
elsif @siren.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 file_validation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def file_validation
if file.attached?
unless file.blob.content_type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
file.purge if persisted?
errors.add(:file, :incorrect_type)
- 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 hugo_ancestors_for_special_page
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def hugo_ancestors_for_special_page(website)
return [] if is_a?(Communication::Website::Page::Localization)
permalink = Communication::Website::Permalink.for_object(self, website)
return [] unless permalink
special_page = permalink.special_page(website)
- 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_radio_buttons_filter
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def render_radio_buttons_filter(f, name, value, options)
options[:collection] = options[:collection].map { |elmt| elmt.is_a?(String) ? [elmt, elmt] : [elmt.is_a?(Hash) ? elmt[:to_s] : elmt.to_s, elmt[:id]] }
f.input name,
as: :radio_buttons,
- 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 from_omniauth
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.from_omniauth(context, attributes)
mapping = context.sso_mapping || []
university = context.is_a?(University) ? context : context.university
# first step: we find the email (we are supposed to have an email mapping)
- 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_check_boxes_filter
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def render_check_boxes_filter(f, name, value, options)
options[:collection] = options[:collection].map { |elmt| elmt.is_a?(String) ? [elmt, elmt] : [elmt.is_a?(Hash) ? elmt[:to_s] : elmt.to_s, elmt[:id]] }
f.input name,
as: :check_boxes,
- 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"