lib/extended_content_helpers.rb

Summary

Maintainability
F
3 days
Test Coverage

Method extended_content_field_xml_tag has a Cognitive Complexity of 100 (exceeds 5 allowed). Consider refactoring.
Open

    def extended_content_field_xml_tag(options = {})
      xml = options[:xml]
      field = options[:field]
      value = options[:value] || nil
      xml_element_name = options[:xml_element_name] || nil
Severity: Minor
Found in lib/extended_content_helpers.rb - About 2 days 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

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

module ExtendedContentHelpers
  unless included_modules.include? ExtendedContentHelpers

    def oai_dc_xml_dc_extended_content(xml, item = self)
      @builder_instance = xml
Severity: Minor
Found in lib/extended_content_helpers.rb by rubocop

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

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

    def extended_content_field_xml_tag(options = {})
      xml = options[:xml]
      field = options[:field]
      value = options[:value] || nil
      xml_element_name = options[:xml_element_name] || nil
Severity: Minor
Found in lib/extended_content_helpers.rb by rubocop

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

Assignment Branch Condition size for extended_content_field_xml_tag is too high. [87.64/15]
Open

    def extended_content_field_xml_tag(options = {})
      xml = options[:xml]
      field = options[:field]
      value = options[:value] || nil
      xml_element_name = options[:xml_element_name] || nil
Severity: Minor
Found in lib/extended_content_helpers.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 oai_dc_xml_for_field_dataset is too high. [61.48/15]
Open

    def oai_dc_xml_for_field_dataset(field_key, data)
      original_field_key = field_key.gsub(/_multiple/, '')

      if data.is_a?(String)
        # This works as expected
Severity: Minor
Found in lib/extended_content_helpers.rb by rubocop

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

Perceived complexity for extended_content_field_xml_tag is too high. [37/7]
Open

    def extended_content_field_xml_tag(options = {})
      xml = options[:xml]
      field = options[:field]
      value = options[:value] || nil
      xml_element_name = options[:xml_element_name] || nil
Severity: Minor
Found in lib/extended_content_helpers.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 oai_dc_xml_for_field_dataset has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def oai_dc_xml_for_field_dataset(field_key, data)
      original_field_key = field_key.gsub(/_multiple/, '')

      if data.is_a?(String)
        # This works as expected
Severity: Minor
Found in lib/extended_content_helpers.rb - About 4 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

    def oai_dc_xml_for_field_dataset(field_key, data)
      original_field_key = field_key.gsub(/_multiple/, '')

      if data.is_a?(String)
        # This works as expected
Severity: Minor
Found in lib/extended_content_helpers.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 extended_content_field_xml_tag is too high. [31/6]
Open

    def extended_content_field_xml_tag(options = {})
      xml = options[:xml]
      field = options[:field]
      value = options[:value] || nil
      xml_element_name = options[:xml_element_name] || nil
Severity: Minor
Found in lib/extended_content_helpers.rb by rubocop

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

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

Method extended_content_field_xml_tag has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def extended_content_field_xml_tag(options = {})
      xml = options[:xml]
      field = options[:field]
      value = options[:value] || nil
      xml_element_name = options[:xml_element_name] || nil
