app/models/search_source.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Unprotected mass assignment
Open

        ss = SearchSource.new(attrs)
Severity: Minor
Found in app/models/search_source.rb by brakeman

Mass assignment is a feature of Rails which allows an application to create a record from the values of a hash.

Example:

User.new(params[:user])

Unfortunately, if there is a user field called admin which controls administrator access, now any user can make themselves an administrator.

attr_accessible and attr_protected can be used to limit mass assignment. However, Brakeman will warn unless attr_accessible is used, or mass assignment is completely disabled.

There are two different mass assignment warnings which can arise. The first is when mass assignment actually occurs, such as the example above. This results in a warning like

Unprotected mass assignment near line 61: User.new(params[:user])

The other warning is raised whenever a model is found which does not use attr_accessible. This produces generic warnings like

Mass assignment is not restricted using attr_accessible

with a list of affected models.

In Rails 3.1 and newer, mass assignment can easily be disabled:

config.active_record.whitelist_attributes = true

Unfortunately, it can also easily be bypassed:

User.new(params[:user], :without_protection => true)

Brakeman will warn on uses of without_protection.

Mass assignment is not restricted using attr_accessible
Open

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

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

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

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

Note that disabling mass assignment globally will suppress these warnings.

Insufficient validation for 'base_url' using /^http:\/\/.*/. Use \A and \z as anchors
Open

  validates_format_of :base_url, with: /^http:\/\/.*/, message: I18n.t('search_source_model.requires_http')
Severity: Critical
Found in app/models/search_source.rb by brakeman

Calls to validates_format_of ..., :with => // which do not use \A and \z as anchors will cause this warning. Using ^ and $ is not sufficient, as they will only match up to a new line. This allows an attacker to put whatever malicious input they would like before or after a new line character.

See the Ruby Security Guide for details.

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

class SearchSource < ActiveRecord::Base
  acts_as_list

  validates_presence_of :title, :source_type
  validates_format_of :base_url, with: /^http:\/\/.*/, message: I18n.t('search_source_model.requires_http')
Severity: Minor
Found in app/models/search_source.rb by rubocop

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

Assignment Branch Condition size for parse_search_text is too high. [40.76/15]
Open

  def parse_search_text(search_text)
    if or_syntax && !or_syntax[:position].blank? && or_syntax[:position] != 'none'
      or_string = or_syntax[:case] == 'upper' ? 'OR' : 'or'
      search_text =
        case or_syntax[:position]
Severity: Minor
Found in app/models/search_source.rb by rubocop

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

Method parse_search_text has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_search_text(search_text)
    if or_syntax && !or_syntax[:position].blank? && or_syntax[:position] != 'none'
      or_string = or_syntax[:case] == 'upper' ? 'OR' : 'or'
      search_text =
        case or_syntax[:position]
Severity: Minor
Found in app/models/search_source.rb - About 3 hrs to fix

Cognitive Complexity

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

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

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

Further reading

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

  def parse_search_text(search_text)
    if or_syntax && !or_syntax[:position].blank? && or_syntax[:position] != 'none'
      or_string = or_syntax[:case] == 'upper' ? 'OR' : 'or'
      search_text =
        case or_syntax[:position]
Severity: Minor
Found in app/models/search_source.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 parse_search_text is too high. [17/6]
Open

  def parse_search_text(search_text)
    if or_syntax && !or_syntax[:position].blank? && or_syntax[:position] != 'none'
      or_string = or_syntax[:case] == 'upper' ? 'OR' : 'or'
      search_text =
        case or_syntax[:position]
Severity: Minor
Found in app/models/search_source.rb by rubocop

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

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

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

  def self.import_from_yaml(yaml_file, options = {})
    options = { verbose: true }.merge(options)

    attr_sets = YAML.load(File.open(yaml_file))
    attr_sets.each do |attrs|
Severity: Minor
Found in app/models/search_source.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 import_from_yaml is too high. [25.32/15]
Open

  def self.import_from_yaml(yaml_file, options = {})
    options = { verbose: true }.merge(options)

    attr_sets = YAML.load(File.open(yaml_file))
    attr_sets.each do |attrs|
Severity: Minor
Found in app/models/search_source.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 parse_search_text is too high. [16/7]
Open

  def parse_search_text(search_text)
    if or_syntax && !or_syntax[:position].blank? && or_syntax[:position] != 'none'
      or_string = or_syntax[:case] == 'upper' ? 'OR' : 'or'
      search_text =
        case or_syntax[:position]
Severity: Minor
Found in app/models/search_source.rb by rubocop

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

Example:

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

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

  def fetch(search_text, options = {})
    return { total: 0 } if search_text.blank?

    logger.debug "Search text before parsing: #{search_text}"
    parse_search_text(search_text)
Severity: Minor
Found in app/models/search_source.rb by rubocop

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

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

  def sort_entries(entries, options = {})
    total = 0
    links = []
    images = []
    entries[0..((options[:limit] || limit) - 1)].each do |entry|
