File application_helper.rb
has 457 lines of code (exceeds 250 allowed). Consider refactoring. Open
module ApplicationHelper
include HtmlCleaner
# TODO: Official recommendation from Rails indicates we should switch to
# unobtrusive JavaScript instead of using anything like `link_to_function`
Method sort_link
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def sort_link(title, column=nil, options = {})
condition = options[:unless] if options.has_key?(:unless)
unless column.nil?
current_column = (params[:sort_column] == column.to_s) || params[:sort_column].blank? && options[:sort_default]
- 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 checkbox_section
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def checkbox_section(form, attribute, choices, options = {})
options = {
checked_method: nil,
name_method: "name",
name_helper_method: nil, # alternative: pass a helper method that gets passed the choice
- 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 checkbox_section
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def checkbox_section(form, attribute, choices, options = {})
options = {
checked_method: nil,
name_method: "name",
name_helper_method: nil, # alternative: pass a helper method that gets passed the choice
Method byline_text
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def byline_text(creation, only_path, text_only = false)
if creation.respond_to?(:author)
creation.author
else
pseuds = @preview_mode ? creation.pseuds_after_saving : creation.pseuds.to_a
- 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 field_name
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def field_name(form_or_object_name, attribute, *_method_names, multiple: false, index: nil)
object_name = if form_or_object_name.respond_to?(:object_name)
form_or_object_name.object_name
else
form_or_object_name
- 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 permit_all_except
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def permit_all_except(params, blocked_keys)
if params.respond_to?(:each_pair)
{}.tap do |result|
params.each_pair do |key, value|
key = key.to_sym
- 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 checkbox_section_toggle
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def checkbox_section_toggle(checkboxes_id, checkboxes_size, options = {})
toggle_show = content_tag(:a, ts("Expand %{checkboxes_size} Checkboxes", checkboxes_size: checkboxes_size),
class: "toggle #{checkboxes_id}_show") + "\n".html_safe
toggle_hide = content_tag(:a, ts("Collapse Checkboxes"),
Method classes_for_main
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def classes_for_main
class_names = controller.controller_name + '-' + controller.action_name
show_sidebar = ((@user || @admin_posts || @collection || show_wrangling_dashboard) && !@hide_dashboard)
class_names += " dashboard" if show_sidebar
- 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 span_if_current
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def span_if_current(link_to_default_text, path, condition=nil, title_attribute_default_text=nil)
is_current = condition.nil? ? current_page?(path) : condition
span_tag = title_attribute_default_text.nil? ? "<span class=\"current\">#{link_to_default_text}</span>" : "<span class=\"current\" title=\"#{title_attribute_default_text}\">#{link_to_default_text}</span>"
link_code = title_attribute_default_text.nil? ? link_to(link_to_default_text, path) : link_to(link_to_default_text, path, title: "#{title_attribute_default_text}")
is_current ? span_tag.html_safe : link_code
- 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 checkbox_section_css_class
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def checkbox_section_css_class(size, concise=false)
css_class = "options index group"
if concise
css_class += " concise lots" if size > ArchiveConfig.OPTIONS_TO_SHOW
- 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 link_to_add_section
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def link_to_add_section(linktext, form, nested_model_name, partial_to_render, locals = {})
Method text_byline
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def text_byline(creation, options={})
if creation.respond_to?(:anonymous?) && creation.anonymous?
anon_byline = ts("Anonymous")
if (logged_in_as_admin? || is_author_of?(creation)) && options[:visibility] != 'public'
anon_byline += " [#{non_anonymous_byline(creation)}]".html_safe
- 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 time_in_zone
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def time_in_zone(time, zone = nil, user = User.current_user)
return ts("(no time specified)") if time.blank?
zone ||= (user&.is_a?(User) && user.preference.time_zone) ? user.preference.time_zone : Time.zone.name
time_in_zone = time.in_time_zone(zone)
- 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 flash_div
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def flash_div *keys
keys.collect { |key|
if flash[key]
if flash[key].is_a?(Array)
content_tag(:div,
- 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"