Severity: Major
Found in lib/extended_content_helpers.rb - About 3 hrs to fix

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

        def oai_dc_xml_dc_extended_content(xml, item = self)
          @builder_instance = xml
    
          # We start with something like: {"text_field_multiple"=>{"2"=>{"text_field"=>{"xml_element_name"=>"dc:description", "value"=>"Value"}}, "3"=>{"text_field"=>{"xml_element_name"=>"dc:description", "value"=>"Second value"}}}, "married"=>"No", "check_boxes_multiple"=>{"1"=>{"check_boxes"=>"Yes"}}, "vehicle_type"=>{"1"=>"Car", "2"=>"Coupé"}, "truck_type_multiple"=>{"1"=>{"truck_type"=>{"1"=>"Lorry"}}, "2"=>{"truck_type"=>{"1"=>"Tractor Unit", "2"=>"Tractor with one trailer"}}}}
    
    
    Severity: Minor
    Found in lib/extended_content_helpers.rb by rubocop

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

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

        def oai_dc_xml_for_field_dataset(field_key, data)
          original_field_key = field_key.gsub(/_multiple/, '')
    
          if data.is_a?(String)
            # This works as expected
    Severity: Minor
    Found in lib/extended_content_helpers.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

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

        def oai_dc_xml_for_field_dataset(field_key, data)
          original_field_key = field_key.gsub(/_multiple/, '')
    
          if data.is_a?(String)
            # This works as expected
    Severity: Minor
    Found in lib/extended_content_helpers.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 oai_dc_xml_dc_extended_content is too high. [21.75/15]
    Open

        def oai_dc_xml_dc_extended_content(xml, item = self)
          @builder_instance = xml
    
          # We start with something like: {"text_field_multiple"=>{"2"=>{"text_field"=>{"xml_element_name"=>"dc:description", "value"=>"Value"}}, "3"=>{"text_field"=>{"xml_element_name"=>"dc:description", "value"=>"Second value"}}}, "married"=>"No", "check_boxes_multiple"=>{"1"=>{"check_boxes"=>"Yes"}}, "vehicle_type"=>{"1"=>"Car", "2"=>"Coupé"}, "truck_type_multiple"=>{"1"=>{"truck_type"=>{"1"=>"Lorry"}}, "2"=>{"truck_type"=>{"1"=>"Tractor Unit", "2"=>"Tractor with one trailer"}}}}
    
    
    Severity: Minor
    Found in lib/extended_content_helpers.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

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

            xml.safe_send(field, options) do |tag|
              value.each_pair do |k, v|
                # convert to string so we don't get errors when running match later
                v = v.to_s
    
    
    Severity: Minor
    Found in lib/extended_content_helpers.rb by rubocop

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

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

              value.each_pair do |k, v|
                # convert to string so we don't get errors when running match later
                v = v.to_s
    
                next if v.blank?
    Severity: Minor
    Found in lib/extended_content_helpers.rb by rubocop

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

    Method oai_dc_xml_for_field_dataset has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def oai_dc_xml_for_field_dataset(field_key, data)
          original_field_key = field_key.gsub(/_multiple/, '')
    
          if data.is_a?(String)
            # This works as expected
    Severity: Minor
    Found in lib/extended_content_helpers.rb - About 1 hr to fix

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

          def oai_dc_xml_dc_extended_content(xml, item = self)
            @builder_instance = xml
      
            # We start with something like: {"text_field_multiple"=>{"2"=>{"text_field"=>{"xml_element_name"=>"dc:description", "value"=>"Value"}}, "3"=>{"text_field"=>{"xml_element_name"=>"dc:description", "value"=>"Second value"}}}, "married"=>"No", "check_boxes_multiple"=>{"1"=>{"check_boxes"=>"Yes"}}, "vehicle_type"=>{"1"=>"Car", "2"=>"Coupé"}, "truck_type_multiple"=>{"1"=>{"truck_type"=>{"1"=>"Lorry"}}, "2"=>{"truck_type"=>{"1"=>"Tractor Unit", "2"=>"Tractor with one trailer"}}}}
      
      
      Severity: Minor
      Found in lib/extended_content_helpers.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

      Consider simplifying this complex logical expression.
      Open

        unless included_modules.include? ExtendedContentHelpers
      
          def oai_dc_xml_dc_extended_content(xml, item = self)
            @builder_instance = xml
      
      
      Severity: Major
      Found in lib/extended_content_helpers.rb - About 1 hr to fix

        Avoid more than 3 levels of block nesting.
        Open

                      if matching_choice
                        tag.safe_send(k, matching_choice.value, label: matching_choice.label)
                      else
                        # otherwise leave value to handled by validation
                        # will likely fail, but they will get error feedback and can modify
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        This cop checks for excessive nesting of conditional and looping constructs.

        You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

        The maximum level of nesting allowed is configurable.

        Avoid more than 3 levels of block nesting.
        Open

                  if data['circa'] == '1'
                    five_years_before, five_years_after = (data['value'].to_i - 5), (data['value'].to_i + 5)
                    @builder_instance.send('dc:date', Time.zone.parse("#{five_years_before}-01-01").xmlschema)
                    @builder_instance.send('dc:date', Time.zone.parse("#{five_years_after}-12-31").xmlschema)
                  end
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        This cop checks for excessive nesting of conditional and looping constructs.

        You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

        The maximum level of nesting allowed is configurable.

        Avoid more than 3 levels of block nesting.
        Open

                        if matching_choice
                          choice = matching_choice
                        else
                          choice = Choice.create!(value: v, label: l)
                          choice.move_to_child_of(parent)
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        This cop checks for excessive nesting of conditional and looping constructs.

        You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

        The maximum level of nesting allowed is configurable.

        Avoid more than 3 levels of block nesting.
        Open

                  if data['xml_element_name'].include?('dc:')
                    @builder_instance.send(data['xml_element_name'], data['value'])
                  else
                    @builder_instance.safe_send(data['xml_element_name'], data['value'])
                  end
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        This cop checks for excessive nesting of conditional and looping constructs.

        You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

        The maximum level of nesting allowed is configurable.

        Avoid more than 3 levels of block nesting.
        Open

                  if data['xml_element_name'].include?('dc:')
                    # we want the namespace for dc xml_element_name
                    @builder_instance.send(data['xml_element_name'], ":#{data_for_values.join(":")}:")
                  else
                    @builder_instance.safe_send(data['xml_element_name'], ":#{data_for_values.join(":")}:")
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        This cop checks for excessive nesting of conditional and looping constructs.

        You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

        The maximum level of nesting allowed is configurable.

        Avoid more than 3 levels of block nesting.
        Open

                      rescue
                        next
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        This cop checks for excessive nesting of conditional and looping constructs.

        You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

        The maximum level of nesting allowed is configurable.

        Avoid more than 3 levels of block nesting.
        Open

                      if index && index >= 1
                        to_check = sorted_values.at(index - 1).last
                      end
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        This cop checks for excessive nesting of conditional and looping constructs.

        You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

        The maximum level of nesting allowed is configurable.

        Avoid more than 3 levels of block nesting.
        Open

                    if value.is_a?(Array) && value_label_hash?(value.first)
                      [nil, value.first['label'], value.first['value']]
                    elsif value.is_a?(String)
                      value.match(/(.+)\(([^\(\)]+)\)\Z/).to_a
                    else
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        This cop checks for excessive nesting of conditional and looping constructs.

        You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

        The maximum level of nesting allowed is configurable.

        Avoid more than 3 levels of block nesting.
        Open

                  unless parts.blank?
                    options[:label] = parts[1].chomp(' ')
                    value = parts[2]
                  end
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        This cop checks for excessive nesting of conditional and looping constructs.

        You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

        The maximum level of nesting allowed is configurable.

        Useless assignment to variable - parts.
        Open

                  parts = []
        Severity: Minor
        Found in lib/extended_content_helpers.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

        Do not use parallel assignment.
        Open

                    five_years_before, five_years_after = (data['value'].to_i - 5), (data['value'].to_i + 5)
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        Checks for simple usages of parallel assignment. This will only complain when the number of variables being assigned matched the number of assigning variables.

        Example:

        # bad
        a, b, c = 1, 2, 3
        a, b, c = [1, 2, 3]
        
        # good
        one, two = *foo
        a, b = foo()
        a, b = b, a
        
        a = 1
        b = 2
        c = 3

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

                    if !matching_choice_mapped && %w(autocomplete choice).include?(ftype) && user_choice_addition
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

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

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

        Example:

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

        Prefer single-quoted strings inside interpolations.
        Open

                    @builder_instance.safe_send(data['xml_element_name'], ":#{data_for_values.join(":")}:")
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        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"}"

        end at 226, 29 is not aligned with if at 220, 12.
        Open

                                     end
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        This cop checks whether the end keywords are aligned properly.

        Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

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

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

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

        Example: EnforcedStyleAlignWith: keyword (default)

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

        Example: EnforcedStyleAlignWith: variable

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

        Example: EnforcedStyleAlignWith: startofline

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

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

                    field_data.each_pair do |index, data|
        Severity: Minor
        Found in lib/extended_content_helpers.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

        Avoid rescuing without specifying an error class.
        Open

                      rescue
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

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

        Example: EnforcedStyle: implicit

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

        Example: EnforcedStyle: explicit (default)

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

        Convert if nested inside else to elsif.
        Open

                  if data['xml_element_name'].include?('dc:')
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

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

        Example:

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

        Use Hash#key? instead of Hash#has_key?.
        Open

              elsif data.has_key?('value')
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        This cop (by default) checks for uses of methods Hash#haskey? and Hash#hasvalue? where it enforces Hash#key? and Hash#value? It is configurable to enforce the inverse, using verbose method names also.

        Example: EnforcedStyle: short (default)

        # bad Hash#haskey? Hash#hasvalue?

        # good Hash#key? Hash#value?

        Example: EnforcedStyle: verbose

        # bad Hash#key? Hash#value?

        # good Hash#haskey? Hash#hasvalue?

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

              fields_in_sorted_array = fields_with_position.keys.sort_by { |s| s.to_s }.map { |key| fields_with_position[key] }
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        Use symbols as procs when possible.

        Example:

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

        Convert if nested inside else to elsif.
        Open

                  if data['xml_element_name'].include?('dc:')
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

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

        Example:

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

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

                data_for_values = data.reject { |k, v| k == 'xml_element_name' || k == 'label' }.map { |k, v| v }
        Severity: Minor
        Found in lib/extended_content_helpers.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

        Unnecessary utf-8 encoding comment.
        Open

        # -*- coding: utf-8 -*-
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        Use Hash#key? instead of Hash#has_key?.
        Open

                if data.has_key?('circa')
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        This cop (by default) checks for uses of methods Hash#haskey? and Hash#hasvalue? where it enforces Hash#key? and Hash#value? It is configurable to enforce the inverse, using verbose method names also.

        Example: EnforcedStyle: short (default)

        # bad Hash#haskey? Hash#hasvalue?

        # good Hash#key? Hash#value?

        Example: EnforcedStyle: verbose

        # bad Hash#key? Hash#value?

        # good Hash#haskey? Hash#hasvalue?

        Prefer $ERROR_INFO from the stdlib 'English' module (don't forget to require it) over $!.
        Open

              logger.error("failed to format xml: #{$!}")
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        Use only ascii symbols in comments.
        Open

              # We start with something like: {"text_field_multiple"=>{"2"=>{"text_field"=>{"xml_element_name"=>"dc:description", "value"=>"Value"}}, "3"=>{"text_field"=>{"xml_element_name"=>"dc:description", "value"=>"Second value"}}}, "married"=>"No", "check_boxes_multiple"=>{"1"=>{"check_boxes"=>"Yes"}}, "vehicle_type"=>{"1"=>"Car", "2"=>"Coupé"}, "truck_type_multiple"=>{"1"=>{"truck_type"=>{"1"=>"Lorry"}}, "2"=>{"truck_type"=>{"1"=>"Tractor Unit", "2"=>"Tractor with one trailer"}}}}
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        This cop checks for non-ascii (non-English) characters in comments. You could set an array of allowed non-ascii chars in AllowedChars attribute (empty by default).

        Example:

        # bad
        # Translates from English to 日本語。
        
        # good
        # Translates from English to Japanese

        Avoid rescuing without specifying an error class.
        Open

            rescue
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

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

        Example: EnforcedStyle: implicit

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

        Example: EnforcedStyle: explicit (default)

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

        Convert if nested inside else to elsif.
        Open

                      if matching_choice
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

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

        Example:

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

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

                      if index && index >= 1
        Severity: Minor
        Found in lib/extended_content_helpers.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?

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

                unless %w(text textarea).include?(ftype)
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

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

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

        Example:

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

        Prefer single-quoted strings inside interpolations.
        Open

                  @anonymous_fields << [original_field_key, ":#{data_for_values.join(":")}:"]
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        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"}"

        Prefer single-quoted strings inside interpolations.
        Open

                    @builder_instance.send(data['xml_element_name'], ":#{data_for_values.join(":")}:")
        Severity: Minor
        Found in lib/extended_content_helpers.rb by rubocop

        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"}"

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

                data_for_values = data.reject { |k, v| k == 'xml_element_name' || k == 'label' }.map { |k, v| v }
        Severity: Minor
        Found in lib/extended_content_helpers.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

        There are no issues that match your filters.

        Category
        Status