Showing 21 of 132 total issues
Function setConfigs
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
setConfigs: function () {
'use strict';
this.setConfig('link', {
toolbar: [
['insert', ['link', 'unlink']]
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 = @university.people
.where(email: @email)
.first_or_initialize
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 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 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 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 add
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add(scope_name, choices, label, multiple = false, tree = false)
Method clear_queue!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.clear_queue!
ids = []
Delayed::Job.find_each do |job|
next unless job.public_respond_to?(:payload_object)
if job.payload_object.method_name == :sync_indirect_object_with_git_without_delay &&
- 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 create_missing_special_pages
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_missing_special_pages
Communication::Website::Page::TYPES.each do |page_class|
# Special pages have a before_validation (:on_create) callback to preset title, slug, ...
page = page_class.where(website: self, university: university, language_id: default_language_id).first_or_initialize
next if page.persisted? # No resave
- 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 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 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 clean_empty_paragraphs_at_beginning_and_end
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def clean_empty_paragraphs_at_beginning_and_end(text)
return text unless text.present?
doc = Nokogiri::HTML::DocumentFragment.parse(text)
- 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
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 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"