Showing 34 of 45 total issues
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 clean_path
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.clean_path(path)
clean_path = path.dup
# Remove eventual host
clean_path = URI(clean_path).path
# Leading slash for absolute 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 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"
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
Function updateViaInputs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
updateViaInputs: function (event) {
'use strict';
var children = event.to.children,
newPosition = 0,
destroyInput,
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def reorder
parent_id = params[:parentId].blank? ? nil : params[:parentId]
old_parent_id = params[:oldParentId].blank? ? nil : params[:oldParentId]
ids = params[:ids] || []
ids.each.with_index do |id, index|
- 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 static_target
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def static_target
test_kind_method = "menu_item_kind_#{kind}?"
return nil if website.respond_to?(test_kind_method) && !website.public_send(test_kind_method)
case kind
- 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 unpublished_by_last_save?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def unpublished_by_last_save?
return unless respond_to?(:published)
return true if saved_change_to_published? && !published?
if respond_to?(:published_at)
return saved_change_to_published_at? && (published_at.nil? || published_at > Time.now)
- 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 add_to_cohort
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_to_cohort(cohort)
cohorts << cohort unless cohort.in?(cohorts)
diploma_years << cohort.academic_year unless cohort.academic_year.in? diploma_years
diploma_programs << cohort.program unless cohort.program.in? diploma_programs
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 redirect_if_not_localized
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def redirect_if_not_localized
return if @l10n.present?
if resource_is_website_direct_object? && !resource.website.localized_in?(current_language)
redirect_to [:confirm_localization, :admin, resource.website, { about: resource.to_gid.to_s }]
- 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 build_person
has a Cognitive Complexity of 6 (exceeds 5 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
- 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 adjust_mobile_phone
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def adjust_mobile_phone
return if self.mobile_phone.nil?
self.mobile_phone = self.mobile_phone.delete(' ')
if self.mobile_phone.start_with?('06', '07')
self.mobile_phone = "+33#{self.mobile_phone[1..-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 render_select_filter
has a Cognitive Complexity of 6 (exceeds 5 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]
- 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"