app/helpers/extended_fields_helper.rb

Summary

Maintainability
D
2 days
Test Coverage

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

module ExtendedFieldsHelper
  # Override for ActiveScaffold extended field controller edit view
  # Refer to http://activescaffold.com/docs/form-overrides for details

  def topic_type_form_column(record, input_name)

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

Assignment Branch Condition size for pseudo_choices_form_column is too high. [55.08/15]
Open

  def pseudo_choices_form_column(record, input_name)
    top_level = Choice.find_top_level
    id = 'tree_' + record.id.to_s

    # Containing DIV for theme

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

File extended_fields_helper.rb has 400 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ExtendedFieldsHelper
  # Override for ActiveScaffold extended field controller edit view
  # Refer to http://activescaffold.com/docs/form-overrides for details

  def topic_type_form_column(record, input_name)
Severity: Minor
Found in app/helpers/extended_fields_helper.rb - About 5 hrs to fix

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

      def extended_field_topic_type_editor(name, value, tag_options, extended_field)
        value = '' if value.blank?
        value = { 'label' => value[0], 'value' => value[1] } if value.is_a?(Array)
        value = "#{value['label']} (#{value['value']})" if value.is_a?(Hash) && value['value'] && value['label']
    
    

    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 children_form_column is too high. [39.37/15]
    Open

      def children_form_column(record, input_name)
        if record.new_record?
    
          # Due to a limitation on better-nested-set, you cannot move_to any node unless the node you're
          # moving has already been saved. The intention here is that hierarchical manipulation of choices

    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 extended_field_choice_select_editor is too high. [36.91/15]
    Open

      def extended_field_choice_select_editor(name, value, options, extended_field, choices, level = 1)
        # Build OPTION tags
        if choices.size > 0
          option_tags = options_for_select(
            [["- choose #{"sub-" if level > 1}#{display_label_for(extended_field).singularize.downcase} -", '']] +

    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. [30/10]
    Open

      def extended_field_choice_select_editor(name, value, options, extended_field, choices, level = 1)
        # Build OPTION tags
        if choices.size > 0
          option_tags = options_for_select(
            [["- choose #{"sub-" if level > 1}#{display_label_for(extended_field).singularize.downcase} -", '']] +

    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 extended_field_choice_autocomplete_editor is too high. [32.31/15]
    Open

      def extended_field_choice_autocomplete_editor(name, value, options, extended_field, choices, level = 1)
        # Build a list of available choices
        choices = choices.map { |c| c.label }
    
        # Because we store the choice's value, not label, we need to find the label to be shown in the text field.

    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. [26/10]
    Open

      def list_item_for_choice(choice, options = {}, url_hash = {})
        options = {
          include_children: true,
          current: false,
        }.merge(options)

    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 extended_field_topic_type_editor is too high. [30.35/15]
    Open

      def extended_field_topic_type_editor(name, value, tag_options, extended_field)
        value = '' if value.blank?
        value = { 'label' => value[0], 'value' => value[1] } if value.is_a?(Array)
        value = "#{value['label']} (#{value['value']})" if value.is_a?(Hash) && value['value'] && value['label']
    
    

    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 list_item_for_choice is too high. [28.79/15]
    Open

      def list_item_for_choice(choice, options = {}, url_hash = {})
        options = {
          include_children: true,
          current: false,
        }.merge(options)

    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. [23/10]
    Open

      def extended_field_choice_editor(name, value, options, extended_field)
        if value.is_a?(Array)
          value =
            value.collect do |v|
              if v.is_a?(Hash) && v['value']

    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. [21/10]
    Open

      def children_form_column(record, input_name)
        if record.new_record?
    
          # Due to a limitation on better-nested-set, you cannot move_to any node unless the node you're
          # moving has already been saved. The intention here is that hierarchical manipulation of choices

    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 extended_field_editor(extended_field, value = nil, options = HashWithIndifferentAccess.new)
        @field_multiple_id = options[:multiple] || 1
    
        # Compile options for text_field_tag
        tag_options = {

    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 ftype_form_column(record, input_name)
        options_for_select = [
          [t('extended_fields_helper.ftype_form_column.check_box'), 'checkbox'],
          [t('extended_fields_helper.ftype_form_column.radio_button'), 'radio'],
          [t('extended_fields_helper.ftype_form_column.date'), 'date'],

    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. [19/10]
    Open

      def extended_field_choice_autocomplete_editor(name, value, options, extended_field, choices, level = 1)
        # Build a list of available choices
        choices = choices.map { |c| c.label }
    
        # Because we store the choice's value, not label, we need to find the label to be shown in the text field.

    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 extended_field_choice_editor is too high. [22.02/15]
    Open

      def extended_field_choice_editor(name, value, options, extended_field)
        if value.is_a?(Array)
          value =
            value.collect do |v|
              if v.is_a?(Hash) && v['value']

    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 extended_field_editor is too high. [21.26/15]
    Open

      def extended_field_editor(extended_field, value = nil, options = HashWithIndifferentAccess.new)
        @field_multiple_id = options[:multiple] || 1
    
        # Compile options for text_field_tag
        tag_options = {

    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. [16/10]
    Open

      def pseudo_choices_form_column(record, input_name)
        top_level = Choice.find_top_level
        id = 'tree_' + record.id.to_s
    
        # Containing DIV for theme

    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 ftype_form_column is too high. [18.14/15]
    Open

      def ftype_form_column(record, input_name)
        options_for_select = [
          [t('extended_fields_helper.ftype_form_column.check_box'), 'checkbox'],
          [t('extended_fields_helper.ftype_form_column.radio_button'), 'radio'],
          [t('extended_fields_helper.ftype_form_column.date'), 'date'],

    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 extended_field_choice_editor is too high. [10/7]
    Open

      def extended_field_choice_editor(name, value, options, extended_field)
        if value.is_a?(Array)
          value =
            value.collect do |v|
              if v.is_a?(Hash) && v['value']

    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

    Cyclomatic complexity for extended_field_topic_type_editor is too high. [8/6]
    Open

      def extended_field_topic_type_editor(name, value, tag_options, extended_field)
        value = '' if value.blank?
        value = { 'label' => value[0], 'value' => value[1] } if value.is_a?(Array)
        value = "#{value['label']} (#{value['value']})" if value.is_a?(Hash) && value['value'] && value['label']
    
    

    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 extended_field_choice_editor is too high. [8/6]
    Open

      def extended_field_choice_editor(name, value, options, extended_field)
        if value.is_a?(Array)
          value =
            value.collect do |v|
              if v.is_a?(Hash) && v['value']

    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. [12/10]
    Open

      def additional_extended_field_control(extended_field, n)
        id = id_for_extended_field(extended_field) + '_additional'
        text = t(
          'extended_fields_helper.additional_extended_field_control.add_another',
          field_name: display_label_for(extended_field).singularize.downcase

    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 list_item_for_choice is too high. [7/6]
    Open

      def list_item_for_choice(choice, options = {}, url_hash = {})
        options = {
          include_children: true,
          current: false,
        }.merge(options)

    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 list_item_for_choice is too high. [8/7]
    Open

      def list_item_for_choice(choice, options = {}, url_hash = {})
        options = {
          include_children: true,
          current: false,
        }.merge(options)

    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

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

      def extended_field_editor(extended_field, value = nil, options = HashWithIndifferentAccess.new)
        @field_multiple_id = options[:multiple] || 1
    
        # Compile options for text_field_tag
        tag_options = {

    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 extended_field_topic_type_editor is too high. [8/7]
    Open

      def extended_field_topic_type_editor(name, value, tag_options, extended_field)
        value = '' if value.blank?
        value = { 'label' => value[0], 'value' => value[1] } if value.is_a?(Array)
        value = "#{value['label']} (#{value['value']})" if value.is_a?(Hash) && value['value'] && value['label']
    
    

    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 extended_field_editor is too high. [8/7]
    Open

      def extended_field_editor(extended_field, value = nil, options = HashWithIndifferentAccess.new)
        @field_multiple_id = options[:multiple] || 1
    
        # Compile options for text_field_tag
        tag_options = {

    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 field_value_from_multiples_hash is too high. [15.94/15]
    Open

      def field_value_from_multiples_hash(extended_field, hash, position_in_set, level = 1)
        field_values = hash[qualified_name_for_field(extended_field) + '_multiple']
        field_values = field_values[position_in_set.to_s][qualified_name_for_field(extended_field)] || ''
    
        if field_values.is_a?(Hash) && extended_field.ftype != 'year'

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

      def extended_field_topic_type_editor(name, value, tag_options, extended_field)
        value = '' if value.blank?
        value = { 'label' => value[0], 'value' => value[1] } if value.is_a?(Array)
        value = "#{value['label']} (#{value['value']})" if value.is_a?(Hash) && value['value'] && value['label']
    
    
    Severity: Minor
    Found in app/helpers/extended_fields_helper.rb - About 1 hr to fix

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

        def extended_field_choice_editor(name, value, options, extended_field)
          if value.is_a?(Array)
            value =
              value.collect do |v|
                if v.is_a?(Hash) && v['value']
      Severity: Minor
      Found in app/helpers/extended_fields_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 extended_field_choice_select_editor has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def extended_field_choice_select_editor(name, value, options, extended_field, choices, level = 1)
          # Build OPTION tags
          if choices.size > 0
            option_tags = options_for_select(
              [["- choose #{"sub-" if level > 1}#{display_label_for(extended_field).singularize.downcase} -", '']] +
      Severity: Minor
      Found in app/helpers/extended_fields_helper.rb - About 1 hr to fix

        Method list_item_for_choice has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def list_item_for_choice(choice, options = {}, url_hash = {})
            options = {
              include_children: true,
              current: false,
            }.merge(options)
        Severity: Minor
        Found in app/helpers/extended_fields_helper.rb - About 1 hr to fix

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

            def list_item_for_choice(choice, options = {}, url_hash = {})
              options = {
                include_children: true,
                current: false,
              }.merge(options)
          Severity: Minor
          Found in app/helpers/extended_fields_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 extended_field_choice_autocomplete_editor has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def extended_field_choice_autocomplete_editor(name, value, options, extended_field, choices, level = 1)
          Severity: Minor
          Found in app/helpers/extended_fields_helper.rb - About 45 mins to fix

            Method extended_field_choice_select_editor has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def extended_field_choice_select_editor(name, value, options, extended_field, choices, level = 1)
            Severity: Minor
            Found in app/helpers/extended_fields_helper.rb - About 45 mins to fix

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

                def extended_field_editor(extended_field, value = nil, options = HashWithIndifferentAccess.new)
                  @field_multiple_id = options[:multiple] || 1
              
                  # Compile options for text_field_tag
                  tag_options = {
              Severity: Minor
              Found in app/helpers/extended_fields_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

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

                def extended_field_choice_select_editor(name, value, options, extended_field, choices, level = 1)
                  # Build OPTION tags
                  if choices.size > 0
                    option_tags = options_for_select(
                      [["- choose #{"sub-" if level > 1}#{display_label_for(extended_field).singularize.downcase} -", '']] +
              Severity: Minor
              Found in app/helpers/extended_fields_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

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

                def extended_field_topic_type_editor(name, value, tag_options, extended_field)
                  value = '' if value.blank?
                  value = { 'label' => value[0], 'value' => value[1] } if value.is_a?(Array)
                  value = "#{value['label']} (#{value['value']})" if value.is_a?(Hash) && value['value'] && value['label']
              
              
              Severity: Minor
              Found in app/helpers/extended_fields_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

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

                def field_value_from_multiples_hash(extended_field, hash, position_in_set, level = 1)
                  field_values = hash[qualified_name_for_field(extended_field) + '_multiple']
                  field_values = field_values[position_in_set.to_s][qualified_name_for_field(extended_field)] || ''
              
                  if field_values.is_a?(Hash) && extended_field.ftype != 'year'
              Severity: Minor
              Found in app/helpers/extended_fields_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. [6/5]
              Open

                def extended_field_choice_autocomplete_editor(name, value, options, extended_field, choices, level = 1)

              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 parameter lists longer than 5 parameters. [6/5]
              Open

                def extended_field_choice_select_editor(name, value, options, extended_field, choices, level = 1)

              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.

              TODO found
              Open

                  # TODO: Ensure the additional field control is only shown after the last multiple in a sequence
              Severity: Minor
              Found in app/helpers/extended_fields_helper.rb by fixme

              TODO found
              Open

                  # TODO: Where does required argument come from?
              Severity: Minor
              Found in app/helpers/extended_fields_helper.rb by fixme

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                    onchange: remote_function(
                      url: { controller: 'extended_fields', action: 'fetch_subchoices', for_level: level },
                      with: "'value='+escape(Form.Element.getValue(this))+'&options[name]=#{name}&options[value]=#{value}&options[extended_field_id]=#{extended_field.id}&item_type_for_params=#{@item_type_for_params}&field_multiple_id=#{@field_multiple_id}&editor=select'",
                      before: "Element.show('#{id_for_extended_field(extended_field)}_level_#{level}_spinner')",
                      complete: "Element.hide('#{id_for_extended_field(extended_field)}_level_#{level}_spinner')"
              Severity: Minor
              Found in app/helpers/extended_fields_helper.rb and 1 other location - About 55 mins to fix
              app/helpers/extended_fields_helper.rb on lines 335..340

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 46.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  remote_call = remote_function(
                    url: { controller: 'extended_fields', action: 'fetch_subchoices', for_level: level },
                    with: "'label='+escape(Form.Element.getValue(el))+'&options[name]=#{name}&options[value]=#{value}&options[extended_field_id]=#{extended_field.id}&item_type_for_params=#{@item_type_for_params}&field_multiple_id=#{@field_multiple_id}&editor=autocomplete'",
                    before: "Element.show('#{id_for_extended_field(extended_field)}_#{level}_spinner')",
                    complete: "Element.hide('#{id_for_extended_field(extended_field)}_#{level}_spinner')"
              Severity: Minor
              Found in app/helpers/extended_fields_helper.rb and 1 other location - About 55 mins to fix
              app/helpers/extended_fields_helper.rb on lines 305..310

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 46.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Useless assignment to variable - memo.
              Open

                      memo = memo + content_tag('li', choice)

              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 method argument - input_name. If it's necessary, use _ or _input_name as an argument name to indicate that it won't be used.
              Open

                def pseudo_choices_form_column(record, input_name)

              This cop checks for unused method arguments.

              Example:

              # bad
              
              def some_method(used, unused, _unused_but_allowed)
                puts used
              end

              Example:

              # good
              
              def some_method(used, _unused, _unused_but_allowed)
                puts used
              end

              Unused method argument - record. If it's necessary, use _ or _record as an argument name to indicate that it won't be used. You can also write as link_choice_values_form_column(*) if you want the method to accept any arguments but don't care about them.
              Open

                def link_choice_values_form_column(record, input_name)

              This cop checks for unused method arguments.

              Example:

              # bad
              
              def some_method(used, unused, _unused_but_allowed)
                puts used
              end

              Example:

              # good
              
              def some_method(used, _unused, _unused_but_allowed)
                puts used
              end

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

                def topic_type_form_column(record, input_name)

              This cop checks for unused method arguments.

              Example:

              # bad
              
              def some_method(used, unused, _unused_but_allowed)
                puts used
              end

              Example:

              # good
              
              def some_method(used, _unused, _unused_but_allowed)
                puts used
              end

              Unused method argument - input_name. If it's necessary, use _ or _input_name as an argument name to indicate that it won't be used. You can also write as link_choice_values_form_column(*) if you want the method to accept any arguments but don't care about them.
              Open

                def link_choice_values_form_column(record, input_name)

              This cop checks for unused method arguments.

              Example:

              # bad
              
              def some_method(used, unused, _unused_but_allowed)
                puts used
              end

              Example:

              # good
              
              def some_method(used, _unused, _unused_but_allowed)
                puts used
              end

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

                def label_form_column(record, input_name)

              This cop checks for unused method arguments.

              Example:

              # bad
              
              def some_method(used, unused, _unused_but_allowed)
                puts used
              end

              Example:

              # good
              
              def some_method(used, _unused, _unused_but_allowed)
                puts used
              end

              Useless assignment to variable - m.
              Open

                      m = m + build_ul_for_choice(choice, record)

              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

                  array.select { |k, v| k == qualified_name_for_field(extended_field) }.last.last

              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 - m.
              Open

                        m = m + build_ul_for_choice(child, record)

              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 method argument - input_name. If it's necessary, use _ or _input_name as an argument name to indicate that it won't be used.
              Open

                def multiple_form_column(record, input_name)

              This cop checks for unused method arguments.

              Example:

              # bad
              
              def some_method(used, unused, _unused_but_allowed)
                puts used
              end

              Example:

              # good
              
              def some_method(used, _unused, _unused_but_allowed)
                puts used
              end

              Unused method argument - record. If it's necessary, use _ or _record as an argument name to indicate that it won't be used. You can also write as user_choice_addition_form_column(*) if you want the method to accept any arguments but don't care about them.
              Open

                def user_choice_addition_form_column(record, input_name)

              This cop checks for unused method arguments.

              Example:

              # bad
              
              def some_method(used, unused, _unused_but_allowed)
                puts used
              end

              Example:

              # good
              
              def some_method(used, _unused, _unused_but_allowed)
                puts used
              end

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

                def children_form_column(record, input_name)

              This cop checks for unused method arguments.

              Example:

              # bad
              
              def some_method(used, unused, _unused_but_allowed)
                puts used
              end

              Example:

              # good
              
              def some_method(used, _unused, _unused_but_allowed)
                puts used
              end

              Use == if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition.
              Open

                  if top_level = Choice.find_top_level

              This cop checks for assignments in the conditions of if/while/until.

              Example:

              # bad
              
              if some_var = true
                do_something
              end

              Example:

              # good
              
              if some_var == true
                do_something
              end

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

                def field_value_from_multiples_hash(extended_field, hash, position_in_set, level = 1)

              This cop checks for unused method arguments.

              Example:

              # bad
              
              def some_method(used, unused, _unused_but_allowed)
                puts used
              end

              Example:

              # good
              
              def some_method(used, _unused, _unused_but_allowed)
                puts used
              end

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

                def extended_field_radio_editor(name, existing_value, options)

              This cop checks for unused method arguments.

              Example:

              # bad
              
              def some_method(used, unused, _unused_but_allowed)
                puts used
              end

              Example:

              # good
              
              def some_method(used, _unused, _unused_but_allowed)
                puts used
              end

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

                def extended_field_topic_type_editor(name, value, tag_options, extended_field)

              This cop checks for unused method arguments.

              Example:

              # bad
              
              def some_method(used, unused, _unused_but_allowed)
                puts used
              end

              Example:

              # good
              
              def some_method(used, _unused, _unused_but_allowed)
                puts used
              end

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

                    children = choice.children.inject('') { |memo, child| list_item_for_choice(child) }

              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

              Unused method argument - input_name. If it's necessary, use _ or _input_name as an argument name to indicate that it won't be used. You can also write as user_choice_addition_form_column(*) if you want the method to accept any arguments but don't care about them.
              Open

                def user_choice_addition_form_column(record, input_name)

              This cop checks for unused method arguments.

              Example:

              # bad
              
              def some_method(used, unused, _unused_but_allowed)
                puts used
              end

              Example:

              # good
              
              def some_method(used, _unused, _unused_but_allowed)
                puts used
              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

                    field_values.reject { |k, v| k == 'xml_element_name' }.sort.collect { |v| v.last } || []

              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

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

                def circa_form_column(record, input_name)

              This cop checks for unused method arguments.

              Example:

              # bad
              
              def some_method(used, unused, _unused_but_allowed)
                puts used
              end

              Example:

              # good
              
              def some_method(used, _unused, _unused_but_allowed)
                puts used
              end

              Useless assignment to variable - v.
              Open

                          v = v['value']

              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

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

                  if %w(choice autocomplete).member?(extended_field.ftype)

              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 self-assignment shorthand +=.
              Open

                      m = m + build_ul_for_choice(choice, record)

              This cop enforces the use the shorthand for self-assignment.

              Example:

              # bad
              x = x + 1
              
              # good
              x += 1

              Useless assignment to variable - memo.
              Open

                      memo = memo + content_tag('li', choice)

              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 - remote_call.
              Open

                  remote_call = remote_function(

              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

              Avoid comma after the last item of a hash.
              Open

                    controller_name_for_zoom_class: params[:controller_name_for_zoom_class] || 'topics',

              This cop checks for trailing comma in array and hash literals.

              Example: EnforcedStyleForMultiline: consistent_comma

              # bad
              a = [1, 2,]
              
              # good
              a = [
                1, 2,
                3,
              ]
              
              # good
              a = [
                1,
                2,
              ]

              Example: EnforcedStyleForMultiline: comma

              # bad
              a = [1, 2,]
              
              # good
              a = [
                1,
                2,
              ]

              Example: EnforcedStyleForMultiline: no_comma (default)

              # bad
              a = [1, 2,]
              
              # good
              a = [
                1,
                2
              ]

              Redundant curly braces around a hash parameter.
              Open

                  link_to(text, url, { id: id, remote: true })

              This cop checks for braces around the last parameter in a method call if the last parameter is a hash. It supports braces, no_braces and context_dependent styles.

              Example: EnforcedStyle: braces

              # The `braces` style enforces braces around all method
              # parameters that are hashes.
              
              # bad
              some_method(x, y, a: 1, b: 2)
              
              # good
              some_method(x, y, {a: 1, b: 2})

              Example: EnforcedStyle: no_braces (default)

              # The `no_braces` style checks that the last parameter doesn't
              # have braces around it.
              
              # bad
              some_method(x, y, {a: 1, b: 2})
              
              # good
              some_method(x, y, a: 1, b: 2)

              Example: EnforcedStyle: context_dependent

              # The `context_dependent` style checks that the last parameter
              # doesn't have braces around it, but requires braces if the
              # second to last parameter is also a hash literal.
              
              # bad
              some_method(x, y, {a: 1, b: 2})
              some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)
              
              # good
              some_method(x, y, a: 1, b: 2)
              some_method(x, y, {a: 1, b: 2}, {a: 1, b: 2})

              Use \ instead of + or << to concatenate those strings.
              Open

                    '</ul></div>' +

              This cop checks for string literal concatenation at the end of a line.

              Example:

              # bad
              some_str = 'ala' +
                         'bala'
              
              some_str = 'ala' <<
                         'bala'
              
              # good
              some_str = 'ala' \
                         'bala'

              Prefer single-quoted strings inside interpolations.
              Open

                    option_tags = options_for_select([["- no #{"sub-" if level > 1}#{display_label_for(extended_field).singularize.downcase} -", '']])

              This cop checks that quotes inside the string interpolation match the configured preference.

              Example: EnforcedStyle: single_quotes (default)

              # bad
              result = "Tests #{success ? "PASS" : "FAIL"}"
              
              # good
              result = "Tests #{success ? 'PASS' : 'FAIL'}"

              Example: EnforcedStyle: double_quotes

              # bad
              result = "Tests #{success ? 'PASS' : 'FAIL'}"
              
              # good
              result = "Tests #{success ? "PASS" : "FAIL"}"

              Avoid comma after the last item of a hash.
              Open

                    current: false,

              This cop checks for trailing comma in array and hash literals.

              Example: EnforcedStyleForMultiline: consistent_comma

              # bad
              a = [1, 2,]
              
              # good
              a = [
                1, 2,
                3,
              ]
              
              # good
              a = [
                1,
                2,
              ]

              Example: EnforcedStyleForMultiline: comma

              # bad
              a = [1, 2,]
              
              # good
              a = [
                1,
                2,
              ]

              Example: EnforcedStyleForMultiline: no_comma (default)

              # bad
              a = [1, 2,]
              
              # good
              a = [
                1,
                2
              ]

              Redundant curly braces around a hash parameter.
              Open

                  content_tag('div', select, { id: "hidden_choices_topic_type_select_#{record.id}", style: 'display:none;' })

              This cop checks for braces around the last parameter in a method call if the last parameter is a hash. It supports braces, no_braces and context_dependent styles.

              Example: EnforcedStyle: braces

              # The `braces` style enforces braces around all method
              # parameters that are hashes.
              
              # bad
              some_method(x, y, a: 1, b: 2)
              
              # good
              some_method(x, y, {a: 1, b: 2})

              Example: EnforcedStyle: no_braces (default)

              # The `no_braces` style checks that the last parameter doesn't
              # have braces around it.
              
              # bad
              some_method(x, y, {a: 1, b: 2})
              
              # good
              some_method(x, y, a: 1, b: 2)

              Example: EnforcedStyle: context_dependent

              # The `context_dependent` style checks that the last parameter
              # doesn't have braces around it, but requires braces if the
              # second to last parameter is also a hash literal.
              
              # bad
              some_method(x, y, {a: 1, b: 2})
              some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)
              
              # good
              some_method(x, y, a: 1, b: 2)
              some_method(x, y, {a: 1, b: 2}, {a: 1, b: 2})

              Avoid rescuing without specifying an error class.
              Open

                rescue

              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

              Redundant curly braces around a hash parameter.
              Open

                  checkbox = check_box('record', 'circa', { checked: (!record.new_record? && record.circa?) })

              This cop checks for braces around the last parameter in a method call if the last parameter is a hash. It supports braces, no_braces and context_dependent styles.

              Example: EnforcedStyle: braces

              # The `braces` style enforces braces around all method
              # parameters that are hashes.
              
              # bad
              some_method(x, y, a: 1, b: 2)
              
              # good
              some_method(x, y, {a: 1, b: 2})

              Example: EnforcedStyle: no_braces (default)

              # The `no_braces` style checks that the last parameter doesn't
              # have braces around it.
              
              # bad
              some_method(x, y, {a: 1, b: 2})
              
              # good
              some_method(x, y, a: 1, b: 2)

              Example: EnforcedStyle: context_dependent

              # The `context_dependent` style checks that the last parameter
              # doesn't have braces around it, but requires braces if the
              # second to last parameter is also a hash literal.
              
              # bad
              some_method(x, y, {a: 1, b: 2})
              some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)
              
              # good
              some_method(x, y, a: 1, b: 2)
              some_method(x, y, {a: 1, b: 2}, {a: 1, b: 2})

              Convert if nested inside else to elsif.
              Open

                    value = value['value'] if value.is_a?(Hash) && value['value']

              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 \ instead of + or << to concatenate those strings.
              Open

                    '<div id="link_choice_values">' +

              This cop checks for string literal concatenation at the end of a line.

              Example:

              # bad
              some_str = 'ala' +
                         'bala'
              
              some_str = 'ala' <<
                         'bala'
              
              # good
              some_str = 'ala' \
                         'bala'

              Use \ instead of + or << to concatenate those strings.
              Open

                    '</div>' +

              This cop checks for string literal concatenation at the end of a line.

              Example:

              # bad
              some_str = 'ala' +
                         'bala'
              
              some_str = 'ala' <<
                         'bala'
              
              # good
              some_str = 'ala' \
                         'bala'

              Use choices.size.positive? instead of choices.size > 0.
              Open

                  if choices.size > 0

              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 &:label as an argument to map instead of a block.
              Open

                  choices = choices.map { |c| c.label }

              Use symbols as procs when possible.

              Example:

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

              Use self-assignment shorthand +=.
              Open

                      memo = memo + content_tag('li', choice)

              This cop enforces the use the shorthand for self-assignment.

              Example:

              # bad
              x = x + 1
              
              # good
              x += 1

              Useless assignment to variable - choices.
              Open

                  choices = choices.map { |c| c.label }

              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

              Pass &:label as an argument to map instead of a block.
              Open

                  record.children.map { |c| c.label }.join(', ')

              Use symbols as procs when possible.

              Example:

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

              Pass &:last as an argument to collect instead of a block.
              Open

                    field_values.reject { |k, v| k == 'xml_element_name' }.sort.collect { |v| v.last } || []

              Use symbols as procs when possible.

              Example:

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

              Redundant curly braces around a hash parameter.
              Open

                    { class: (options[:current] ? 'current' : '') }

              This cop checks for braces around the last parameter in a method call if the last parameter is a hash. It supports braces, no_braces and context_dependent styles.

              Example: EnforcedStyle: braces

              # The `braces` style enforces braces around all method
              # parameters that are hashes.
              
              # bad
              some_method(x, y, a: 1, b: 2)
              
              # good
              some_method(x, y, {a: 1, b: 2})

              Example: EnforcedStyle: no_braces (default)

              # The `no_braces` style checks that the last parameter doesn't
              # have braces around it.
              
              # bad
              some_method(x, y, {a: 1, b: 2})
              
              # good
              some_method(x, y, a: 1, b: 2)

              Example: EnforcedStyle: context_dependent

              # The `context_dependent` style checks that the last parameter
              # doesn't have braces around it, but requires braces if the
              # second to last parameter is also a hash literal.
              
              # bad
              some_method(x, y, {a: 1, b: 2})
              some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)
              
              # good
              some_method(x, y, a: 1, b: 2)
              some_method(x, y, {a: 1, b: 2}, {a: 1, b: 2})

              Use !empty? instead of size > 0.
              Open

                  if choices.size > 0

              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?

              Redundant curly braces around a hash parameter.
              Open

                    {
                      indicator: spinner_id,
                      update: "#{id}_results",
                      url: {
                        controller: 'extended_fields',

              This cop checks for braces around the last parameter in a method call if the last parameter is a hash. It supports braces, no_braces and context_dependent styles.

              Example: EnforcedStyle: braces

              # The `braces` style enforces braces around all method
              # parameters that are hashes.
              
              # bad
              some_method(x, y, a: 1, b: 2)
              
              # good
              some_method(x, y, {a: 1, b: 2})

              Example: EnforcedStyle: no_braces (default)

              # The `no_braces` style checks that the last parameter doesn't
              # have braces around it.
              
              # bad
              some_method(x, y, {a: 1, b: 2})
              
              # good
              some_method(x, y, a: 1, b: 2)

              Example: EnforcedStyle: context_dependent

              # The `context_dependent` style checks that the last parameter
              # doesn't have braces around it, but requires braces if the
              # second to last parameter is also a hash literal.
              
              # bad
              some_method(x, y, {a: 1, b: 2})
              some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)
              
              # good
              some_method(x, y, a: 1, b: 2)
              some_method(x, y, {a: 1, b: 2}, {a: 1, b: 2})

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

                  if choices.size > 0
                    option_tags = options_for_select(
                      [["- choose #{"sub-" if level > 1}#{display_label_for(extended_field).singularize.downcase} -", '']] +
                                                             choices.map { |c| [c.label, c.value] }, value
                    )

              Avoid rescuing without specifying an error class.
              Open

                rescue

              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

              Redundant curly braces around a hash parameter.
              Open

                    { class: 'select', tabindex: '1' }

              This cop checks for braces around the last parameter in a method call if the last parameter is a hash. It supports braces, no_braces and context_dependent styles.

              Example: EnforcedStyle: braces

              # The `braces` style enforces braces around all method
              # parameters that are hashes.
              
              # bad
              some_method(x, y, a: 1, b: 2)
              
              # good
              some_method(x, y, {a: 1, b: 2})

              Example: EnforcedStyle: no_braces (default)

              # The `no_braces` style checks that the last parameter doesn't
              # have braces around it.
              
              # bad
              some_method(x, y, {a: 1, b: 2})
              
              # good
              some_method(x, y, a: 1, b: 2)

              Example: EnforcedStyle: context_dependent

              # The `context_dependent` style checks that the last parameter
              # doesn't have braces around it, but requires braces if the
              # second to last parameter is also a hash literal.
              
              # bad
              some_method(x, y, {a: 1, b: 2})
              some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)
              
              # good
              some_method(x, y, a: 1, b: 2)
              some_method(x, y, {a: 1, b: 2}, {a: 1, b: 2})

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

                  elsif %w(map map_address).member?(extended_field.ftype)

              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 \ instead of + or << to concatenate those strings.
              Open

                    '</div>' +

              This cop checks for string literal concatenation at the end of a line.

              Example:

              # bad
              some_str = 'ala' +
                         'bala'
              
              some_str = 'ala' <<
                         'bala'
              
              # good
              some_str = 'ala' \
                         'bala'

              Use \ instead of + or << to concatenate those strings.
              Open

                    '<div id="allow_user_additions">' +

              This cop checks for string literal concatenation at the end of a line.

              Example:

              # bad
              some_str = 'ala' +
                         'bala'
              
              some_str = 'ala' <<
                         'bala'
              
              # good
              some_str = 'ala' \
                         'bala'

              Use self-assignment shorthand +=.
              Open

                        m = m + build_ul_for_choice(child, record)

              This cop enforces the use the shorthand for self-assignment.

              Example:

              # bad
              x = x + 1
              
              # good
              x += 1

              Prefer single-quoted strings inside interpolations.
              Open

                      [["- choose #{"sub-" if level > 1}#{display_label_for(extended_field).singularize.downcase} -", '']] +

              This cop checks that quotes inside the string interpolation match the configured preference.

              Example: EnforcedStyle: single_quotes (default)

              # bad
              result = "Tests #{success ? "PASS" : "FAIL"}"
              
              # good
              result = "Tests #{success ? 'PASS' : 'FAIL'}"

              Example: EnforcedStyle: double_quotes

              # bad
              result = "Tests #{success ? 'PASS' : 'FAIL'}"
              
              # good
              result = "Tests #{success ? "PASS" : "FAIL"}"

              Redundant curly braces around a hash parameter.
              Open

                            { title: choice.value }

              This cop checks for braces around the last parameter in a method call if the last parameter is a hash. It supports braces, no_braces and context_dependent styles.

              Example: EnforcedStyle: braces

              # The `braces` style enforces braces around all method
              # parameters that are hashes.
              
              # bad
              some_method(x, y, a: 1, b: 2)
              
              # good
              some_method(x, y, {a: 1, b: 2})

              Example: EnforcedStyle: no_braces (default)

              # The `no_braces` style checks that the last parameter doesn't
              # have braces around it.
              
              # bad
              some_method(x, y, {a: 1, b: 2})
              
              # good
              some_method(x, y, a: 1, b: 2)

              Example: EnforcedStyle: context_dependent

              # The `context_dependent` style checks that the last parameter
              # doesn't have braces around it, but requires braces if the
              # second to last parameter is also a hash literal.
              
              # bad
              some_method(x, y, {a: 1, b: 2})
              some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)
              
              # good
              some_method(x, y, a: 1, b: 2)
              some_method(x, y, {a: 1, b: 2}, {a: 1, b: 2})

              Use self-assignment shorthand +=.
              Open

                      memo = memo + content_tag('li', choice)

              This cop enforces the use the shorthand for self-assignment.

              Example:

              # bad
              x = x + 1
              
              # good
              x += 1

              There are no issues that match your filters.

              Category
              Status