app/models/basket.rb

Summary

Maintainability
D
3 days
Test Coverage

Mass assignment is not restricted using attr_accessible
Open

class Basket < ActiveRecord::Base
Severity: Critical
Found in app/models/basket.rb by brakeman

This warning comes up if a model does not limit what attributes can be set through mass assignment.

In particular, this check looks for attr_accessible inside model definitions. If it is not found, this warning will be issued.

Brakeman also warns on use of attr_protected - especially since it was found to be vulnerable to bypass. Warnings for mass assignment on models using attr_protected will be reported, but at a lower confidence level.

Note that disabling mass assignment globally will suppress these warnings.

Class has too many lines. [487/100]
Open

class Basket < ActiveRecord::Base
  scope :except_certain_baskets, lambda { |baskets| where("id not in (?) AND status = 'approved'", baskets) }

  def self.settings
    # * EOIN: we are pretty sure this is not called - raise an exception to be sure
Severity: Minor
Found in app/models/basket.rb by rubocop

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

Class Basket has 72 methods (exceeds 20 allowed). Consider refactoring.
Open

class Basket < ActiveRecord::Base
  scope :except_certain_baskets, lambda { |baskets| where("id not in (?) AND status = 'approved'", baskets) }

  def self.settings
    # * EOIN: we are pretty sure this is not called - raise an exception to be sure
