app/helpers/application_helper.rb

Summary

Maintainability
F
1 wk
Test Coverage

Possible SQL injection
Open

           ContentItemRelation.count(conditions: [conditions, { item_id: item_id }])
Severity: Critical
Found in app/helpers/application_helper.rb by brakeman

Injection is #1 on the 2013 OWASP Top Ten web security risks. SQL injection is when a user is able to manipulate a value which is used unsafely inside a SQL query. This can lead to data leaks, data loss, elevation of privilege, and other unpleasant outcomes.

Brakeman focuses on ActiveRecord methods dealing with building SQL statements.

A basic (Rails 2.x) example looks like this:

User.first(:conditions => "username = '#{params[:username]}'")

Brakeman would produce a warning like this:

Possible SQL injection near line 30: User.first(:conditions => ("username = '#{params[:username]}'"))

The safe way to do this query is to use a parameterized query:

User.first(:conditions => ["username = ?", params[:username]])

Brakeman also understands the new Rails 3.x way of doing things (and local variables and concatenation):

username = params[:user][:name].downcase
password = params[:user][:password]

User.first.where("username = '" + username + "' AND password = '" + password + "'")

This results in this kind of warning:

Possible SQL injection near line 37:
User.first.where((((("username = '" + params[:user][:name].downcase) + "' AND password = '") + params[:user][:password]) + "'"))

See the Ruby Security Guide for more information and Rails-SQLi.org for many examples of SQL injection in Rails.

Module has too many lines. [1376/100]
Open

module ApplicationHelper
  include ExtendedFieldsHelpers
  include ExtendedContentHelpers
  include OaiDcHelpers

Severity: Minor
Found in app/helpers/application_helper.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

File application_helper.rb has 1379 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'avatar/view/action_view_support'

# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  include ExtendedFieldsHelpers
Severity: Major
Found in app/helpers/application_helper.rb - About 3 days to fix

    Assignment Branch Condition size for formatted_value_from_xml is too high. [75.69/15]
    Open

      def formatted_value_from_xml(value, ef = nil, item = nil)
        if ef && %w(autocomplete choice).member?(ef.ftype)
          base_url = ef.base_url
    
          # If the extended field type is a choice, then link the value to the search page for the EF.
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [66/10]
    Open

      def formatted_value_from_xml(value, ef = nil, item = nil)
        if ef && %w(autocomplete choice).member?(ef.ftype)
          base_url = ef.base_url
    
          # If the extended field type is a choice, then link the value to the search page for the EF.
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method has too many lines. [65/10]
    Open

      def show_comments_for(item)
        html_string = "<p>#{t('application_helper.show_comments_for.comment_count', count: @comments.size)}</p><p>"
    
        unless @comments.empty?
          html_string += t('application_helper.show_comments_for.read_and')
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method has too many lines. [63/10]
    Open

      def render_baskets_as_menu
        html = '<ul id="sub-menu" class="menu basket-list-menu">'
    
        basket_count = 0
        Basket.except_certain_baskets(@standard_baskets).all.each do |basket|
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for show_comments_for is too high. [66.95/15]
    Open

      def show_comments_for(item)
        html_string = "<p>#{t('application_helper.show_comments_for.comment_count', count: @comments.size)}</p><p>"
    
        unless @comments.empty?
          html_string += t('application_helper.show_comments_for.read_and')
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [53/10]
    Open

      def link_to_membership_request_of(basket, options = {})
        return '' unless logged_in?
    
        options = {
          join_text: t('application_helper.link_to_membership_request_of.join'),
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for link_to_membership_request_of is too high. [54.38/15]
    Open

      def link_to_membership_request_of(basket, options = {})
        return '' unless logged_in?
    
        options = {
          join_text: t('application_helper.link_to_membership_request_of.join'),
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for render_baskets_as_menu is too high. [53.24/15]
    Open

      def render_baskets_as_menu
        html = '<ul id="sub-menu" class="menu basket-list-menu">'
    
        basket_count = 0
        Basket.except_certain_baskets(@standard_baskets).all.each do |basket|
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for browse_by_category_columns is too high. [52.61/15]
    Open

      def browse_by_category_columns
        # If not, return blank so nothing is displayed
        return '' if categories_field.nil? || !categories_field.is_a_choice?
    
        # Get the current choice from params (limit_to_choice is special because it also controls search results)
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method formatted_value_from_xml has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

      def formatted_value_from_xml(value, ef = nil, item = nil)
        if ef && %w(autocomplete choice).member?(ef.ftype)
          base_url = ef.base_url
    
          # If the extended field type is a choice, then link the value to the search page for the EF.
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 5 hrs to fix

    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

    Assignment Branch Condition size for display_xml_attributes is too high. [48.09/15]
    Open

      def display_xml_attributes(item, options = {})
        raq = ' &raquo; '
        html = []
    
        mappings =
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for dc_metadata_for is too high. [47.05/15]
    Open

      def dc_metadata_for(item)
        metadata = ''
    
        metadata += tag(:link, rel: 'schema.DCTERMS', href: 'http://purl.org/dc/terms/') + "\n"
        metadata += tag(:link, rel: 'schema.DC', href: 'http://purl.org/dc/elements/1.1/') + "\n"
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [42/10]
    Open

      def browse_by_category_columns
        # If not, return blank so nothing is displayed
        return '' if categories_field.nil? || !categories_field.is_a_choice?
    
        # Get the current choice from params (limit_to_choice is special because it also controls search results)
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for users_baskets_list is too high. [46.52/15]
    Open

      def users_baskets_list(user = current_user, options = {})
        # if the user is the current user, use the basket_access_hash instead of fetching them again
        basket_permissions = user == current_user ? @basket_access_hash : user.basket_permissions
    
        row1 = 'user_basket_list_row1'
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for related_items_display_of is too high. [46.58/15]
    Open

      def related_items_display_of(items, options = {})
        return '' if items.blank?
        unless options[:display_num].nil?
          display_num = options[:display_num]
          items = [] if display_num.zero?
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [41/10]
    Open

      def display_xml_attributes(item, options = {})
        raq = ' &raquo; '
        html = []
    
        mappings =
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method render_baskets_as_menu has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

      def render_baskets_as_menu
        html = '<ul id="sub-menu" class="menu basket-list-menu">'
    
        basket_count = 0
        Basket.except_certain_baskets(@standard_baskets).all.each do |basket|
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 4 hrs to fix

    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 has too many lines. [34/10]
    Open

      def related_image_link_for(still_image, options = {}, link_options = {})
        return '' if still_image.blank?
        options = { privacy_type: 'public' }.merge(options)
        if still_image.is_a?(StillImage)
          if !still_image.thumbnail_file.nil?
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method has too many lines. [34/10]
    Open

      def formatted_extended_content_value(field, field_name, value, item, mapping)
        # handle if the field is multiple
        values = []
        if field.multiple?
          values = value
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method display_xml_attributes has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

      def display_xml_attributes(item, options = {})
        raq = ' &raquo; '
        html = []
    
        mappings =
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 4 hrs to fix

    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

    Assignment Branch Condition size for avatar_for is too high. [38.41/15]
    Open

      def avatar_for(user, options = {})
        # New installs use strings for the small_sq value, but we have to handle legacy settings containing arrays
        image_dimension =
          SystemSetting.image_sizes[:small_sq].is_a?(String) ? \
                                 SystemSetting.image_sizes[:small_sq].gsub(/(!|>|<)/, '').split('x').first.to_i : \
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [31/10]
    Open

      def related_items_display_of(items, options = {})
        return '' if items.blank?
        unless options[:display_num].nil?
          display_num = options[:display_num]
          items = [] if display_num.zero?
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method has too many lines. [31/10]
    Open

      def avatar_for(user, options = {})
        # New installs use strings for the small_sq value, but we have to handle legacy settings containing arrays
        image_dimension =
          SystemSetting.image_sizes[:small_sq].is_a?(String) ? \
                                 SystemSetting.image_sizes[:small_sq].gsub(/(!|>|<)/, '').split('x').first.to_i : \
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for search_sorting_controls_for is too high. [35.58/15]
    Open

      def search_sorting_controls_for(sort_text, sort_type, main_sort_order = false, default_direction = 'asc', remote_link = false)
        # if searching, get the current sort direction else use the default order
        direction = (params[:order] == sort_type ? params[:direction] : nil) || default_direction
    
        # using the current sort direction, create the image we'll use display
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [29/10]
    Open

      def search_sorting_controls_for(sort_text, sort_type, main_sort_order = false, default_direction = 'asc', remote_link = false)
        # if searching, get the current sort direction else use the default order
        direction = (params[:order] == sort_type ? params[:direction] : nil) || default_direction
    
        # using the current sort direction, create the image we'll use display
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Perceived complexity for formatted_value_from_xml is too high. [26/7]
    Open

      def formatted_value_from_xml(value, ef = nil, item = nil)
        if ef && %w(autocomplete choice).member?(ef.ftype)
          base_url = ef.base_url
    
          # If the extended field type is a choice, then link the value to the search page for the EF.
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

    Method users_baskets_list has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

      def users_baskets_list(user = current_user, options = {})
        # if the user is the current user, use the basket_access_hash instead of fetching them again
        basket_permissions = user == current_user ? @basket_access_hash : user.basket_permissions
    
        row1 = 'user_basket_list_row1'
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 3 hrs to fix

    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

    Cyclomatic complexity for formatted_value_from_xml is too high. [23/6]
    Open

      def formatted_value_from_xml(value, ef = nil, item = nil)
        if ef && %w(autocomplete choice).member?(ef.ftype)
          base_url = ef.base_url
    
          # If the extended field type is a choice, then link the value to the search page for the EF.
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Assignment Branch Condition size for adding_or_editing_private_item? is too high. [32.89/15]
    Open

      def adding_or_editing_private_item?
        if @comment
          return params[:commentable_private].param_to_obj_equiv if params[:commentable_private]
          return params[:comment][:commentable_private].param_to_obj_equiv if params[:comment] && params[:comment][:commentable_private]
          @comment.private?
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for related_image_link_for is too high. [31.45/15]
    Open

      def related_image_link_for(still_image, options = {}, link_options = {})
        return '' if still_image.blank?
        options = { privacy_type: 'public' }.merge(options)
        if still_image.is_a?(StillImage)
          if !still_image.thumbnail_file.nil?
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for formatted_extended_content_value is too high. [29.85/15]
    Open

      def formatted_extended_content_value(field, field_name, value, item, mapping)
        # handle if the field is multiple
        values = []
        if field.multiple?
          values = value
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [24/10]
    Open

      def users_baskets_list(user = current_user, options = {})
        # if the user is the current user, use the basket_access_hash instead of fetching them again
        basket_permissions = user == current_user ? @basket_access_hash : user.basket_permissions
    
        row1 = 'user_basket_list_row1'
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method formatted_extended_content_value has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

      def formatted_extended_content_value(field, field_name, value, item, mapping)
        # handle if the field is multiple
        values = []
        if field.multiple?
          values = value
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 3 hrs to fix

    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 related_items_display_of has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      def related_items_display_of(items, options = {})
        return '' if items.blank?
        unless options[:display_num].nil?
          display_num = options[:display_num]
          items = [] if display_num.zero?
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 3 hrs to fix

    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

    Block has too many lines. [58/25]
    Open

        Basket.except_certain_baskets(@standard_baskets).all.each do |basket|
          basket_count += 1
          if basket == @current_basket
    
            html += li_with_correct_class(basket_count) + link_to_index_for(basket)
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

    Assignment Branch Condition size for topic_type_select_with_indent is too high. [27.39/15]
    Open

      def topic_type_select_with_indent(object, method, collection, value_method, text_method, current_value, html_options = {}, pre_options = [])
        result =
          if method
            "<select name=\"#{object}[#{method}]\" id=\"#{object}_#{method}\""
          else
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [22/10]
    Open

      def items_to_rebuild(item)
        # first entry is self
        items_to_rebuild = ["#{item.class.name}-#{item.id}"]
    
        # grab all zoom_classes for topics
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for locale_dropdown is too high. [27.15/15]
    Open

      def locale_dropdown(form = nil, options = nil)
        options ||= {}
        options[:default] ||=
          if params[:user]
            params[:user][:locale]
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [22/10]
    Open

      def link_to_members_of(basket, options = {})
        options = {
          viewable_text: t('application_helper.link_to_members_of.members_link_text'),
          unavailable_text: ''
        }.merge(options)
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for stylish_link_to_contributions_of is too high. [26.7/15]
    Open

      def stylish_link_to_contributions_of(user, zoom_class, options = {})
        options = { with_avatar: true }.merge(options)
        div_classes = (['stylish_user_contribution_link'] + options[:additional_classes].to_a).flatten.compact.join(' ')
        display_html = "<div class=\"#{div_classes}\">"
        if options[:with_avatar]
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for limit_search_to_choice_control is too high. [26.4/15]
    Open

      def limit_search_to_choice_control(clear_values = false)
        options_array = []
    
        if @extended_field
          options_array =
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for items_to_rebuild is too high. [26.1/15]
    Open

      def items_to_rebuild(item)
        # first entry is self
        items_to_rebuild = ["#{item.class.name}-#{item.id}"]
    
        # grab all zoom_classes for topics
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Perceived complexity for related_items_display_of is too high. [18/7]
    Open

      def related_items_display_of(items, options = {})
        return '' if items.blank?
        unless options[:display_num].nil?
          display_num = options[:display_num]
          items = [] if display_num.zero?
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

    Method link_to_membership_request_of has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      def link_to_membership_request_of(basket, options = {})
        return '' unless logged_in?
    
        options = {
          join_text: t('application_helper.link_to_membership_request_of.join'),
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 2 hrs to fix

    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

    Cyclomatic complexity for related_items_display_of is too high. [16/6]
    Open

      def related_items_display_of(items, options = {})
        return '' if items.blank?
        unless options[:display_num].nil?
          display_num = options[:display_num]
          items = [] if display_num.zero?
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Method has too many lines. [20/10]
    Open

      def limit_search_to_choice_control(clear_values = false)
        options_array = []
    
        if @extended_field
          options_array =
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method has too many lines. [20/10]
    Open

      def topic_type_select_with_indent(object, method, collection, value_method, text_method, current_value, html_options = {}, pre_options = [])
        result =
          if method
            "<select name=\"#{object}[#{method}]\" id=\"#{object}_#{method}\""
          else
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Perceived complexity for display_xml_attributes is too high. [16/7]
    Open

      def display_xml_attributes(item, options = {})
        raq = ' &raquo; '
        html = []
    
        mappings =
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

    Method has too many lines. [19/10]
    Open

      def pending_review(item)
        html_string = ''
        if item.disputed?
          html_string = "<h4>#{t('application_helper.pending_review.pending')} "
          privacy_type = item.respond_to?(:private) && item.private? ? 'private' : 'public'
    Severity: Minor
    Found in app/helpers/application_helper.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method formatted_value_from_xml has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def formatted_value_from_xml(value, ef = nil, item = nil)
        if ef && %w(autocomplete choice).member?(ef.ftype)
          base_url = ef.base_url
    
          # If the extended field type is a choice, then link the value to the search page for the EF.
    Severity: Major
    Found in app/helpers/application_helper.rb - About 2 hrs to fix

      Method show_comments_for has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def show_comments_for(item)
          html_string = "<p>#{t('application_helper.show_comments_for.comment_count', count: @comments.size)}</p><p>"
      
          unless @comments.empty?
            html_string += t('application_helper.show_comments_for.read_and')
      Severity: Major
      Found in app/helpers/application_helper.rb - About 2 hrs to fix

        Cyclomatic complexity for link_to_membership_request_of is too high. [14/6]
        Open

          def link_to_membership_request_of(basket, options = {})
            return '' unless logged_in?
        
            options = {
              join_text: t('application_helper.link_to_membership_request_of.join'),
        Severity: Minor
        Found in app/helpers/application_helper.rb by rubocop

        This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

        An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

        Perceived complexity for render_baskets_as_menu is too high. [15/7]
        Open

          def render_baskets_as_menu
            html = '<ul id="sub-menu" class="menu basket-list-menu">'
        
            basket_count = 0
            Basket.except_certain_baskets(@standard_baskets).all.each do |basket|
        Severity: Minor
        Found in app/helpers/application_helper.rb by rubocop

        This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

        Example:

        def my_method                   # 1
          if cond                       # 1
            case var                    # 2 (0.8 + 4 * 0.2, rounded)
            when 1 then func_one
            when 2 then func_two
            when 3 then func_three
            when 4..10 then func_other
            end
          else                          # 1
            do_something until a && b   # 2
          end                           # ===
        end                             # 7 complexity points

        Perceived complexity for search_sorting_controls_for is too high. [15/7]
        Open

          def search_sorting_controls_for(sort_text, sort_type, main_sort_order = false, default_direction = 'asc', remote_link = false)
            # if searching, get the current sort direction else use the default order
            direction = (params[:order] == sort_type ? params[:direction] : nil) || default_direction
        
            # using the current sort direction, create the image we'll use display
        Severity: Minor
        Found in app/helpers/application_helper.rb by rubocop

        This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

        Example:

        def my_method                   # 1
          if cond                       # 1
            case var                    # 2 (0.8 + 4 * 0.2, rounded)
            when 1 then func_one
            when 2 then func_two
            when 3 then func_three
            when 4..10 then func_other
            end
          else                          # 1
            do_something until a && b   # 2
          end                           # ===
        end                             # 7 complexity points

        Method has too many lines. [18/10]
        Open

          def locale_links(options = nil)
            options ||= {}
            options[:default] ||= (current_user != :false ? current_user.locale : I18n.locale)
            choices = ''
            I18n.available_locales_with_labels.each_with_index do |(key, value), index|
        Severity: Minor
        Found in app/helpers/application_helper.rb by rubocop

        This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

        Method render_baskets_as_menu has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def render_baskets_as_menu
            html = '<ul id="sub-menu" class="menu basket-list-menu">'
        
            basket_count = 0
            Basket.except_certain_baskets(@standard_baskets).all.each do |basket|
        Severity: Major
        Found in app/helpers/application_helper.rb - About 2 hrs to fix

          Cyclomatic complexity for display_xml_attributes is too high. [13/6]
          Open

            def display_xml_attributes(item, options = {})
              raq = ' &raquo; '
              html = []
          
              mappings =
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Cyclomatic complexity for users_baskets_list is too high. [13/6]
          Open

            def users_baskets_list(user = current_user, options = {})
              # if the user is the current user, use the basket_access_hash instead of fetching them again
              basket_permissions = user == current_user ? @basket_access_hash : user.basket_permissions
          
              row1 = 'user_basket_list_row1'
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Cyclomatic complexity for render_baskets_as_menu is too high. [13/6]
          Open

            def render_baskets_as_menu
              html = '<ul id="sub-menu" class="menu basket-list-menu">'
          
              basket_count = 0
              Basket.except_certain_baskets(@standard_baskets).all.each do |basket|
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Perceived complexity for adding_or_editing_private_item? is too high. [14/7]
          Open

            def adding_or_editing_private_item?
              if @comment
                return params[:commentable_private].param_to_obj_equiv if params[:commentable_private]
                return params[:comment][:commentable_private].param_to_obj_equiv if params[:comment] && params[:comment][:commentable_private]
                @comment.private?
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

          Example:

          def my_method                   # 1
            if cond                       # 1
              case var                    # 2 (0.8 + 4 * 0.2, rounded)
              when 1 then func_one
              when 2 then func_two
              when 3 then func_three
              when 4..10 then func_other
              end
            else                          # 1
              do_something until a && b   # 2
            end                           # ===
          end                             # 7 complexity points

          Method has too many lines. [17/10]
          Open

            def locale_dropdown(form = nil, options = nil)
              options ||= {}
              options[:default] ||=
                if params[:user]
                  params[:user][:locale]
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Perceived complexity for formatted_extended_content_value is too high. [14/7]
          Open

            def formatted_extended_content_value(field, field_name, value, item, mapping)
              # handle if the field is multiple
              values = []
              if field.multiple?
                values = value
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

          Example:

          def my_method                   # 1
            if cond                       # 1
              case var                    # 2 (0.8 + 4 * 0.2, rounded)
              when 1 then func_one
              when 2 then func_two
              when 3 then func_three
              when 4..10 then func_other
              end
            else                          # 1
              do_something until a && b   # 2
            end                           # ===
          end                             # 7 complexity points

          Method show_comments_for has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def show_comments_for(item)
              html_string = "<p>#{t('application_helper.show_comments_for.comment_count', count: @comments.size)}</p><p>"
          
              unless @comments.empty?
                html_string += t('application_helper.show_comments_for.read_and')
          Severity: Minor
          Found in app/helpers/application_helper.rb - About 2 hrs to fix

          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

          Cyclomatic complexity for adding_or_editing_private_item? is too high. [12/6]
          Open

            def adding_or_editing_private_item?
              if @comment
                return params[:commentable_private].param_to_obj_equiv if params[:commentable_private]
                return params[:comment][:commentable_private].param_to_obj_equiv if params[:comment] && params[:comment][:commentable_private]
                @comment.private?
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Cyclomatic complexity for search_sorting_controls_for is too high. [12/6]
          Open

            def search_sorting_controls_for(sort_text, sort_type, main_sort_order = false, default_direction = 'asc', remote_link = false)
              # if searching, get the current sort direction else use the default order
              direction = (params[:order] == sort_type ? params[:direction] : nil) || default_direction
          
              # using the current sort direction, create the image we'll use display
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Perceived complexity for link_to_membership_request_of is too high. [13/7]
          Open

            def link_to_membership_request_of(basket, options = {})
              return '' unless logged_in?
          
              options = {
                join_text: t('application_helper.link_to_membership_request_of.join'),
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

          Example:

          def my_method                   # 1
            if cond                       # 1
              case var                    # 2 (0.8 + 4 * 0.2, rounded)
              when 1 then func_one
              when 2 then func_two
              when 3 then func_three
              when 4..10 then func_other
              end
            else                          # 1
              do_something until a && b   # 2
            end                           # ===
          end                             # 7 complexity points

          Perceived complexity for users_baskets_list is too high. [13/7]
          Open

            def users_baskets_list(user = current_user, options = {})
              # if the user is the current user, use the basket_access_hash instead of fetching them again
              basket_permissions = user == current_user ? @basket_access_hash : user.basket_permissions
          
              row1 = 'user_basket_list_row1'
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

          Example:

          def my_method                   # 1
            if cond                       # 1
              case var                    # 2 (0.8 + 4 * 0.2, rounded)
              when 1 then func_one
              when 2 then func_two
              when 3 then func_three
              when 4..10 then func_other
              end
            else                          # 1
              do_something until a && b   # 2
            end                           # ===
          end                             # 7 complexity points

          Method has too many lines. [16/10]
          Open

            def link_to_contributions_of(user, zoom_class = 'Topic', options = {})
              display_html = ''
              if options[:with_avatar]
                display_html = avatar_for(user, class: 'user_contribution_link_avatar')
                display_html += h(user.user_name)
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Method browse_by_category_columns has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            def browse_by_category_columns
              # If not, return blank so nothing is displayed
              return '' if categories_field.nil? || !categories_field.is_a_choice?
          
              # Get the current choice from params (limit_to_choice is special because it also controls search results)
          Severity: Minor
          Found in app/helpers/application_helper.rb - About 2 hrs to fix

          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

          Assignment Branch Condition size for locale_links is too high. [20.78/15]
          Open

            def locale_links(options = nil)
              options ||= {}
              options[:default] ||= (current_user != :false ? current_user.locale : I18n.locale)
              choices = ''
              I18n.available_locales_with_labels.each_with_index do |(key, value), index|
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

          Method has too many lines. [15/10]
          Open

            def header_add_basket_link
              # ROB: we're not going to let people create baskets, so we hide the link.
              return
          
              return unless current_user_can_add_or_request_basket?
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Method has too many lines. [15/10]
          Open

            def header_add_links(options = {})
              return unless current_user_can_see_add_links?
              options = { link_text: t('application_helper.header_add_links.add_item') }.merge(options)
              link_text = options.delete(:link_text)
              li_class = options.delete(:class) || ''
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Method has too many lines. [15/10]
          Open

            def adding_or_editing_private_item?
              if @comment
                return params[:commentable_private].param_to_obj_equiv if params[:commentable_private]
                return params[:comment][:commentable_private].param_to_obj_equiv if params[:comment] && params[:comment][:commentable_private]
                @comment.private?
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Method has too many lines. [15/10]
          Open

            def overwritten_search_params
              {
                # set basic values for our search
                urlified_name: @current_basket.urlified_name,
                controller: 'search',
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Block has too many lines. [47/25]
          Open

                @comments.each do |comment|
                  comment_string = '<div class="comment-wrapper">'
                  comment_string += '<div class="comment-wrapper-header-wrapper"><div class="comment-wrapper-header"></div></div>'
                  comment_string += '<div class="comment-content">'
                  comment_string += "#{comment.description}\n" unless comment.description.blank?
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

          Assignment Branch Condition size for tag_cloud is too high. [19.42/15]
          Open

            def tag_cloud(tags, classes)
              max = 0
              min = 0
              tags.each do |t|
                t_count = t[:total_taggings_count].to_i
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

          Cyclomatic complexity for formatted_extended_content_value is too high. [10/6]
          Open

            def formatted_extended_content_value(field, field_name, value, item, mapping)
              # handle if the field is multiple
              values = []
              if field.multiple?
                values = value
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Cyclomatic complexity for avatar_for is too high. [10/6]
          Open

            def avatar_for(user, options = {})
              # New installs use strings for the small_sq value, but we have to handle legacy settings containing arrays
              image_dimension =
                SystemSetting.image_sizes[:small_sq].is_a?(String) ? \
                                       SystemSetting.image_sizes[:small_sq].gsub(/(!|>|<)/, '').split('x').first.to_i : \
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Assignment Branch Condition size for link_to_related_item_function is too high. [19.03/15]
          Open

            def link_to_related_item_function(options = {})
              options = { link_text: t(
                'application_helper.link_to_related_item_function.link_text',
                function: options[:function].capitalize
              ) }.merge(options)
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

          Method has too many lines. [14/10]
          Open

            def stylish_link_to_contributions_of(user, zoom_class, options = {})
              options = { with_avatar: true }.merge(options)
              div_classes = (['stylish_user_contribution_link'] + options[:additional_classes].to_a).flatten.compact.join(' ')
              display_html = "<div class=\"#{div_classes}\">"
              if options[:with_avatar]
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Method has too many lines. [14/10]
          Open

            def link_to_related_item_function(options = {})
              options = { link_text: t(
                'application_helper.link_to_related_item_function.link_text',
                function: options[:function].capitalize
              ) }.merge(options)
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Method has too many lines. [14/10]
          Open

            def link_to_preview_of(item, version, check_permission = true, options = {})
              # if we got sent a version object, we need to link to the latest version
              item = item.latest_version if item.class.name =~ /Version/
          
              version_number = 0
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Method has too many lines. [14/10]
          Open

            def dc_metadata_for(item)
              metadata = ''
          
              metadata += tag(:link, rel: 'schema.DCTERMS', href: 'http://purl.org/dc/terms/') + "\n"
              metadata += tag(:link, rel: 'schema.DC', href: 'http://purl.org/dc/elements/1.1/') + "\n"
          Severity: Minor
          Found in app/helpers/application_helper.rb by rubocop

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Method link_to_membership_request_of has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def link_to_membership_request_of(basket, options = {})
              return '' unless logged_in?
          
              options = {
                join_text: t('application_helper.link_to_membership_request_of.join'),
          Severity: Major
          Found in app/helpers/application_helper.rb - About 2 hrs to fix

            Cyclomatic complexity for browse_by_category_columns is too high. [9/6]
            Open

              def browse_by_category_columns
                # If not, return blank so nothing is displayed
                return '' if categories_field.nil? || !categories_field.is_a_choice?
            
                # Get the current choice from params (limit_to_choice is special because it also controls search results)
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

            An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

            Cyclomatic complexity for show_comments_for is too high. [9/6]
            Open

              def show_comments_for(item)
                html_string = "<p>#{t('application_helper.show_comments_for.comment_count', count: @comments.size)}</p><p>"
            
                unless @comments.empty?
                  html_string += t('application_helper.show_comments_for.read_and')
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

            An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

            Method has too many lines. [13/10]
            Open

              def related_items_count_for_current_item(item)
                @related_items_count_for_current_item ||=
                  begin
                       if item
                         item_id = item.id
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

            Perceived complexity for avatar_for is too high. [10/7]
            Open

              def avatar_for(user, options = {})
                # New installs use strings for the small_sq value, but we have to handle legacy settings containing arrays
                image_dimension =
                  SystemSetting.image_sizes[:small_sq].is_a?(String) ? \
                                         SystemSetting.image_sizes[:small_sq].gsub(/(!|>|<)/, '').split('x').first.to_i : \
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

            Example:

            def my_method                   # 1
              if cond                       # 1
                case var                    # 2 (0.8 + 4 * 0.2, rounded)
                when 1 then func_one
                when 2 then func_two
                when 3 then func_three
                when 4..10 then func_other
                end
              else                          # 1
                do_something until a && b   # 2
              end                           # ===
            end                             # 7 complexity points

            Method has too many lines. [13/10]
            Open

              def url_for_topics_of_type(topic_type, privacy = nil)
                privacy = 'private' if !params[:private].nil? && params[:private] == 'true'
            
                url_hash = {
                  urlified_name: @site_basket.urlified_name,
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

            Perceived complexity for browse_by_category_columns is too high. [10/7]
            Open

              def browse_by_category_columns
                # If not, return blank so nothing is displayed
                return '' if categories_field.nil? || !categories_field.is_a_choice?
            
                # Get the current choice from params (limit_to_choice is special because it also controls search results)
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

            Example:

            def my_method                   # 1
              if cond                       # 1
                case var                    # 2 (0.8 + 4 * 0.2, rounded)
                when 1 then func_one
                when 2 then func_two
                when 3 then func_three
                when 4..10 then func_other
                end
              else                          # 1
                do_something until a && b   # 2
              end                           # ===
            end                             # 7 complexity points

            Method has too many lines. [13/10]
            Open

              def kete_time_ago_in_words(from_time)
                string =
                  if from_time < Time.now - 1.week
                    t(
                      'application_helper.kete_time_ago_in_words.longer_than_a_week',
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

            Method avatar_for has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def avatar_for(user, options = {})
                # New installs use strings for the small_sq value, but we have to handle legacy settings containing arrays
                image_dimension =
                  SystemSetting.image_sizes[:small_sq].is_a?(String) ? \
                                         SystemSetting.image_sizes[:small_sq].gsub(/(!|>|<)/, '').split('x').first.to_i : \
            Severity: Minor
            Found in app/helpers/application_helper.rb - About 1 hr to fix

            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

            Assignment Branch Condition size for related_items_count_for_current_item is too high. [17.38/15]
            Open

              def related_items_count_for_current_item(item)
                @related_items_count_for_current_item ||=
                  begin
                       if item
                         item_id = item.id
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

            Assignment Branch Condition size for image_size_of is too high. [17.15/15]
            Open

              def image_size_of(string)
                return string.to_i if string.is_a? Numeric
                size =
                  SystemSetting.image_sizes[string.to_sym].is_a?(String) ? \
                              SystemSetting.image_sizes[string.to_sym].split('x').first : \
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

            Method has too many lines. [12/10]
            Open

              def calculate_comment_depth_for(comment)
                depth = 0
                parent_comment_id = comment.parent_id
                until parent_comment_id.blank?
                  depth += 1
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

            Method has too many lines. [12/10]
            Open

              def topic_types_counts_for(item)
                html = '<ul>'
                topics = item.is_a?(Topic) ? item.related_topics : item.topics
                topic_types_and_counts = topics.collection_of_objects_and_counts_for(:topic_type, true)
                topic_types_and_counts.each do |topic_type, count|
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

            Perceived complexity for related_image_link_for is too high. [9/7]
            Open

              def related_image_link_for(still_image, options = {}, link_options = {})
                return '' if still_image.blank?
                options = { privacy_type: 'public' }.merge(options)
                if still_image.is_a?(StillImage)
                  if !still_image.thumbnail_file.nil?
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

            Example:

            def my_method                   # 1
              if cond                       # 1
                case var                    # 2 (0.8 + 4 * 0.2, rounded)
                when 1 then func_one
                when 2 then func_two
                when 3 then func_three
                when 4..10 then func_other
                end
              else                          # 1
                do_something until a && b   # 2
              end                           # ===
            end                             # 7 complexity points

            Perceived complexity for show_comments_for is too high. [9/7]
            Open

              def show_comments_for(item)
                html_string = "<p>#{t('application_helper.show_comments_for.comment_count', count: @comments.size)}</p><p>"
            
                unless @comments.empty?
                  html_string += t('application_helper.show_comments_for.read_and')
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

            Example:

            def my_method                   # 1
              if cond                       # 1
                case var                    # 2 (0.8 + 4 * 0.2, rounded)
                when 1 then func_one
                when 2 then func_two
                when 3 then func_three
                when 4..10 then func_other
                end
              else                          # 1
                do_something until a && b   # 2
              end                           # ===
            end                             # 7 complexity points

            Assignment Branch Condition size for any_fields_editable? is too high. [17.2/15]
            Open

              def any_fields_editable?(form_type = @form_type)
                form_type = form_type.to_s
                return true if @site_admin
                return true if @basket.profiles.blank?
                profile_rules = @basket.profiles.first.rules(true)
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

            Method has too many lines. [12/10]
            Open

              def tag_cloud(tags, classes)
                max = 0
                min = 0
                tags.each do |t|
                  t_count = t[:total_taggings_count].to_i
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

            Assignment Branch Condition size for tags_for is too high. [16.76/15]
            Open

              def tags_for(item)
                html_string = ''
            
                return html_string if item.tags.blank?
            
            
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

            Cyclomatic complexity for limit_search_to_choice_control is too high. [7/6]
            Open

              def limit_search_to_choice_control(clear_values = false)
                options_array = []
            
                if @extended_field
                  options_array =
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

            An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

            Cyclomatic complexity for any_fields_editable? is too high. [7/6]
            Open

              def any_fields_editable?(form_type = @form_type)
                form_type = form_type.to_s
                return true if @site_admin
                return true if @basket.profiles.blank?
                profile_rules = @basket.profiles.first.rules(true)
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

            An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

            Cyclomatic complexity for class_and_styless_from is too high. [7/6]
            Open

              def class_and_styless_from(position = nil, count = nil)
                class_names = []
                styles = []
            
                class_names << position if position
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

            An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

            Method has too many lines. [11/10]
            Open

              def link_to_related_items_of(item, zoom_class, options = {}, location = {})
                options = {
                  link_text: t('application_helper.link_to_related_items_of.link_text', item_title: item.title)
                }.merge(options)
            
            
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

            Method has too many lines. [11/10]
            Open

              def tags_for(item)
                html_string = ''
            
                return html_string if item.tags.blank?
            
            
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

            Perceived complexity for limit_search_to_choice_control is too high. [8/7]
            Open

              def limit_search_to_choice_control(clear_values = false)
                options_array = []
            
                if @extended_field
                  options_array =
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

            Example:

            def my_method                   # 1
              if cond                       # 1
                case var                    # 2 (0.8 + 4 * 0.2, rounded)
                when 1 then func_one
                when 2 then func_two
                when 3 then func_three
                when 4..10 then func_other
                end
              else                          # 1
                do_something until a && b   # 2
              end                           # ===
            end                             # 7 complexity points

            Method has too many lines. [11/10]
            Open

              def link_to_last_stored_location
                if session[:return_to_title].blank?
                  link_to(t('application_helper.link_to_last_stored_location.back_to_kete_home'), '/')
                else
                  link_to(
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

            Perceived complexity for locale_dropdown is too high. [8/7]
            Open

              def locale_dropdown(form = nil, options = nil)
                options ||= {}
                options[:default] ||=
                  if params[:user]
                    params[:user][:locale]
            Severity: Minor
            Found in app/helpers/application_helper.rb by rubocop

            This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

            Example:

            def my_method                   # 1
              if cond                       # 1
                case var                    # 2 (0.8 + 4 * 0.2, rounded)
                when 1 then func_one
                when 2 then func_two
                when 3 then func_three
                when 4..10 then func_other
                end
              else                          # 1
                do_something until a && b   # 2
              end                           # ===
            end                             # 7 complexity points

            Method browse_by_category_columns has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def browse_by_category_columns
                # If not, return blank so nothing is displayed
                return '' if categories_field.nil? || !categories_field.is_a_choice?
            
                # Get the current choice from params (limit_to_choice is special because it also controls search results)
            Severity: Minor
            Found in app/helpers/application_helper.rb - About 1 hr to fix

              Method display_xml_attributes has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def display_xml_attributes(item, options = {})
                  raq = ' &raquo; '
                  html = []
              
                  mappings =
              Severity: Minor
              Found in app/helpers/application_helper.rb - About 1 hr to fix

                Method related_image_link_for has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                  def related_image_link_for(still_image, options = {}, link_options = {})
                    return '' if still_image.blank?
                    options = { privacy_type: 'public' }.merge(options)
                    if still_image.is_a?(StillImage)
                      if !still_image.thumbnail_file.nil?
                Severity: Minor
                Found in app/helpers/application_helper.rb - About 1 hr to fix

                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 search_sorting_controls_for has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                  def search_sorting_controls_for(sort_text, sort_type, main_sort_order = false, default_direction = 'asc', remote_link = false)
                    # if searching, get the current sort direction else use the default order
                    direction = (params[:order] == sort_type ? params[:direction] : nil) || default_direction
                
                    # using the current sort direction, create the image we'll use display
                Severity: Minor
                Found in app/helpers/application_helper.rb - About 1 hr to fix

                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 related_image_link_for has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def related_image_link_for(still_image, options = {}, link_options = {})
                    return '' if still_image.blank?
                    options = { privacy_type: 'public' }.merge(options)
                    if still_image.is_a?(StillImage)
                      if !still_image.thumbnail_file.nil?
                Severity: Minor
                Found in app/helpers/application_helper.rb - About 1 hr to fix

                  Method formatted_extended_content_value has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def formatted_extended_content_value(field, field_name, value, item, mapping)
                      # handle if the field is multiple
                      values = []
                      if field.multiple?
                        values = value
                  Severity: Minor
                  Found in app/helpers/application_helper.rb - About 1 hr to fix

                    Method locale_links has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def locale_links(options = nil)
                        options ||= {}
                        options[:default] ||= (current_user != :false ? current_user.locale : I18n.locale)
                        choices = ''
                        I18n.available_locales_with_labels.each_with_index do |(key, value), index|
                    Severity: Minor
                    Found in app/helpers/application_helper.rb - About 1 hr to fix

                    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 avatar_for has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def avatar_for(user, options = {})
                        # New installs use strings for the small_sq value, but we have to handle legacy settings containing arrays
                        image_dimension =
                          SystemSetting.image_sizes[:small_sq].is_a?(String) ? \
                                                 SystemSetting.image_sizes[:small_sq].gsub(/(!|>|<)/, '').split('x').first.to_i : \
                    Severity: Minor
                    Found in app/helpers/application_helper.rb - About 1 hr to fix

                      Method related_items_display_of has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def related_items_display_of(items, options = {})
                          return '' if items.blank?
                          unless options[:display_num].nil?
                            display_num = options[:display_num]
                            items = [] if display_num.zero?
                      Severity: Minor
                      Found in app/helpers/application_helper.rb - About 1 hr to fix

                        Method search_sorting_controls_for has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def search_sorting_controls_for(sort_text, sort_type, main_sort_order = false, default_direction = 'asc', remote_link = false)
                            # if searching, get the current sort direction else use the default order
                            direction = (params[:order] == sort_type ? params[:direction] : nil) || default_direction
                        
                            # using the current sort direction, create the image we'll use display
                        Severity: Minor
                        Found in app/helpers/application_helper.rb - About 1 hr to fix

                          Method adding_or_editing_private_item? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def adding_or_editing_private_item?
                              if @comment
                                return params[:commentable_private].param_to_obj_equiv if params[:commentable_private]
                                return params[:comment][:commentable_private].param_to_obj_equiv if params[:comment] && params[:comment][:commentable_private]
                                @comment.private?
                          Severity: Minor
                          Found in app/helpers/application_helper.rb - About 1 hr to fix

                          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 topic_type_select_with_indent has 8 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                            def topic_type_select_with_indent(object, method, collection, value_method, text_method, current_value, html_options = {}, pre_options = [])
                          Severity: Major
                          Found in app/helpers/application_helper.rb - About 1 hr to fix

                            Method topic_type_select_with_indent has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def topic_type_select_with_indent(object, method, collection, value_method, text_method, current_value, html_options = {}, pre_options = [])
                                result =
                                  if method
                                    "<select name=\"#{object}[#{method}]\" id=\"#{object}_#{method}\""
                                  else
                            Severity: Minor
                            Found in app/helpers/application_helper.rb - About 55 mins to fix

                            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 pending_review has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def pending_review(item)
                                html_string = ''
                                if item.disputed?
                                  html_string = "<h4>#{t('application_helper.pending_review.pending')} "
                                  privacy_type = item.respond_to?(:private) && item.private? ? 'private' : 'public'
                            Severity: Minor
                            Found in app/helpers/application_helper.rb - About 45 mins to fix

                            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 limit_search_to_choice_control has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def limit_search_to_choice_control(clear_values = false)
                                options_array = []
                            
                                if @extended_field
                                  options_array =
                            Severity: Minor
                            Found in app/helpers/application_helper.rb - About 45 mins to fix

                            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 locale_dropdown has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def locale_dropdown(form = nil, options = nil)
                                options ||= {}
                                options[:default] ||=
                                  if params[:user]
                                    params[:user][:locale]
                            Severity: Minor
                            Found in app/helpers/application_helper.rb - About 45 mins to fix

                            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

                            Block has too many lines. [30/25]
                            Open

                                parent_choices.size.times do |time|
                                  # pop the first parent off the end of the parent_choices array
                                  current_choice = parent_choices.shift
                            
                                  choices =
                            Severity: Minor
                            Found in app/helpers/application_helper.rb by rubocop

                            This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

                            Consider simplifying this complex logical expression.
                            Open

                                if (params[:order] && params[:order] == sort_type && sort_type != 'random') || (!params[:order] && main_sort_order && sort_type != 'random')
                                  # flip the current direction so clicking the link reverses direction
                                  location_hash[:direction] = sort_direction_after(direction)
                                  link_to_text = "#{sort_text} #{direction_image}"
                                else
                            Severity: Major
                            Found in app/helpers/application_helper.rb - About 40 mins to fix

                              Method formatted_extended_content_value has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                def formatted_extended_content_value(field, field_name, value, item, mapping)
                              Severity: Minor
                              Found in app/helpers/application_helper.rb - About 35 mins to fix

                                Method search_sorting_controls_for has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                  def search_sorting_controls_for(sort_text, sort_type, main_sort_order = false, default_direction = 'asc', remote_link = false)
                                Severity: Minor
                                Found in app/helpers/application_helper.rb - About 35 mins to fix

                                  Method link_to_related_item_function has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    def link_to_related_item_function(options = {})
                                      options = { link_text: t(
                                        'application_helper.link_to_related_item_function.link_text',
                                        function: options[:function].capitalize
                                      ) }.merge(options)
                                  Severity: Minor
                                  Found in app/helpers/application_helper.rb - About 35 mins to fix

                                  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

                                  Avoid parameter lists longer than 5 parameters. [8/5]
                                  Open

                                    def topic_type_select_with_indent(object, method, collection, value_method, text_method, current_value, html_options = {}, pre_options = [])
                                  Severity: Minor
                                  Found in app/helpers/application_helper.rb by rubocop

                                  This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.

                                  Avoid too many return statements within this method.
                                  Open

                                      return false if profile_rules[form_type]['rule_type'] == 'none'
                                  Severity: Major
                                  Found in app/helpers/application_helper.rb - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                          return avatar_tag(user, avatar_options, options)
                                    Severity: Major
                                    Found in app/helpers/application_helper.rb - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                          return false if profile_rules[form_type]['allowed'].blank?
                                      Severity: Major
                                      Found in app/helpers/application_helper.rb - About 30 mins to fix

                                        Method stylish_link_to_contributions_of has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                          def stylish_link_to_contributions_of(user, zoom_class, options = {})
                                            options = { with_avatar: true }.merge(options)
                                            div_classes = (['stylish_user_contribution_link'] + options[:additional_classes].to_a).flatten.compact.join(' ')
                                            display_html = "<div class=\"#{div_classes}\">"
                                            if options[:with_avatar]
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb - About 25 mins to fix

                                        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 items_to_rebuild has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                          def items_to_rebuild(item)
                                            # first entry is self
                                            items_to_rebuild = ["#{item.class.name}-#{item.id}"]
                                        
                                            # grab all zoom_classes for topics
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb - About 25 mins to fix

                                        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 any_fields_editable? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                          def any_fields_editable?(form_type = @form_type)
                                            form_type = form_type.to_s
                                            return true if @site_admin
                                            return true if @basket.profiles.blank?
                                            profile_rules = @basket.profiles.first.rules(true)
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb - About 25 mins to fix

                                        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

                                        Block has too many lines. [26/25]
                                        Open

                                            mappings.each do |mapping|
                                              unless options[:embedded_only].nil?
                                                if options[:embedded_only]
                                                  next unless mapping.embedded?
                                                else
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

                                        TODO found
                                        Open

                                          # TODO: may want to replace this with better history plugin
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by fixme

                                        TODO found
                                        Open

                                                # TODO: look into how best to present multiple maps
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by fixme

                                        TODO found
                                        Open

                                            # TODO: replace with better icon
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by fixme

                                        Place the condition on the same line as elsif.
                                        Open

                                                html_string += t(
                                                  'application_helper.pending_review.no_safe_version',
                                                  privacy_type: privacy_type
                                                )
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for conditions that are not on the same line as if/while/until.

                                        Example:

                                        # bad
                                        
                                        if
                                          some_condition
                                          do_something
                                        end

                                        Example:

                                        # good
                                        
                                        if some_condition
                                          do_something
                                        end

                                        end at 401, 31 is not aligned with if at 397, 6.
                                        Open

                                                                       end
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks whether the end keywords are aligned properly.

                                        Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

                                        If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

                                        If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

                                        If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

                                        Example: EnforcedStyleAlignWith: keyword (default)

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                                   end

                                        Example: EnforcedStyleAlignWith: variable

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                        end

                                        Example: EnforcedStyleAlignWith: startofline

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        puts(if true
                                        end)

                                        Useless assignment to variable - return_value.
                                        Open

                                            return_value = can_see_discussion
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

                                        assigned but unused variable - foo

                                        Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

                                        Example:

                                        # bad
                                        
                                        def some_method
                                          some_var = 1
                                          do_something
                                        end

                                        Example:

                                        # good
                                        
                                        def some_method
                                          some_var = 1
                                          do_something(some_var)
                                        end

                                        Operator == used in void context.
                                        Open

                                              direction == 'asc' # if direction is something else, we set it right here
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for operators, variables and literals used in void context.

                                        Example:

                                        # bad
                                        
                                        def some_method
                                          some_num * 10
                                          do_something
                                        end

                                        Example:

                                        # bad
                                        
                                        def some_method(some_var)
                                          some_var
                                          do_something
                                        end

                                        Example:

                                        # good
                                        
                                        def some_method
                                          do_something
                                          some_num * 10
                                        end

                                        Example:

                                        # good
                                        
                                        def some_method(some_var)
                                          do_something
                                          some_var
                                        end

                                        end at 411, 30 is not aligned with if at 407, 6.
                                        Open

                                                                      end
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks whether the end keywords are aligned properly.

                                        Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

                                        If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

                                        If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

                                        If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

                                        Example: EnforcedStyleAlignWith: keyword (default)

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                                   end

                                        Example: EnforcedStyleAlignWith: variable

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                        end

                                        Example: EnforcedStyleAlignWith: startofline

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        puts(if true
                                        end)

                                        Symbol with a boolean name - you probably meant to use false.
                                        Open

                                              elsif current_user != :false
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for :true and :false symbols. In most cases it would be a typo.

                                        Example:

                                        # bad
                                        :true
                                        
                                        # good
                                        true

                                        Example:

                                        # bad
                                        :false
                                        
                                        # good
                                        false

                                        end at 333, 25 is not aligned with case at 318, 10.
                                        Open

                                                                 end
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks whether the end keywords are aligned properly.

                                        Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

                                        If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

                                        If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

                                        If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

                                        Example: EnforcedStyleAlignWith: keyword (default)

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                                   end

                                        Example: EnforcedStyleAlignWith: variable

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                        end

                                        Example: EnforcedStyleAlignWith: startofline

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        puts(if true
                                        end)

                                        end at 1707, 31 is not aligned with if at 1701, 6.
                                        Open

                                                                       end
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks whether the end keywords are aligned properly.

                                        Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

                                        If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

                                        If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

                                        If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

                                        Example: EnforcedStyleAlignWith: keyword (default)

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                                   end

                                        Example: EnforcedStyleAlignWith: variable

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                        end

                                        Example: EnforcedStyleAlignWith: startofline

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        puts(if true
                                        end)

                                        end at 390, 29 is not aligned with if at 386, 6.
                                        Open

                                                                     end
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks whether the end keywords are aligned properly.

                                        Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

                                        If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

                                        If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

                                        If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

                                        Example: EnforcedStyleAlignWith: keyword (default)

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                                   end

                                        Example: EnforcedStyleAlignWith: variable

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                        end

                                        Example: EnforcedStyleAlignWith: startofline

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        puts(if true
                                        end)

                                        end at 806, 29 is not aligned with if at 798, 8.
                                        Open

                                                                     end
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks whether the end keywords are aligned properly.

                                        Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

                                        If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

                                        If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

                                        If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

                                        Example: EnforcedStyleAlignWith: keyword (default)

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                                   end

                                        Example: EnforcedStyleAlignWith: variable

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                        end

                                        Example: EnforcedStyleAlignWith: startofline

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        puts(if true
                                        end)

                                        end at 1641, 23 is not aligned with if at 1637, 8.
                                        Open

                                                               end
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks whether the end keywords are aligned properly.

                                        Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

                                        If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

                                        If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

                                        If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

                                        Example: EnforcedStyleAlignWith: keyword (default)

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                                   end

                                        Example: EnforcedStyleAlignWith: variable

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                        end

                                        Example: EnforcedStyleAlignWith: startofline

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        puts(if true
                                        end)

                                        Symbol with a boolean name - you probably meant to use false.
                                        Open

                                            options[:default] ||= (current_user != :false ? current_user.locale : I18n.locale)
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for :true and :false symbols. In most cases it would be a typo.

                                        Example:

                                        # bad
                                        :true
                                        
                                        # good
                                        true

                                        Example:

                                        # bad
                                        :false
                                        
                                        # good
                                        false

                                        end at 342, 25 is not aligned with if at 336, 10.
                                        Open

                                                                 end
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks whether the end keywords are aligned properly.

                                        Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

                                        If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

                                        If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

                                        If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

                                        Example: EnforcedStyleAlignWith: keyword (default)

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                                   end

                                        Example: EnforcedStyleAlignWith: variable

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                        end

                                        Example: EnforcedStyleAlignWith: startofline

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        puts(if true
                                        end)

                                        end at 1581, 18 is not aligned with if at 1571, 6.
                                        Open

                                                          end
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks whether the end keywords are aligned properly.

                                        Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

                                        If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

                                        If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

                                        If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

                                        Example: EnforcedStyleAlignWith: keyword (default)

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                                   end

                                        Example: EnforcedStyleAlignWith: variable

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                        end

                                        Example: EnforcedStyleAlignWith: startofline

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        puts(if true
                                        end)

                                        end at 1444, 18 is not aligned with if at 1440, 6.
                                        Open

                                                          end
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks whether the end keywords are aligned properly.

                                        Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

                                        If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

                                        If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

                                        If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

                                        Example: EnforcedStyleAlignWith: keyword (default)

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                                   end

                                        Example: EnforcedStyleAlignWith: variable

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                        end

                                        Example: EnforcedStyleAlignWith: startofline

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        puts(if true
                                        end)

                                        Useless assignment to variable - raq.
                                        Open

                                            raq = ' &raquo; '
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

                                        assigned but unused variable - foo

                                        Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

                                        Example:

                                        # bad
                                        
                                        def some_method
                                          some_var = 1
                                          do_something
                                        end

                                        Example:

                                        # good
                                        
                                        def some_method
                                          some_var = 1
                                          do_something(some_var)
                                        end

                                        end at 290, 23 is not aligned with if at 286, 6.
                                        Open

                                                               end
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks whether the end keywords are aligned properly.

                                        Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

                                        If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

                                        If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

                                        If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

                                        Example: EnforcedStyleAlignWith: keyword (default)

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                                   end

                                        Example: EnforcedStyleAlignWith: variable

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                        end

                                        Example: EnforcedStyleAlignWith: startofline

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        puts(if true
                                        end)

                                        Unreachable code detected.
                                        Open

                                            return unless current_user_can_add_or_request_basket?
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for unreachable code. The check are based on the presence of flow of control statement in non-final position in begin(implicit) blocks.

                                        Example:

                                        # bad
                                        
                                        def some_method
                                          return
                                          do_something
                                        end
                                        
                                        # bad
                                        
                                        def some_method
                                          if cond
                                            return
                                          else
                                            return
                                          end
                                          do_something
                                        end

                                        Example:

                                        # good
                                        
                                        def some_method
                                          do_something
                                        end

                                        Useless assignment to variable - html.
                                        Open

                                              html += link_to_index_for(@current_basket, class: 'basket', tabindex: '2')
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

                                        assigned but unused variable - foo

                                        Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

                                        Example:

                                        # bad
                                        
                                        def some_method
                                          some_var = 1
                                          do_something
                                        end

                                        Example:

                                        # good
                                        
                                        def some_method
                                          some_var = 1
                                          do_something(some_var)
                                        end

                                        Useless assignment to variable - html. Use + instead of +=.
                                        Open

                                            html += '</li>'
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

                                        assigned but unused variable - foo

                                        Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

                                        Example:

                                        # bad
                                        
                                        def some_method
                                          some_var = 1
                                          do_something
                                        end

                                        Example:

                                        # good
                                        
                                        def some_method
                                          some_var = 1
                                          do_something(some_var)
                                        end

                                        end at 998, 20 is not aligned with if at 994, 6.
                                        Open

                                                            end
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks whether the end keywords are aligned properly.

                                        Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

                                        If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

                                        If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

                                        If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

                                        Example: EnforcedStyleAlignWith: keyword (default)

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                                   end

                                        Example: EnforcedStyleAlignWith: variable

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        variable = if true
                                        end

                                        Example: EnforcedStyleAlignWith: startofline

                                        # bad
                                        
                                        variable = if true
                                            end
                                        
                                        # good
                                        
                                        puts(if true
                                        end)

                                        Convert if nested inside else to elsif.
                                        Open

                                              if @item_type && params[@item_type] && params[@item_type][:private]
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        If the else branch of a conditional consists solely of an if node, it can be combined with the else to become an elsif. This helps to keep the nesting level from getting too deep.

                                        Example:

                                        # bad
                                        if condition_a
                                          action_a
                                        else
                                          if condition_b
                                            action_b
                                          else
                                            action_c
                                          end
                                        end
                                        
                                        # good
                                        if condition_a
                                          action_a
                                        elsif condition_b
                                          action_b
                                        else
                                          action_c
                                        end

                                        Use %r around regular expression.
                                        Open

                                                when /^(.+)\((\w{3,9}:\/\/.+)\)$/
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop enforces using // or %r around regular expressions.

                                        Example: EnforcedStyle: slashes (default)

                                        # bad
                                        snake_case = %r{^[\dA-Z_]+$}
                                        
                                        # bad
                                        regex = %r{
                                          foo
                                          (bar)
                                          (baz)
                                        }x
                                        
                                        # good
                                        snake_case = /^[\dA-Z_]+$/
                                        
                                        # good
                                        regex = /
                                          foo
                                          (bar)
                                          (baz)
                                        /x

                                        Example: EnforcedStyle: percent_r

                                        # bad
                                        snake_case = /^[\dA-Z_]+$/
                                        
                                        # bad
                                        regex = /
                                          foo
                                          (bar)
                                          (baz)
                                        /x
                                        
                                        # good
                                        snake_case = %r{^[\dA-Z_]+$}
                                        
                                        # good
                                        regex = %r{
                                          foo
                                          (bar)
                                          (baz)
                                        }x

                                        Example: EnforcedStyle: mixed

                                        # bad
                                        snake_case = %r{^[\dA-Z_]+$}
                                        
                                        # bad
                                        regex = /
                                          foo
                                          (bar)
                                          (baz)
                                        /x
                                        
                                        # good
                                        snake_case = /^[\dA-Z_]+$/
                                        
                                        # good
                                        regex = %r{
                                          foo
                                          (bar)
                                          (baz)
                                        }x

                                        Example: AllowInnerSlashes: false (default)

                                        # If `false`, the cop will always recommend using `%r` if one or more
                                        # slashes are found in the regexp string.
                                        
                                        # bad
                                        x =~ /home\//
                                        
                                        # good
                                        x =~ %r{home/}

                                        Example: AllowInnerSlashes: true

                                        # good
                                        x =~ /home\//

                                        Use safe navigation (&.) instead of checking if an object exists before calling the method.
                                        Open

                                            class_names << 'no-items' if count && count.zero? && params[:controller] != 'topics'
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop transforms usages of a method call safeguarded by a non nil check for the variable whose method is being called to safe navigation (&.).

                                        Configuration option: ConvertCodeThatCanStartToReturnNil The default for this is false. When configured to true, this will check for code in the format !foo.nil? && foo.bar. As it is written, the return of this code is limited to false and whatever the return of the method is. If this is converted to safe navigation, foo&.bar can start returning nil as well as what the method returns.

                                        Example:

                                        # bad
                                        foo.bar if foo
                                        foo.bar(param1, param2) if foo
                                        foo.bar { |e| e.something } if foo
                                        foo.bar(param) { |e| e.something } if foo
                                        
                                        foo.bar if !foo.nil?
                                        foo.bar unless !foo
                                        foo.bar unless foo.nil?
                                        
                                        foo && foo.bar
                                        foo && foo.bar(param1, param2)
                                        foo && foo.bar { |e| e.something }
                                        foo && foo.bar(param) { |e| e.something }
                                        
                                        # good
                                        foo&.bar
                                        foo&.bar(param1, param2)
                                        foo&.bar { |e| e.something }
                                        foo&.bar(param) { |e| e.something }
                                        
                                        foo.nil? || foo.bar
                                        !foo || foo.bar
                                        
                                        # Methods that `nil` will `respond_to?` should not be converted to
                                        # use safe navigation
                                        foo.to_i if foo

                                        Use the return of the conditional for variable assignment and comparison.
                                        Open

                                                if related_item.is_a?(Hash) && !related_item[:thumbnail].blank?
                                                  display_html += "<li class='#{li_class}'>#{related_image_link_for(related_item, options)}</li>"
                                                else
                                                  display_html += "<li class='#{li_class}'>#{link_to(related_item[:title], related_item[:url])}</li>"
                                                end
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        Prefer each over for.
                                        Open

                                                for topic in basket.topics.order(order).limit(limit).all.reject(&:disputed_or_not_available?)
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop looks for uses of the for keyword, or each method. The preferred alternative is set in the EnforcedStyle configuration parameter. An each call with a block on a single line is always allowed, however.

                                        Use a guard clause instead of wrapping the code inside a conditional expression.
                                        Open

                                            unless html.empty?
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        Use a guard clause instead of wrapping the code inside a conditional expression

                                        Example:

                                        # bad
                                        def test
                                          if something
                                            work
                                          end
                                        end
                                        
                                        # good
                                        def test
                                          return unless something
                                          work
                                        end
                                        
                                        # also good
                                        def test
                                          work if something
                                        end
                                        
                                        # bad
                                        if something
                                          raise 'exception'
                                        else
                                          ok
                                        end
                                        
                                        # good
                                        raise 'exception' if something
                                        ok

                                        Move html += li_with_correct_class(basket_count) + link_to_index_for(basket) out of the conditional.
                                        Open

                                                html += li_with_correct_class(basket_count) + link_to_index_for(basket)
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for identical lines at the beginning or end of each branch of a conditional statement.

                                        Example:

                                        # bad
                                        if condition
                                          do_x
                                          do_z
                                        else
                                          do_y
                                          do_z
                                        end
                                        
                                        # good
                                        if condition
                                          do_x
                                        else
                                          do_y
                                        end
                                        do_z
                                        
                                        # bad
                                        if condition
                                          do_z
                                          do_x
                                        else
                                          do_z
                                          do_y
                                        end
                                        
                                        # good
                                        do_z
                                        if condition
                                          do_x
                                        else
                                          do_y
                                        end
                                        
                                        # bad
                                        case foo
                                        when 1
                                          do_x
                                        when 2
                                          do_x
                                        else
                                          do_x
                                        end
                                        
                                        # good
                                        case foo
                                        when 1
                                          do_x
                                          do_y
                                        when 2
                                          # nothing
                                        else
                                          do_x
                                          do_z
                                        end

                                        Avoid multi-line ternary operators, use if or unless instead.
                                        Open

                                                  still_image.already_at_blank_version? ? '/images/pending.jpg' :
                                                                                                                   still_image.thumbnail_file.public_filename
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for multi-line ternary op expressions.

                                        Example:

                                        # bad
                                        a = cond ?
                                          b : c
                                        a = cond ? b :
                                            c
                                        a = cond ?
                                            b :
                                            c
                                        
                                        # good
                                        a = cond ? b : c
                                        a =
                                          if cond
                                            b
                                          else
                                            c
                                          end

                                        Use meaningful heredoc delimiters.
                                        Open

                                            EOT
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks that your heredocs are using meaningful delimiters. By default it disallows END and EO*, and can be configured through blacklisting additional delimiters.

                                        Example:

                                        # good
                                        <<-SQL
                                          SELECT * FROM foo
                                        SQL
                                        
                                        # bad
                                        <<-END
                                          SELECT * FROM foo
                                        END
                                        
                                        # bad
                                        <<-EOS
                                          SELECT * FROM foo
                                        EOS

                                        Use %r around regular expression.
                                        Open

                                                when /^\w+:\/\/[^ ]+/
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop enforces using // or %r around regular expressions.

                                        Example: EnforcedStyle: slashes (default)

                                        # bad
                                        snake_case = %r{^[\dA-Z_]+$}
                                        
                                        # bad
                                        regex = %r{
                                          foo
                                          (bar)
                                          (baz)
                                        }x
                                        
                                        # good
                                        snake_case = /^[\dA-Z_]+$/
                                        
                                        # good
                                        regex = /
                                          foo
                                          (bar)
                                          (baz)
                                        /x

                                        Example: EnforcedStyle: percent_r

                                        # bad
                                        snake_case = /^[\dA-Z_]+$/
                                        
                                        # bad
                                        regex = /
                                          foo
                                          (bar)
                                          (baz)
                                        /x
                                        
                                        # good
                                        snake_case = %r{^[\dA-Z_]+$}
                                        
                                        # good
                                        regex = %r{
                                          foo
                                          (bar)
                                          (baz)
                                        }x

                                        Example: EnforcedStyle: mixed

                                        # bad
                                        snake_case = %r{^[\dA-Z_]+$}
                                        
                                        # bad
                                        regex = /
                                          foo
                                          (bar)
                                          (baz)
                                        /x
                                        
                                        # good
                                        snake_case = /^[\dA-Z_]+$/
                                        
                                        # good
                                        regex = %r{
                                          foo
                                          (bar)
                                          (baz)
                                        }x

                                        Example: AllowInnerSlashes: false (default)

                                        # If `false`, the cop will always recommend using `%r` if one or more
                                        # slashes are found in the regexp string.
                                        
                                        # bad
                                        x =~ /home\//
                                        
                                        # good
                                        x =~ %r{home/}

                                        Example: AllowInnerSlashes: true

                                        # good
                                        x =~ /home\//

                                        %w-literals should be delimited by [ and ].
                                        Open

                                              if %w(map map_address).include?(field.ftype)
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop enforces the consistent usage of %-literal delimiters.

                                        Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

                                        Example:

                                        # Style/PercentLiteralDelimiters:
                                        #   PreferredDelimiters:
                                        #     default: '[]'
                                        #     '%i':    '()'
                                        
                                        # good
                                        %w[alpha beta] + %i(gamma delta)
                                        
                                        # bad
                                        %W(alpha #{beta})
                                        
                                        # bad
                                        %I(alpha beta)

                                        Prefer each over for.
                                        Open

                                            for element in collection
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop looks for uses of the for keyword, or each method. The preferred alternative is set in the EnforcedStyle configuration parameter. An each call with a block on a single line is always allowed, however.

                                        Use basket_topic_count.positive? instead of basket_topic_count > 0.
                                        Open

                                                if basket.topics.count > basket_topic_count && basket_topic_count > 0
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

                                        The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

                                        The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

                                        Example: EnforcedStyle: predicate (default)

                                        # bad
                                        
                                        foo == 0
                                        0 > foo
                                        bar.baz > 0
                                        
                                        # good
                                        
                                        foo.zero?
                                        foo.negative?
                                        bar.baz.positive?

                                        Example: EnforcedStyle: comparison

                                        # bad
                                        
                                        foo.zero?
                                        foo.negative?
                                        bar.baz.positive?
                                        
                                        # good
                                        
                                        foo == 0
                                        0 > foo
                                        bar.baz > 0

                                        Use display_num.positive? instead of display_num > 0.
                                        Open

                                              items = items[0..(display_num - 1)] if display_num > 0
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

                                        The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

                                        The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

                                        Example: EnforcedStyle: predicate (default)

                                        # bad
                                        
                                        foo == 0
                                        0 > foo
                                        bar.baz > 0
                                        
                                        # good
                                        
                                        foo.zero?
                                        foo.negative?
                                        bar.baz.positive?

                                        Example: EnforcedStyle: comparison

                                        # bad
                                        
                                        foo.zero?
                                        foo.negative?
                                        bar.baz.positive?
                                        
                                        # good
                                        
                                        foo == 0
                                        0 > foo
                                        bar.baz > 0

                                        Move html += li_with_correct_class(basket_count) + link_to_index_for(basket) out of the conditional.
                                        Open

                                                html += li_with_correct_class(basket_count) + link_to_index_for(basket)
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for identical lines at the beginning or end of each branch of a conditional statement.

                                        Example:

                                        # bad
                                        if condition
                                          do_x
                                          do_z
                                        else
                                          do_y
                                          do_z
                                        end
                                        
                                        # good
                                        if condition
                                          do_x
                                        else
                                          do_y
                                        end
                                        do_z
                                        
                                        # bad
                                        if condition
                                          do_z
                                          do_x
                                        else
                                          do_z
                                          do_y
                                        end
                                        
                                        # good
                                        do_z
                                        if condition
                                          do_x
                                        else
                                          do_y
                                        end
                                        
                                        # bad
                                        case foo
                                        when 1
                                          do_x
                                        when 2
                                          do_x
                                        else
                                          do_x
                                        end
                                        
                                        # good
                                        case foo
                                        when 1
                                          do_x
                                          do_y
                                        when 2
                                          # nothing
                                        else
                                          do_x
                                          do_z
                                        end

                                        Convert if nested inside else to elsif.
                                        Open

                                                  next if mapping.embedded?
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        If the else branch of a conditional consists solely of an if node, it can be combined with the else to become an elsif. This helps to keep the nesting level from getting too deep.

                                        Example:

                                        # bad
                                        if condition_a
                                          action_a
                                        else
                                          if condition_b
                                            action_b
                                          else
                                            action_c
                                          end
                                        end
                                        
                                        # good
                                        if condition_a
                                          action_a
                                        elsif condition_b
                                          action_b
                                        else
                                          action_c
                                        end

                                        Avoid rescuing without specifying an error class.
                                        Open

                                                             rescue
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for rescuing StandardError. There are two supported styles implicit and explicit. This cop will not register an offense if any error other than StandardError is specified.

                                        Example: EnforcedStyle: implicit

                                        # `implicit` will enforce using `rescue` instead of
                                        # `rescue StandardError`.
                                        
                                        # bad
                                        begin
                                          foo
                                        rescue StandardError
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue OtherError
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue StandardError, SecurityError
                                          bar
                                        end

                                        Example: EnforcedStyle: explicit (default)

                                        # `explicit` will enforce using `rescue StandardError`
                                        # instead of `rescue`.
                                        
                                        # bad
                                        begin
                                          foo
                                        rescue
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue StandardError
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue OtherError
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue StandardError, SecurityError
                                          bar
                                        end

                                        Use a guard clause instead of wrapping the code inside a conditional expression.
                                        Open

                                            if @current_basket != @site_basket
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        Use a guard clause instead of wrapping the code inside a conditional expression

                                        Example:

                                        # bad
                                        def test
                                          if something
                                            work
                                          end
                                        end
                                        
                                        # good
                                        def test
                                          return unless something
                                          work
                                        end
                                        
                                        # also good
                                        def test
                                          work if something
                                        end
                                        
                                        # bad
                                        if something
                                          raise 'exception'
                                        else
                                          ok
                                        end
                                        
                                        # good
                                        raise 'exception' if something
                                        ok

                                        Avoid comparing a variable with multiple items in a conditional, use Array#include? instead.
                                        Open

                                              name = basket == @site_basket || basket == @about_basket ? SystemSetting.pretty_site_name : basket.name
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks against comparing a variable with multiple items, where Array#include? could be used instead to avoid code repetition.

                                        Example:

                                        # bad
                                        a = 'a'
                                        foo if a == 'a' || a == 'b' || a == 'c'
                                        
                                        # good
                                        a = 'a'
                                        foo if ['a', 'b', 'c'].include?(a)

                                        Use safe navigation (&.) instead of checking if an object exists before calling the method.
                                        Open

                                                  if ef && ef.dont_link_choice_values?
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop transforms usages of a method call safeguarded by a non nil check for the variable whose method is being called to safe navigation (&.).

                                        Configuration option: ConvertCodeThatCanStartToReturnNil The default for this is false. When configured to true, this will check for code in the format !foo.nil? && foo.bar. As it is written, the return of this code is limited to false and whatever the return of the method is. If this is converted to safe navigation, foo&.bar can start returning nil as well as what the method returns.

                                        Example:

                                        # bad
                                        foo.bar if foo
                                        foo.bar(param1, param2) if foo
                                        foo.bar { |e| e.something } if foo
                                        foo.bar(param) { |e| e.something } if foo
                                        
                                        foo.bar if !foo.nil?
                                        foo.bar unless !foo
                                        foo.bar unless foo.nil?
                                        
                                        foo && foo.bar
                                        foo && foo.bar(param1, param2)
                                        foo && foo.bar { |e| e.something }
                                        foo && foo.bar(param) { |e| e.something }
                                        
                                        # good
                                        foo&.bar
                                        foo&.bar(param1, param2)
                                        foo&.bar { |e| e.something }
                                        foo&.bar(param) { |e| e.something }
                                        
                                        foo.nil? || foo.bar
                                        !foo || foo.bar
                                        
                                        # Methods that `nil` will `respond_to?` should not be converted to
                                        # use safe navigation
                                        foo.to_i if foo

                                        Use the return of the conditional for variable assignment and comparison.
                                        Open

                                            if session[:return_to].blank?
                                              html += link_to(t('application_helper.link_to_cancel.cancel'), action: 'list', tabindex: '1')
                                            else
                                              html += link_to(t('application_helper.link_to_cancel.cancel'), url_for(session[:return_to]), tabindex: '1')
                                            end
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        Avoid multi-line ternary operators, use if or unless instead.
                                        Open

                                              SystemSetting.image_sizes[string.to_sym].is_a?(String) ? \
                                                          SystemSetting.image_sizes[string.to_sym].split('x').first : \
                                                          SystemSetting.image_sizes[string.to_sym].first
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for multi-line ternary op expressions.

                                        Example:

                                        # bad
                                        a = cond ?
                                          b : c
                                        a = cond ? b :
                                            c
                                        a = cond ?
                                            b :
                                            c
                                        
                                        # good
                                        a = cond ? b : c
                                        a =
                                          if cond
                                            b
                                          else
                                            c
                                          end

                                        %w-literals should be delimited by [ and ].
                                        Open

                                              unless base_url.blank? || %w(map map_address choice autocomplete).include?(field.ftype)
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop enforces the consistent usage of %-literal delimiters.

                                        Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

                                        Example:

                                        # Style/PercentLiteralDelimiters:
                                        #   PreferredDelimiters:
                                        #     default: '[]'
                                        #     '%i':    '()'
                                        
                                        # good
                                        %w[alpha beta] + %i(gamma delta)
                                        
                                        # bad
                                        %W(alpha #{beta})
                                        
                                        # bad
                                        %I(alpha beta)

                                        %w-literals should be delimited by [ and ].
                                        Open

                                          %w(public_related_items_for private_related_items_for).each do |method_name|
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop enforces the consistent usage of %-literal delimiters.

                                        Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

                                        Example:

                                        # Style/PercentLiteralDelimiters:
                                        #   PreferredDelimiters:
                                        #     default: '[]'
                                        #     '%i':    '()'
                                        
                                        # good
                                        %w[alpha beta] + %i(gamma delta)
                                        
                                        # bad
                                        %W(alpha #{beta})
                                        
                                        # bad
                                        %I(alpha beta)

                                        %w-literals should be delimited by [ and ].
                                        Open

                                          %w(beginning mid end).each do |location|
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop enforces the consistent usage of %-literal delimiters.

                                        Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

                                        Example:

                                        # Style/PercentLiteralDelimiters:
                                        #   PreferredDelimiters:
                                        #     default: '[]'
                                        #     '%i':    '()'
                                        
                                        # good
                                        %w[alpha beta] + %i(gamma delta)
                                        
                                        # bad
                                        %W(alpha #{beta})
                                        
                                        # bad
                                        %I(alpha beta)

                                        Avoid rescuing without specifying an error class.
                                        Open

                                                                         rescue
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for rescuing StandardError. There are two supported styles implicit and explicit. This cop will not register an offense if any error other than StandardError is specified.

                                        Example: EnforcedStyle: implicit

                                        # `implicit` will enforce using `rescue` instead of
                                        # `rescue StandardError`.
                                        
                                        # bad
                                        begin
                                          foo
                                        rescue StandardError
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue OtherError
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue StandardError, SecurityError
                                          bar
                                        end

                                        Example: EnforcedStyle: explicit (default)

                                        # `explicit` will enforce using `rescue StandardError`
                                        # instead of `rescue`.
                                        
                                        # bad
                                        begin
                                          foo
                                        rescue
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue StandardError
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue OtherError
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue StandardError, SecurityError
                                          bar
                                        end

                                        Avoid multi-line ternary operators, use if or unless instead.
                                        Open

                                              SystemSetting.image_sizes[:small_sq].is_a?(String) ? \
                                                                     SystemSetting.image_sizes[:small_sq].gsub(/(!|>|<)/, '').split('x').first.to_i : \
                                                                     SystemSetting.image_sizes[:small_sq].first
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for multi-line ternary op expressions.

                                        Example:

                                        # bad
                                        a = cond ?
                                          b : c
                                        a = cond ? b :
                                            c
                                        a = cond ?
                                            b :
                                            c
                                        
                                        # good
                                        a = cond ? b : c
                                        a =
                                          if cond
                                            b
                                          else
                                            c
                                          end

                                        Avoid rescuing without specifying an error class.
                                        Open

                                            rescue
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop checks for rescuing StandardError. There are two supported styles implicit and explicit. This cop will not register an offense if any error other than StandardError is specified.

                                        Example: EnforcedStyle: implicit

                                        # `implicit` will enforce using `rescue` instead of
                                        # `rescue StandardError`.
                                        
                                        # bad
                                        begin
                                          foo
                                        rescue StandardError
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue OtherError
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue StandardError, SecurityError
                                          bar
                                        end

                                        Example: EnforcedStyle: explicit (default)

                                        # `explicit` will enforce using `rescue StandardError`
                                        # instead of `rescue`.
                                        
                                        # bad
                                        begin
                                          foo
                                        rescue
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue StandardError
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue OtherError
                                          bar
                                        end
                                        
                                        # good
                                        begin
                                          foo
                                        rescue StandardError, SecurityError
                                          bar
                                        end

                                        Use safe navigation (&.) instead of checking if an object exists before calling the method.
                                        Open

                                            class_names << 'no-items' if count && count.zero? && params[:controller] != 'topics'
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop transforms usages of a method call safeguarded by a non nil check for the variable whose method is being called to safe navigation (&.).

                                        Configuration option: ConvertCodeThatCanStartToReturnNil The default for this is false. When configured to true, this will check for code in the format !foo.nil? && foo.bar. As it is written, the return of this code is limited to false and whatever the return of the method is. If this is converted to safe navigation, foo&.bar can start returning nil as well as what the method returns.

                                        Example:

                                        # bad
                                        foo.bar if foo
                                        foo.bar(param1, param2) if foo
                                        foo.bar { |e| e.something } if foo
                                        foo.bar(param) { |e| e.something } if foo
                                        
                                        foo.bar if !foo.nil?
                                        foo.bar unless !foo
                                        foo.bar unless foo.nil?
                                        
                                        foo && foo.bar
                                        foo && foo.bar(param1, param2)
                                        foo && foo.bar { |e| e.something }
                                        foo && foo.bar(param) { |e| e.something }
                                        
                                        # good
                                        foo&.bar
                                        foo&.bar(param1, param2)
                                        foo&.bar { |e| e.something }
                                        foo&.bar(param) { |e| e.something }
                                        
                                        foo.nil? || foo.bar
                                        !foo || foo.bar
                                        
                                        # Methods that `nil` will `respond_to?` should not be converted to
                                        # use safe navigation
                                        foo.to_i if foo

                                        %w-literals should be delimited by [ and ].
                                        Open

                                            if ef && %w(autocomplete choice).member?(ef.ftype)
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb by rubocop

                                        This cop enforces the consistent usage of %-literal delimiters.

                                        Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

                                        Example:

                                        # Style/PercentLiteralDelimiters:
                                        #   PreferredDelimiters:
                                        #     default: '[]'
                                        #     '%i':    '()'
                                        
                                        # good
                                        %w[alpha beta] + %i(gamma delta)
                                        
                                        # bad
                                        %W(alpha #{beta})
                                        
                                        # bad
                                        %I(alpha beta)

                                        There are no issues that match your filters.

                                        Category
                                        Status