Severity: Minor
Found in app/models/search_source.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 fetch is too high. [18.36/15]
Open

  def fetch(search_text, options = {})
    return { total: 0 } if search_text.blank?

    logger.debug "Search text before parsing: #{search_text}"
    parse_search_text(search_text)
Severity: Minor
Found in app/models/search_source.rb by rubocop

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

Method parse_search_text has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def parse_search_text(search_text)
    if or_syntax && !or_syntax[:position].blank? && or_syntax[:position] != 'none'
      or_string = or_syntax[:case] == 'upper' ? 'OR' : 'or'
      search_text =
        case or_syntax[:position]
Severity: Minor
Found in app/models/search_source.rb - About 1 hr to fix

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

      def self.import_from_yaml(yaml_file, options = {})
        options = { verbose: true }.merge(options)
    
        attr_sets = YAML.load(File.open(yaml_file))
        attr_sets.each do |attrs|
    Severity: Minor
    Found in app/models/search_source.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

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

          [I18n.t('search_source_model.or_positions.after_terms'), 'after']]
    Severity: Minor
    Found in app/models/search_source.rb by rubocop

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

    When using the symmetrical (default) style:

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

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

    When using the new_line style:

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

    When using the same_line style:

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

    Example: EnforcedStyle: symmetrical (default)

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

    Example: EnforcedStyle: new_line

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

    Example: EnforcedStyle: same_line

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

    Avoid rescuing without specifying an error class.
    Open

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

    Pass __FILE__ and __LINE__ to eval method, as they are used by backtraces.
    Open

        class_eval("@@acceptable_#{config} = ExternalSearchSources[config.to_sym]")
    Severity: Minor
    Found in app/models/search_source.rb by rubocop

    This cop checks eval method usage. eval can receive source location metadata, that are filename and line number. The metadata is used by backtraces. This cop recommends to pass the metadata to eval method.

    Example:

    # bad
    eval <<-RUBY
      def do_something
      end
    RUBY
    
    # bad
    C.class_eval <<-RUBY
      def do_something
      end
    RUBY
    
    # good
    eval <<-RUBY, binding, __FILE__, __LINE__ + 1
      def do_something
      end
    RUBY
    
    # good
    C.class_eval <<-RUBY, __FILE__, __LINE__ + 1
      def do_something
      end
    RUBY

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

        %w{jpg png gif tif bmp}.include?(link.split('.').last.downcase)
    Severity: Minor
    Found in app/models/search_source.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)

    URI.escape method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case.
    Open

        @search_text = URI.escape(search_text, /\W/)
    Severity: Minor
    Found in app/models/search_source.rb by rubocop

    This cop identifies places where URI.escape can be replaced by CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case. Also this cop identifies places where URI.unescape can be replaced by CGI.unescape, URI.decode_www_form or URI.decode_www_form_component depending on your specific use case.

    Example:

    # bad
    URI.escape('http://example.com')
    URI.encode('http://example.com')
    
    # good
    CGI.escape('http://example.com')
    URI.encode_www_form([['example', 'param'], ['lang', 'en']])
    URI.encode_www_form(page: 10, locale: 'en')
    URI.encode_www_form_component('http://example.com')
    
    # bad
    URI.unescape(enc_uri)
    URI.decode(enc_uri)
    
    # good
    CGI.unescape(enc_uri)
    URI.decode_www_form(enc_uri)
    URI.decode_www_form_component(enc_uri)

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

          [I18n.t('search_source_model.case_values.lowercase'), 'lower']]
    Severity: Minor
    Found in app/models/search_source.rb by rubocop

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

    When using the symmetrical (default) style:

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

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

    When using the new_line style:

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

    When using the same_line style:

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

    Example: EnforcedStyle: symmetrical (default)

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

    Example: EnforcedStyle: new_line

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

    Example: EnforcedStyle: same_line

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

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

      %w{source_types source_targets limit_params}.each do |config|
    Severity: Minor
    Found in app/models/search_source.rb by rubocop

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

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

    Example:

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

    Use %r around regular expression.
    Open

      validates_format_of :base_url, with: /^http:\/\/.*/, message: I18n.t('search_source_model.requires_http')
    Severity: Minor
    Found in app/models/search_source.rb by rubocop

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

    Example: EnforcedStyle: slashes (default)

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

    Example: EnforcedStyle: percent_r

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

    Example: EnforcedStyle: mixed

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

    Example: AllowInnerSlashes: false (default)

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

    Example: AllowInnerSlashes: true

    # good
    x =~ /home\//

    URI.escape method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case.
    Open

        URI.escape(base_url) + @search_text + @limit_string.to_s
    Severity: Minor
    Found in app/models/search_source.rb by rubocop

    This cop identifies places where URI.escape can be replaced by CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case. Also this cop identifies places where URI.unescape can be replaced by CGI.unescape, URI.decode_www_form or URI.decode_www_form_component depending on your specific use case.

    Example:

    # bad
    URI.escape('http://example.com')
    URI.encode('http://example.com')
    
    # good
    CGI.escape('http://example.com')
    URI.encode_www_form([['example', 'param'], ['lang', 'en']])
    URI.encode_www_form(page: 10, locale: 'en')
    URI.encode_www_form_component('http://example.com')
    
    # bad
    URI.unescape(enc_uri)
    URI.decode(enc_uri)
    
    # good
    CGI.unescape(enc_uri)
    URI.decode_www_form(enc_uri)
    URI.decode_www_form_component(enc_uri)

    URI.escape method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case.
    Open

        URI.escape(more_link_base_url) + @search_text + @limit_string.to_s
    Severity: Minor
    Found in app/models/search_source.rb by rubocop

    This cop identifies places where URI.escape can be replaced by CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case. Also this cop identifies places where URI.unescape can be replaced by CGI.unescape, URI.decode_www_form or URI.decode_www_form_component depending on your specific use case.

    Example:

    # bad
    URI.escape('http://example.com')
    URI.encode('http://example.com')
    
    # good
    CGI.escape('http://example.com')
    URI.encode_www_form([['example', 'param'], ['lang', 'en']])
    URI.encode_www_form(page: 10, locale: 'en')
    URI.encode_www_form_component('http://example.com')
    
    # bad
    URI.unescape(enc_uri)
    URI.decode(enc_uri)
    
    # good
    CGI.unescape(enc_uri)
    URI.decode_www_form(enc_uri)
    URI.decode_www_form_component(enc_uri)

    Pass __FILE__ and __LINE__ to eval method, as they are used by backtraces.
    Open

        validates_inclusion_of config.singularize.to_sym, in: class_eval("@@acceptable_#{config}"), allow_blank: (config == 'limit_params'),
    Severity: Minor
    Found in app/models/search_source.rb by rubocop

    This cop checks eval method usage. eval can receive source location metadata, that are filename and line number. The metadata is used by backtraces. This cop recommends to pass the metadata to eval method.

    Example:

    # bad
    eval <<-RUBY
      def do_something
      end
    RUBY
    
    # bad
    C.class_eval <<-RUBY
      def do_something
      end
    RUBY
    
    # good
    eval <<-RUBY, binding, __FILE__, __LINE__ + 1
      def do_something
      end
    RUBY
    
    # good
    C.class_eval <<-RUBY, __FILE__, __LINE__ + 1
      def do_something
      end
    RUBY

    Pass __FILE__ and __LINE__ to eval method, as they are used by backtraces.
    Open

                                                          message: I18n.t('search_source_model.must_be_one_of', types: class_eval("@@acceptable_#{config}.join(', ')"))
    Severity: Minor
    Found in app/models/search_source.rb by rubocop

    This cop checks eval method usage. eval can receive source location metadata, that are filename and line number. The metadata is used by backtraces. This cop recommends to pass the metadata to eval method.

    Example:

    # bad
    eval <<-RUBY
      def do_something
      end
    RUBY
    
    # bad
    C.class_eval <<-RUBY
      def do_something
      end
    RUBY
    
    # good
    eval <<-RUBY, binding, __FILE__, __LINE__ + 1
      def do_something
      end
    RUBY
    
    # good
    C.class_eval <<-RUBY, __FILE__, __LINE__ + 1
      def do_something
      end
    RUBY

    Avoid rescuing without specifying an error class.
    Open

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

    end at 146, 27 is not aligned with case at 137, 8.
    Open

                               end
    Severity: Minor
    Found in app/models/search_source.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)

    Redundant curly braces around a hash parameter.
    Open

          feed = Feedzirra::Feed.fetch_and_parse(source_url, { timeout: ExternalSearchSources[:timeout] })
    Severity: Minor
    Found in app/models/search_source.rb by rubocop

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

    Prefer using YAML.safe_load over YAML.load.
    Open

        attr_sets = YAML.load(File.open(yaml_file))
    Severity: Minor
    Found in app/models/search_source.rb by rubocop

    This cop checks for the use of YAML class methods which have potential security issues leading to remote code execution when loading from an untrusted source.

    Example:

    # bad
    YAML.load("--- foo")
    
    # good
    YAML.safe_load("--- foo")
    YAML.dump("foo")

    Prefer single-quoted strings inside interpolations.
    Open

            puts "Inserted search source: '#{attrs["title"]}'." if options[:verbose]
    Severity: Minor
    Found in app/models/search_source.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 $ERROR_INFO from the stdlib 'English' module (don't forget to require it) over $!.
    Open

            puts "Inserting search source '#{attrs["title"]}' failed: #{$!}"
    Severity: Minor
    Found in app/models/search_source.rb by rubocop

    Prefer single-quoted strings inside interpolations.
    Open

            puts "Inserting search source '#{attrs["title"]}' failed: #{$!}"
    Severity: Minor
    Found in app/models/search_source.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"}"

    There are no issues that match your filters.

    Category
    Status