Severity: Major
Found in app/models/basket.rb - About 1 day to fix

    File basket.rb has 489 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Basket < ActiveRecord::Base
      scope :except_certain_baskets, lambda { |baskets| where("id not in (?) AND status = 'approved'", baskets) }
    
      def self.settings
        # * EOIN: we are pretty sure this is not called - raise an exception to be sure
    Severity: Minor
    Found in app/models/basket.rb - About 7 hrs to fix

      Assignment Branch Condition size for tag_counts_array is too high. [40.24/15]
      Open

        def tag_counts_array(options = {})
          tag_limit = !options[:limit].nil? ? options[:limit] : index_page_number_of_tags
          tag_order = !options[:order].nil? ? options[:order] : index_page_order_tags_by
          tag_direction = ['asc', 'desc'].include?(options[:direction]) ? options[:direction] : (tag_order == 'alphabetical' ? 'asc' : 'desc')
          private_tags = options[:allow_private] || false
      Severity: Minor
      Found in app/models/basket.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. [34/10]
      Open

        def tag_counts_array(options = {})
          tag_limit = !options[:limit].nil? ? options[:limit] : index_page_number_of_tags
          tag_order = !options[:order].nil? ? options[:order] : index_page_order_tags_by
          tag_direction = ['asc', 'desc'].include?(options[:direction]) ? options[:direction] : (tag_order == 'alphabetical' ? 'asc' : 'desc')
          private_tags = options[:allow_private] || false
      Severity: Minor
      Found in app/models/basket.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.

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

        def tag_counts_array(options = {})
          tag_limit = !options[:limit].nil? ? options[:limit] : index_page_number_of_tags
          tag_order = !options[:order].nil? ? options[:order] : index_page_order_tags_by
          tag_direction = ['asc', 'desc'].include?(options[:direction]) ? options[:direction] : (tag_order == 'alphabetical' ? 'asc' : 'desc')
          private_tags = options[:allow_private] || false
      Severity: Minor
      Found in app/models/basket.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 tag_counts_array is too high. [12/7]
      Open

        def tag_counts_array(options = {})
          tag_limit = !options[:limit].nil? ? options[:limit] : index_page_number_of_tags
          tag_order = !options[:order].nil? ? options[:order] : index_page_order_tags_by
          tag_direction = ['asc', 'desc'].include?(options[:direction]) ? options[:direction] : (tag_order == 'alphabetical' ? 'asc' : 'desc')
          private_tags = options[:allow_private] || false
      Severity: Minor
      Found in app/models/basket.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. [15/10]
      Open

        def font_family_select_options(default = nil)
          select_options = ''
          [
            [I18n.t('basket_model.font_use_theme_default'), ''],
            [I18n.t('basket_model.font_sans_serif'), 'sans-serif'],
      Severity: Minor
      Found in app/models/basket.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 moderation_select_options(default = nil)
          select_options = ''
          [
            [I18n.t('basket_model.moderate_before_approved'), true],
            [I18n.t('basket_model.moderate_on_flagged'), false]].each do |option|
      Severity: Minor
      Found in app/models/basket.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 tag_counts_array has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def tag_counts_array(options = {})
          tag_limit = !options[:limit].nil? ? options[:limit] : index_page_number_of_tags
          tag_order = !options[:order].nil? ? options[:order] : index_page_order_tags_by
          tag_direction = ['asc', 'desc'].include?(options[:direction]) ? options[:direction] : (tag_order == 'alphabetical' ? 'asc' : 'desc')
          private_tags = options[:allow_private] || false
      Severity: Minor
      Found in app/models/basket.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 moderation_select_options is too high. [17.69/15]
      Open

        def moderation_select_options(default = nil)
          select_options = ''
          [
            [I18n.t('basket_model.moderate_before_approved'), true],
            [I18n.t('basket_model.moderate_on_flagged'), false]].each do |option|
      Severity: Minor
      Found in app/models/basket.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 font_family_select_options is too high. [17.12/15]
      Open

        def font_family_select_options(default = nil)
          select_options = ''
          [
            [I18n.t('basket_model.font_use_theme_default'), ''],
            [I18n.t('basket_model.font_sans_serif'), 'sans-serif'],
      Severity: Minor
      Found in app/models/basket.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 array_to_options_list_with_defaults(options_array, default_value, site_admin = true, pluralize = false)
          select_options = ''
          options_array.each do |option|
            label = option[0]
            value = option[1]
      Severity: Minor
      Found in app/models/basket.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.

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

        def moderation_select_options(default = nil)
          select_options = ''
          [
            [I18n.t('basket_model.moderate_before_approved'), true],
            [I18n.t('basket_model.moderate_on_flagged'), false]].each do |option|
      Severity: Minor
      Found in app/models/basket.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 moderators_or_next_in_line is too high. [16.76/15]
      Open

        def moderators_or_next_in_line
          moderators = has_moderators
          moderators = has_admins if moderators.size == 0
          moderators = Basket.site_basket.has_admins if moderators.size == 0
          moderators << Basket.site_basket.has_site_admins if moderators.size == 0 || SystemSetting.notify_site_admins_of_flaggings
      Severity: Minor
      Found in app/models/basket.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 tag_counts_array has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def tag_counts_array(options = {})
          tag_limit = !options[:limit].nil? ? options[:limit] : index_page_number_of_tags
          tag_order = !options[:order].nil? ? options[:order] : index_page_order_tags_by
          tag_direction = ['asc', 'desc'].include?(options[:direction]) ? options[:direction] : (tag_order == 'alphabetical' ? 'asc' : 'desc')
          private_tags = options[:allow_private] || false
      Severity: Minor
      Found in app/models/basket.rb - About 1 hr to fix

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

          def array_to_options_list_with_defaults(options_array, default_value, site_admin = true, pluralize = false)
            select_options = ''
            options_array.each do |option|
              label = option[0]
              value = option[1]
        Severity: Minor
        Found in app/models/basket.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

        Consider simplifying this complex logical expression.
        Open

              if (default && (default == value.to_s || (default.blank? && value == false))) ||
                 (!default && fully_moderated? == value)
                select_options += ' selected="selected"'
              end
        Severity: Major
        Found in app/models/basket.rb - About 40 mins to fix

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

            def moderation_select_options(default = nil)
              select_options = ''
              [
                [I18n.t('basket_model.moderate_before_approved'), true],
                [I18n.t('basket_model.moderate_on_flagged'), false]].each do |option|
          Severity: Minor
          Found in app/models/basket.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

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

            def possible_themes
              @possible_themes = []
              themes_dir = Dir.new(THEMES_ROOT)
              themes_dir.each do |listing|
                path_to_theme_dir = THEMES_ROOT + '/' + listing
          Severity: Minor
          Found in app/models/basket.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

          TODO found
          Open

                # TODO: do we really need to specify that the order should be random?
          Severity: Minor
          Found in app/models/basket.rb by fixme

          TODO found
          Open

            # TODO clean this up using define_method (meta programming magic)
          Severity: Minor
          Found in app/models/basket.rb by fixme

          FIXME found
          Open

              # * FIXME: this is temporary and should be removed before we go into production
          Severity: Minor
          Found in app/models/basket.rb by fixme

          Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
          Open

                [I18n.t('basket_model.only_comments'), 'comments']]
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

          When using the symmetrical (default) style:

          If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

          If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

          When using the new_line style:

          The closing brace of a multi-line array literal must be on the line after the last element of the array.

          When using the same_line style:

          The closing brace of a multi-line array literal must be on the same line as the last element of the array.

          Example: EnforcedStyle: symmetrical (default)

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: new_line

          # bad
            [
              :a,
              :b ]
          
            # bad
            [ :a,
              :b ]
          
            # good
            [ :a,
              :b
            ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: same_line

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b
            ]
          
            # good
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]

          Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
          Open

              show_privacy_controls do_not_sanitize feeds_attributes }
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

          When using the symmetrical (default) style:

          If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

          If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

          When using the new_line style:

          The closing brace of a multi-line array literal must be on the line after the last element of the array.

          When using the same_line style:

          The closing brace of a multi-line array literal must be on the same line as the last element of the array.

          Example: EnforcedStyle: symmetrical (default)

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: new_line

          # bad
            [
              :a,
              :b ]
          
            # bad
            [ :a,
              :b ]
          
            # good
            [ :a,
              :b
            ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: same_line

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b
            ]
          
            # good
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]

          Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
          Open

                [I18n.t('basket_model.tags_as_tag_cloud'), 'tag cloud']]
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

          When using the symmetrical (default) style:

          If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

          If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

          When using the new_line style:

          The closing brace of a multi-line array literal must be on the line after the last element of the array.

          When using the same_line style:

          The closing brace of a multi-line array literal must be on the same line as the last element of the array.

          Example: EnforcedStyle: symmetrical (default)

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: new_line

          # bad
            [
              :a,
              :b ]
          
            # bad
            [ :a,
              :b ]
          
            # good
            [ :a,
              :b
            ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: same_line

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b
            ]
          
            # good
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]

          Useless assignment to variable - select_options.
          Open

              select_options = array_to_options_list_with_defaults(Basket.member_level_options, current_value)
          Severity: Minor
          Found in app/models/basket.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

          Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
          Open

                [I18n.t('basket_model.image_random'), 'random']]
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

          When using the symmetrical (default) style:

          If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

          If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

          When using the new_line style:

          The closing brace of a multi-line array literal must be on the line after the last element of the array.

          When using the same_line style:

          The closing brace of a multi-line array literal must be on the same line as the last element of the array.

          Example: EnforcedStyle: symmetrical (default)

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: new_line

          # bad
            [
              :a,
              :b ]
          
            # bad
            [ :a,
              :b ]
          
            # good
            [ :a,
              :b
            ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: same_line

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b
            ]
          
            # good
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]

          Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
          Open

                [I18n.t('basket_model.font_serif'), 'serif']].each do |option|
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

          When using the symmetrical (default) style:

          If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

          If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

          When using the new_line style:

          The closing brace of a multi-line array literal must be on the line after the last element of the array.

          When using the same_line style:

          The closing brace of a multi-line array literal must be on the same line as the last element of the array.

          Example: EnforcedStyle: symmetrical (default)

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: new_line

          # bad
            [
              :a,
              :b ]
          
            # bad
            [ :a,
              :b ]
          
            # good
            [ :a,
              :b
            ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: same_line

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b
            ]
          
            # good
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]

          Unreachable code detected.
          Open

                false
          Severity: Minor
          Found in app/models/basket.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

          Replace class var @@privacy_exists with a class instance var.
          Open

              @@privacy_exists = all_baskets.any? { |basket| basket.show_privacy_controls? }
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

          Replace class var @@privacy_exists with a class instance var.
          Open

              @@privacy_exists = (Basket.should_show_privacy_controls.count > 0)
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

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

              case tag_order
              when 'alphabetical'
                find_tag_order = "tags.name #{tag_direction}"
              when 'latest'
                find_tag_order = "taggings.created_at #{tag_direction}"
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
          Open

                [I18n.t('basket_model.basket_homepage_options'), 'homepage_options']]
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

          When using the symmetrical (default) style:

          If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

          If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

          When using the new_line style:

          The closing brace of a multi-line array literal must be on the line after the last element of the array.

          When using the same_line style:

          The closing brace of a multi-line array literal must be on the same line as the last element of the array.

          Example: EnforcedStyle: symmetrical (default)

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: new_line

          # bad
            [
              :a,
              :b ]
          
            # bad
            [ :a,
              :b ]
          
            # good
            [ :a,
              :b
            ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: same_line

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b
            ]
          
            # good
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]

          Useless assignment to variable - select_options.
          Open

              select_options = array_to_options_list_with_defaults(options, current_value, false, true)
          Severity: Minor
          Found in app/models/basket.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

          Unused block argument - v. If it's necessary, use _ or _v as an argument name to indicate that it won't be used.
          Open

              Basket.all_level_options.select { |v, k| k == key }.first.first
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks for unused block arguments.

          Example:

          # bad
          
          do_something do |used, unused|
            puts used
          end
          
          do_something do |bar|
            puts :foo
          end
          
          define_method(:foo) do |bar|
            puts :baz
          end

          Example:

          #good
          
          do_something do |used, _unused|
            puts used
          end
          
          do_something do
            puts :foo
          end
          
          define_method(:foo) do |_bar|
            puts :baz
          end

          Useless assignment to variable - select_options.
          Open

              select_options = array_to_options_list_with_defaults(Basket.user_level_options, current_show_flagging_value)
          Severity: Minor
          Found in app/models/basket.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

          Use || instead of or.
          Open

              b or raise('Failed to find the required Documentation basket')
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

          Example: EnforcedStyle: always (default)

          # bad
          foo.save and return
          
          # bad
          if foo and bar
          end
          
          # good
          foo.save && return
          
          # good
          if foo && bar
          end

          Example: EnforcedStyle: conditionals

          # bad
          if foo and bar
          end
          
          # good
          foo.save && return
          
          # good
          foo.save and return
          
          # good
          if foo && bar
          end

          Use || instead of or.
          Open

              b or raise('Failed to find the required Help basket')
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

          Example: EnforcedStyle: always (default)

          # bad
          foo.save and return
          
          # bad
          if foo and bar
          end
          
          # good
          foo.save && return
          
          # good
          if foo && bar
          end

          Example: EnforcedStyle: conditionals

          # bad
          if foo and bar
          end
          
          # good
          foo.save && return
          
          # good
          foo.save and return
          
          # good
          if foo && bar
          end

          Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
          Open

                [I18n.t('basket_model.tags_ordered_random'), 'random']]
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

          When using the symmetrical (default) style:

          If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

          If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

          When using the new_line style:

          The closing brace of a multi-line array literal must be on the line after the last element of the array.

          When using the same_line style:

          The closing brace of a multi-line array literal must be on the same line as the last element of the array.

          Example: EnforcedStyle: symmetrical (default)

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: new_line

          # bad
            [
              :a,
              :b ]
          
            # bad
            [ :a,
              :b ]
          
            # good
            [ :a,
              :b
            ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: same_line

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b
            ]
          
            # good
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]

          Use || instead of or.
          Open

              b or raise('Failed to find the required About basket')
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

          Example: EnforcedStyle: always (default)

          # bad
          foo.save and return
          
          # bad
          if foo and bar
          end
          
          # good
          foo.save && return
          
          # good
          if foo && bar
          end

          Example: EnforcedStyle: conditionals

          # bad
          if foo and bar
          end
          
          # good
          foo.save && return
          
          # good
          foo.save and return
          
          # good
          if foo && bar
          end

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

              if old_urlified_name != urlified_name
          Severity: Minor
          Found in app/models/basket.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

          Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
          Open

                [I18n.t('basket_model.site_admin'), 'at least site admin']]
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

          When using the symmetrical (default) style:

          If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

          If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

          When using the new_line style:

          The closing brace of a multi-line array literal must be on the line after the last element of the array.

          When using the same_line style:

          The closing brace of a multi-line array literal must be on the same line as the last element of the array.

          Example: EnforcedStyle: symmetrical (default)

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: new_line

          # bad
            [
              :a,
              :b ]
          
            # bad
            [ :a,
              :b ]
          
            # good
            [ :a,
              :b
            ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: same_line

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b
            ]
          
            # good
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]

          Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
          Open

              additional_footer_content do_not_sanitize_footer_content replace_existing_footer }
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

          When using the symmetrical (default) style:

          If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

          If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

          When using the new_line style:

          The closing brace of a multi-line array literal must be on the line after the last element of the array.

          When using the same_line style:

          The closing brace of a multi-line array literal must be on the same line as the last element of the array.

          Example: EnforcedStyle: symmetrical (default)

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: new_line

          # bad
            [
              :a,
              :b ]
          
            # bad
            [ :a,
              :b ]
          
            # good
            [ :a,
              :b
            ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: same_line

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b
            ]
          
            # good
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]

          Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
          Open

              do_not_sanitize_footer_content replace_existing_footer }
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

          When using the symmetrical (default) style:

          If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

          If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

          When using the new_line style:

          The closing brace of a multi-line array literal must be on the line after the last element of the array.

          When using the same_line style:

          The closing brace of a multi-line array literal must be on the same line as the last element of the array.

          Example: EnforcedStyle: symmetrical (default)

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: new_line

          # bad
            [
              :a,
              :b ]
          
            # bad
            [ :a,
              :b ]
          
            # good
            [ :a,
              :b
            ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: same_line

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b
            ]
          
            # good
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]

          Use the -> { ... } lambda literal syntax for single line lambdas.
          Open

            scope :except_certain_baskets, lambda { |baskets| where("id not in (?) AND status = 'approved'", baskets) }
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop (by default) checks for uses of the lambda literal syntax for single line lambdas, and the method call syntax for multiline lambdas. It is configurable to enforce one of the styles for both single line and multiline lambdas as well.

          Example: EnforcedStyle: linecountdependent (default)

          # bad
          f = lambda { |x| x }
          f = ->(x) do
                x
              end
          
          # good
          f = ->(x) { x }
          f = lambda do |x|
                x
              end

          Example: EnforcedStyle: lambda

          # bad
          f = ->(x) { x }
          f = ->(x) do
                x
              end
          
          # good
          f = lambda { |x| x }
          f = lambda do |x|
                x
              end

          Example: EnforcedStyle: literal

          # bad
          f = lambda { |x| x }
          f = lambda do |x|
                x
              end
          
          # good
          f = ->(x) { x }
          f = ->(x) do
                x
              end

          Avoid the use of the case equality operator ===.
          Open

              allow_non_member_comments === true
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks for uses of the case equality operator(===).

          Example:

          # bad
          Array === something
          (1..100) === 7
          /something/ === some_string
          
          # good
          something.is_a?(Array)
          (1..100).include?(7)
          some_string =~ /something/

          Useless assignment to variable - select_options.
          Open

              select_options = array_to_options_list_with_defaults(Basket.user_level_options, current_show_discussion_value)
          Severity: Minor
          Found in app/models/basket.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 - select_options.
          Open

              select_options = array_to_options_list_with_defaults(Basket.user_level_options, current_show_add_links_value)
          Severity: Minor
          Found in app/models/basket.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 - select_options.
          Open

              select_options = array_to_options_list_with_defaults(options_array, current_value)
          Severity: Minor
          Found in app/models/basket.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

          Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
          Open

                [I18n.t('basket_model.moderate_on_flagged'), false]].each do |option|
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

          When using the symmetrical (default) style:

          If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

          If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

          When using the new_line style:

          The closing brace of a multi-line array literal must be on the line after the last element of the array.

          When using the same_line style:

          The closing brace of a multi-line array literal must be on the same line as the last element of the array.

          Example: EnforcedStyle: symmetrical (default)

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: new_line

          # bad
            [
              :a,
              :b ]
          
            # bad
            [ :a,
              :b ]
          
            # good
            [ :a,
              :b
            ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: same_line

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b
            ]
          
            # good
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]

          Useless assignment to variable - select_options.
          Open

              select_options = array_to_options_list_with_defaults(Basket.user_level_options, current_show_actions_value)
          Severity: Minor
          Found in app/models/basket.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

          Freeze mutable objects assigned to constants.
          Open

            EDITABLE_ATTRIBUTES = %w{
              index_page_redirect_to_all index_page_topic_is_entire_page
              index_page_link_to_index_topic_as index_page_basket_search index_page_image_as
              index_page_tags_as index_page_number_of_tags index_page_order_tags_by
              index_page_recent_topics_as index_page_number_of_recent_topics index_page_archives_as
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

          Example:

          # bad
          CONST = [1, 2, 3]
          
          # good
          CONST = [1, 2, 3].freeze

          Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
          Open

                [I18n.t('basket_model.recent_as_headlines'), 'headlines']]
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

          When using the symmetrical (default) style:

          If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

          If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

          When using the new_line style:

          The closing brace of a multi-line array literal must be on the line after the last element of the array.

          When using the same_line style:

          The closing brace of a multi-line array literal must be on the same line as the last element of the array.

          Example: EnforcedStyle: symmetrical (default)

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: new_line

          # bad
            [
              :a,
              :b ]
          
            # bad
            [ :a,
              :b ]
          
            # good
            [ :a,
              :b
            ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: same_line

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b
            ]
          
            # good
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]

          Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
          Open

                [I18n.t('basket_model.archives_by_type'), 'by type']]
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

          When using the symmetrical (default) style:

          If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

          If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

          When using the new_line style:

          The closing brace of a multi-line array literal must be on the line after the last element of the array.

          When using the same_line style:

          The closing brace of a multi-line array literal must be on the same line as the last element of the array.

          Example: EnforcedStyle: symmetrical (default)

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: new_line

          # bad
            [
              :a,
              :b ]
          
            # bad
            [ :a,
              :b ]
          
            # good
            [ :a,
              :b
            ]
          
            # good
            [
              :a,
              :b
            ]

          Example: EnforcedStyle: same_line

          # bad
            [ :a,
              :b
            ]
          
            # bad
            [
              :a,
              :b
            ]
          
            # good
            [
              :a,
              :b ]
          
            # good
            [ :a,
              :b ]

          protected (on line 607) does not make singleton methods protected. Use protected inside a class << self block instead.
          Open

            def self.list_as_names_and_urlified_names
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks for private or protected access modifiers which are applied to a singleton method. These access modifiers do not make singleton methods private/protected. private_class_method can be used for that.

          Example:

          # bad
          
          class C
            private
          
            def self.method
              puts 'hi'
            end
          end

          Example:

          # good
          
          class C
            def self.method
              puts 'hi'
            end
          
            private_class_method :method
          end

          Example:

          # good
          
          class C
            class << self
              private
          
              def method
                puts 'hi'
              end
            end
          end

          Use the -> { ... } lambda literal syntax for single line lambdas.
          Open

              scope :should_show_privacy_controls, lambda { where(show_privacy_controls: true) }
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop (by default) checks for uses of the lambda literal syntax for single line lambdas, and the method call syntax for multiline lambdas. It is configurable to enforce one of the styles for both single line and multiline lambdas as well.

          Example: EnforcedStyle: linecountdependent (default)

          # bad
          f = lambda { |x| x }
          f = ->(x) do
                x
              end
          
          # good
          f = ->(x) { x }
          f = lambda do |x|
                x
              end

          Example: EnforcedStyle: lambda

          # bad
          f = ->(x) { x }
          f = ->(x) do
                x
              end
          
          # good
          f = lambda { |x| x }
          f = lambda do |x|
                x
              end

          Example: EnforcedStyle: literal

          # bad
          f = lambda { |x| x }
          f = lambda do |x|
                x
              end
          
          # good
          f = ->(x) { x }
          f = ->(x) do
                x
              end

          Use || instead of or.
          Open

              b or raise('Failed to find the required Site basket')
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

          Example: EnforcedStyle: always (default)

          # bad
          foo.save and return
          
          # bad
          if foo and bar
          end
          
          # good
          foo.save && return
          
          # good
          if foo && bar
          end

          Example: EnforcedStyle: conditionals

          # bad
          if foo and bar
          end
          
          # good
          foo.save && return
          
          # good
          foo.save and return
          
          # good
          if foo && bar
          end

          Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
          Open

                if default_value == value
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

          Example:

          # bad
          if condition
            do_stuff(bar)
          end
          
          unless qux.empty?
            Foo.do_something
          end
          
          # good
          do_stuff(bar) if condition
          Foo.do_something unless qux.empty?

          Use moderators.size.zero? instead of moderators.size == 0.
          Open

              moderators = Basket.site_basket.has_admins if moderators.size == 0
          Severity: Minor
          Found in app/models/basket.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

          Pass &:flagged_at as an argument to sort_by instead of a block.
          Open

                revisions.sort_by { |item| item.flagged_at }
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          Use symbols as procs when possible.

          Example:

          # bad
          something.map { |s| s.upcase }
          
          # good
          something.map(&:upcase)

          Freeze mutable objects assigned to constants.
          Open

            NESTED_FIELDS = %w{
              name status creator_id do_not_sanitize moderated_except
              sort_direction_reversed_default private_item_notification_show_title
              private_item_notification_show_short_summary index_page_link_to_index_topic_as
              index_page_recent_topics_as index_page_tags_as index_page_order_tags_by
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

          Example:

          # bad
          CONST = [1, 2, 3]
          
          # good
          CONST = [1, 2, 3].freeze

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

            NESTED_FIELDS = %w{
              name status creator_id do_not_sanitize moderated_except
              sort_direction_reversed_default private_item_notification_show_title
              private_item_notification_show_short_summary index_page_link_to_index_topic_as
              index_page_recent_topics_as index_page_tags_as index_page_order_tags_by
          Severity: Minor
          Found in app/models/basket.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)

          Use empty? instead of size == 0.
          Open

                role.destroy if role.users.size == 0
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty.

          Example:

          # bad
          [1, 2, 3].length == 0
          0 == "foobar".length
          array.length < 1
          {a: 1, b: 2}.length != 0
          string.length > 0
          hash.size > 0
          
          # good
          [1, 2, 3].empty?
          "foobar".empty?
          array.empty?
          !{a: 1, b: 2}.empty?
          !string.empty?
          !hash.empty?

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

            EDITABLE_ATTRIBUTES = %w{
              index_page_redirect_to_all index_page_topic_is_entire_page
              index_page_link_to_index_topic_as index_page_basket_search index_page_image_as
              index_page_tags_as index_page_number_of_tags index_page_order_tags_by
              index_page_recent_topics_as index_page_number_of_recent_topics index_page_archives_as
          Severity: Minor
          Found in app/models/basket.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)

          Always use raise to signal exceptions.
          Open

              fail "Basket#setting expected just a name but we got the name '#{name}' and these extras: #{args}" unless args.empty?
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks for uses of fail and raise.

          Example: EnforcedStyle: only_raise (default)

          # The `only_raise` style enforces the sole use of `raise`.
          # bad
          begin
            fail
          rescue Exception
            # handle it
          end
          
          def watch_out
            fail
          rescue Exception
            # handle it
          end
          
          Kernel.fail
          
          # good
          begin
            raise
          rescue Exception
            # handle it
          end
          
          def watch_out
            raise
          rescue Exception
            # handle it
          end
          
          Kernel.raise

          Example: EnforcedStyle: only_fail

          # The `only_fail` style enforces the sole use of `fail`.
          # bad
          begin
            raise
          rescue Exception
            # handle it
          end
          
          def watch_out
            raise
          rescue Exception
            # handle it
          end
          
          Kernel.raise
          
          # good
          begin
            fail
          rescue Exception
            # handle it
          end
          
          def watch_out
            fail
          rescue Exception
            # handle it
          end
          
          Kernel.fail

          Example: EnforcedStyle: semantic

          # The `semantic` style enforces the use of `fail` to signal an
          # exception, then will use `raise` to trigger an offense after
          # it has been rescued.
          # bad
          begin
            raise
          rescue Exception
            # handle it
          end
          
          def watch_out
            # Error thrown
          rescue Exception
            fail
          end
          
          Kernel.fail
          Kernel.raise
          
          # good
          begin
            fail
          rescue Exception
            # handle it
          end
          
          def watch_out
            fail
          rescue Exception
            raise 'Preferably with descriptive message'
          end
          
          explicit_receiver.fail
          explicit_receiver.raise

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

            EDITABLE_SETTINGS = %w{
              fully_moderated moderated_except private_file_visibility browse_view_as
              sort_order_default sort_direction_reversed_default disable_site_recent_topics_display
              basket_join_policy memberlist_policy import_archive_set_policy allow_basket_admin_contact private_item_notification
              private_item_notification_show_title private_item_notification_show_short_summary
          Severity: Minor
          Found in app/models/basket.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)

          Use empty? instead of size == 0.
          Open

              moderators << Basket.site_basket.has_site_admins if moderators.size == 0 || SystemSetting.notify_site_admins_of_flaggings
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty.

          Example:

          # bad
          [1, 2, 3].length == 0
          0 == "foobar".length
          array.length < 1
          {a: 1, b: 2}.length != 0
          string.length > 0
          hash.size > 0
          
          # good
          [1, 2, 3].empty?
          "foobar".empty?
          array.empty?
          !{a: 1, b: 2}.empty?
          !string.empty?
          !hash.empty?

          Use moderators.size.zero? instead of moderators.size == 0.
          Open

              moderators = has_admins if moderators.size == 0
          Severity: Minor
          Found in app/models/basket.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 moderators.size.zero? instead of moderators.size == 0.
          Open

              moderators << Basket.site_basket.has_site_admins if moderators.size == 0 || SystemSetting.notify_site_admins_of_flaggings
          Severity: Minor
          Found in app/models/basket.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 empty? instead of size == 0.
          Open

              moderators = Basket.site_basket.has_admins if moderators.size == 0
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty.

          Example:

          # bad
          [1, 2, 3].length == 0
          0 == "foobar".length
          array.length < 1
          {a: 1, b: 2}.length != 0
          string.length > 0
          hash.size > 0
          
          # good
          [1, 2, 3].empty?
          "foobar".empty?
          array.empty?
          !{a: 1, b: 2}.empty?
          !string.empty?
          !hash.empty?

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

            %w{disputed reviewed rejected}.each do |type|
          Severity: Minor
          Found in app/models/basket.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)

          Use Basket.should_show_privacy_controls.count.positive? instead of Basket.should_show_privacy_controls.count > 0.
          Open

              @@privacy_exists = (Basket.should_show_privacy_controls.count > 0)
          Severity: Minor
          Found in app/models/basket.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

          Pass &:show_privacy_controls? as an argument to any? instead of a block.
          Open

              @@privacy_exists = all_baskets.any? { |basket| basket.show_privacy_controls? }
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          Use symbols as procs when possible.

          Example:

          # bad
          something.map { |s| s.upcase }
          
          # good
          something.map(&:upcase)

          Ternary operators must not be nested. Prefer if or else constructs instead.
          Open

              tag_direction = ['asc', 'desc'].include?(options[:direction]) ? options[:direction] : (tag_order == 'alphabetical' ? 'asc' : 'desc')
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          Use empty? instead of size == 0.
          Open

              moderators = has_admins if moderators.size == 0
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty.

          Example:

          # bad
          [1, 2, 3].length == 0
          0 == "foobar".length
          array.length < 1
          {a: 1, b: 2}.length != 0
          string.length > 0
          hash.size > 0
          
          # good
          [1, 2, 3].empty?
          "foobar".empty?
          array.empty?
          !{a: 1, b: 2}.empty?
          !string.empty?
          !hash.empty?

          Use role.users.size.zero? instead of role.users.size == 0.
          Open

                role.destroy if role.users.size == 0
          Severity: Minor
          Found in app/models/basket.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

          Freeze mutable objects assigned to constants.
          Open

            EDITABLE_SETTINGS = %w{
              fully_moderated moderated_except private_file_visibility browse_view_as
              sort_order_default sort_direction_reversed_default disable_site_recent_topics_display
              basket_join_policy memberlist_policy import_archive_set_policy allow_basket_admin_contact private_item_notification
              private_item_notification_show_title private_item_notification_show_short_summary
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

          Example:

          # bad
          CONST = [1, 2, 3]
          
          # good
          CONST = [1, 2, 3].freeze

          Use next to skip iteration.
          Open

                if File.directory?(path_to_theme_dir) && !['.', '..', '.svn'].include?(listing)
          Severity: Minor
          Found in app/models/basket.rb by rubocop

          Use next to skip iteration instead of a condition at the end.

          Example: EnforcedStyle: skipmodifierifs (default)

          # bad
          [1, 2].each do |a|
            if a == 1
              puts a
            end
          end
          
          # good
          [1, 2].each do |a|
            next unless a == 1
            puts a
          end
          
          # good
          [1, 2].each do |o|
            puts o unless o == 1
          end

          Example: EnforcedStyle: always

          # With `always` all conditions at the end of an iteration needs to be
          # replaced by next - with `skip_modifier_ifs` the modifier if like
          # this one are ignored: `[1, 2].each { |a| return 'yes' if a == 1 }`
          
          # bad
          [1, 2].each do |o|
            puts o unless o == 1
          end
          
          # bad
          [1, 2].each do |a|
            if a == 1
              puts a
            end
          end
          
          # good
          [1, 2].each do |a|
            next unless a == 1
            puts a
          end

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

              return [] unless !tag_limit || tag_limit > 0 # false = no limit, 0 = no tags
          Severity: Minor
          Found in app/models/basket.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

          There are no issues that match your filters.

          Category
          Status