spec/classes/document_search_spec.rb

Summary

Maintainability
D
2 days
Test Coverage

File document_search_spec.rb has 942 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rails_helper'

describe DocumentSearch do
  let(:query) { 'common' }
  let(:handles) { %w[agency_blogs] }
Severity: Major
Found in spec/classes/document_search_spec.rb - About 2 days to fix

    Omit the hash value.
    Open

            { handles: handles, language: :en, query: query, size: 10, offset: 0, include: %w[audience

    Checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    This cop has EnforcedShorthandSyntax option. It can enforce either the use of the explicit hash value syntax or the use of Ruby 3.1's hash value shorthand syntax.

    The supported styles are:

    • always - forces use of the 3.1 syntax (e.g. {foo:})
    • never - forces use of explicit hash literal value
    • either - accepts both shorthand and explicit use of hash literal value
    • consistent - forces use of the 3.1 syntax only if all values can be omitted in the hash

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Example: EnforcedShorthandSyntax: always (default)

    # bad
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: never

    # bad
    {foo:, bar:}
    
    # good
    {foo: foo, bar: bar}

    Example: EnforcedShorthandSyntax: either

    # good
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: consistent

    # bad - `foo` and `bar` values can be omitted
    {foo: foo, bar: bar}
    
    # bad - `bar` value can be omitted
    {foo:, bar: bar}
    
    # bad - mixed syntaxes
    {foo:, bar: baz}
    
    # good
    {foo:, bar:}
    
    # good - can't omit `baz`
    {foo: foo, bar: baz}

    Omit the hash value.
    Open

            document_search_results = described_class.new(search_options.merge(query: query, language: lang_code)).search

    Checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    This cop has EnforcedShorthandSyntax option. It can enforce either the use of the explicit hash value syntax or the use of Ruby 3.1's hash value shorthand syntax.

    The supported styles are:

    • always - forces use of the 3.1 syntax (e.g. {foo:})
    • never - forces use of explicit hash literal value
    • either - accepts both shorthand and explicit use of hash literal value
    • consistent - forces use of the 3.1 syntax only if all values can be omitted in the hash

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Example: EnforcedShorthandSyntax: always (default)

    # bad
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: never

    # bad
    {foo:, bar:}
    
    # good
    {foo: foo, bar: bar}

    Example: EnforcedShorthandSyntax: either

    # good
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: consistent

    # bad - `foo` and `bar` values can be omitted
    {foo: foo, bar: bar}
    
    # bad - `bar` value can be omitted
    {foo:, bar: bar}
    
    # bad - mixed syntaxes
    {foo:, bar: baz}
    
    # good
    {foo:, bar:}
    
    # good - can't omit `baz`
    {foo: foo, bar: baz}

    Omit the hash value.
    Open

            { handles: handles, language: :en, query: query, size: 10, offset: 0, include: %w[searchgov_custom1

    Checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    This cop has EnforcedShorthandSyntax option. It can enforce either the use of the explicit hash value syntax or the use of Ruby 3.1's hash value shorthand syntax.

    The supported styles are:

    • always - forces use of the 3.1 syntax (e.g. {foo:})
    • never - forces use of explicit hash literal value
    • either - accepts both shorthand and explicit use of hash literal value
    • consistent - forces use of the 3.1 syntax only if all values can be omitted in the hash

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Example: EnforcedShorthandSyntax: always (default)

    # bad
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: never

    # bad
    {foo:, bar:}
    
    # good
    {foo: foo, bar: bar}

    Example: EnforcedShorthandSyntax: either

    # good
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: consistent

    # bad - `foo` and `bar` values can be omitted
    {foo: foo, bar: bar}
    
    # bad - `bar` value can be omitted
    {foo:, bar: bar}
    
    # bad - mixed syntaxes
    {foo:, bar: baz}
    
    # good
    {foo:, bar:}
    
    # good - can't omit `baz`
    {foo: foo, bar: baz}

    Omit the hash value.
    Open

          handles: handles,

    Checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    This cop has EnforcedShorthandSyntax option. It can enforce either the use of the explicit hash value syntax or the use of Ruby 3.1's hash value shorthand syntax.

    The supported styles are:

    • always - forces use of the 3.1 syntax (e.g. {foo:})
    • never - forces use of explicit hash literal value
    • either - accepts both shorthand and explicit use of hash literal value
    • consistent - forces use of the 3.1 syntax only if all values can be omitted in the hash

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Example: EnforcedShorthandSyntax: always (default)

    # bad
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: never

    # bad
    {foo:, bar:}
    
    # good
    {foo: foo, bar: bar}

    Example: EnforcedShorthandSyntax: either

    # good
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: consistent

    # bad - `foo` and `bar` values can be omitted
    {foo: foo, bar: bar}
    
    # bad - `bar` value can be omitted
    {foo:, bar: bar}
    
    # bad - mixed syntaxes
    {foo:, bar: baz}
    
    # good
    {foo:, bar:}
    
    # good - can't omit `baz`
    {foo: foo, bar: baz}

    Omit the hash value.
    Open

          { handles: handles, language: :en, query: query, size: 10, offset: 0, include: ['tags'] }

    Checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    This cop has EnforcedShorthandSyntax option. It can enforce either the use of the explicit hash value syntax or the use of Ruby 3.1's hash value shorthand syntax.

    The supported styles are:

    • always - forces use of the 3.1 syntax (e.g. {foo:})
    • never - forces use of explicit hash literal value
    • either - accepts both shorthand and explicit use of hash literal value
    • consistent - forces use of the 3.1 syntax only if all values can be omitted in the hash

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Example: EnforcedShorthandSyntax: always (default)

    # bad
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: never

    # bad
    {foo:, bar:}
    
    # good
    {foo: foo, bar: bar}

    Example: EnforcedShorthandSyntax: either

    # good
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: consistent

    # bad - `foo` and `bar` values can be omitted
    {foo: foo, bar: bar}
    
    # bad - `bar` value can be omitted
    {foo:, bar: bar}
    
    # bad - mixed syntaxes
    {foo:, bar: baz}
    
    # good
    {foo:, bar:}
    
    # good - can't omit `baz`
    {foo: foo, bar: baz}

    Omit the hash value.
    Open

          { handles: handles, language: :en, query: query, size: 10, offset: 0, include: ['tags'] }

    Checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    This cop has EnforcedShorthandSyntax option. It can enforce either the use of the explicit hash value syntax or the use of Ruby 3.1's hash value shorthand syntax.

    The supported styles are:

    • always - forces use of the 3.1 syntax (e.g. {foo:})
    • never - forces use of explicit hash literal value
    • either - accepts both shorthand and explicit use of hash literal value
    • consistent - forces use of the 3.1 syntax only if all values can be omitted in the hash

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Example: EnforcedShorthandSyntax: always (default)

    # bad
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: never

    # bad
    {foo:, bar:}
    
    # good
    {foo: foo, bar: bar}

    Example: EnforcedShorthandSyntax: either

    # good
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: consistent

    # bad - `foo` and `bar` values can be omitted
    {foo: foo, bar: bar}
    
    # bad - `bar` value can be omitted
    {foo:, bar: bar}
    
    # bad - mixed syntaxes
    {foo:, bar: baz}
    
    # good
    {foo:, bar:}
    
    # good - can't omit `baz`
    {foo: foo, bar: baz}

    Omit the hash value.
    Open

          offset: offset

    Checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    This cop has EnforcedShorthandSyntax option. It can enforce either the use of the explicit hash value syntax or the use of Ruby 3.1's hash value shorthand syntax.

    The supported styles are:

    • always - forces use of the 3.1 syntax (e.g. {foo:})
    • never - forces use of explicit hash literal value
    • either - accepts both shorthand and explicit use of hash literal value
    • consistent - forces use of the 3.1 syntax only if all values can be omitted in the hash

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Example: EnforcedShorthandSyntax: always (default)

    # bad
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: never

    # bad
    {foo:, bar:}
    
    # good
    {foo: foo, bar: bar}

    Example: EnforcedShorthandSyntax: either

    # good
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: consistent

    # bad - `foo` and `bar` values can be omitted
    {foo: foo, bar: bar}
    
    # bad - `bar` value can be omitted
    {foo:, bar: bar}
    
    # bad - mixed syntaxes
    {foo:, bar: baz}
    
    # good
    {foo:, bar:}
    
    # good - can't omit `baz`
    {foo: foo, bar: baz}

    Omit the hash value.
    Open

          size: size,

    Checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    This cop has EnforcedShorthandSyntax option. It can enforce either the use of the explicit hash value syntax or the use of Ruby 3.1's hash value shorthand syntax.

    The supported styles are:

    • always - forces use of the 3.1 syntax (e.g. {foo:})
    • never - forces use of explicit hash literal value
    • either - accepts both shorthand and explicit use of hash literal value
    • consistent - forces use of the 3.1 syntax only if all values can be omitted in the hash

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Example: EnforcedShorthandSyntax: always (default)

    # bad
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: never

    # bad
    {foo:, bar:}
    
    # good
    {foo: foo, bar: bar}

    Example: EnforcedShorthandSyntax: either

    # good
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: consistent

    # bad - `foo` and `bar` values can be omitted
    {foo: foo, bar: bar}
    
    # bad - `bar` value can be omitted
    {foo:, bar: bar}
    
    # bad - mixed syntaxes
    {foo:, bar: baz}
    
    # good
    {foo:, bar:}
    
    # good - can't omit `baz`
    {foo: foo, bar: baz}

    Omit the hash value.
    Open

                                 content: content

    Checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    This cop has EnforcedShorthandSyntax option. It can enforce either the use of the explicit hash value syntax or the use of Ruby 3.1's hash value shorthand syntax.

    The supported styles are:

    • always - forces use of the 3.1 syntax (e.g. {foo:})
    • never - forces use of explicit hash literal value
    • either - accepts both shorthand and explicit use of hash literal value
    • consistent - forces use of the 3.1 syntax only if all values can be omitted in the hash

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Example: EnforcedShorthandSyntax: always (default)

    # bad
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: never

    # bad
    {foo:, bar:}
    
    # good
    {foo: foo, bar: bar}

    Example: EnforcedShorthandSyntax: either

    # good
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: consistent

    # bad - `foo` and `bar` values can be omitted
    {foo: foo, bar: bar}
    
    # bad - `bar` value can be omitted
    {foo:, bar: bar}
    
    # bad - mixed syntaxes
    {foo:, bar: baz}
    
    # good
    {foo:, bar:}
    
    # good - can't omit `baz`
    {foo: foo, bar: baz}

    Omit the hash value.
    Open

          query: query,

    Checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    This cop has EnforcedShorthandSyntax option. It can enforce either the use of the explicit hash value syntax or the use of Ruby 3.1's hash value shorthand syntax.

    The supported styles are:

    • always - forces use of the 3.1 syntax (e.g. {foo:})
    • never - forces use of explicit hash literal value
    • either - accepts both shorthand and explicit use of hash literal value
    • consistent - forces use of the 3.1 syntax only if all values can be omitted in the hash

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Example: EnforcedShorthandSyntax: always (default)

    # bad
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: never

    # bad
    {foo:, bar:}
    
    # good
    {foo: foo, bar: bar}

    Example: EnforcedShorthandSyntax: either

    # good
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: consistent

    # bad - `foo` and `bar` values can be omitted
    {foo: foo, bar: bar}
    
    # bad - `bar` value can be omitted
    {foo:, bar: bar}
    
    # bad - mixed syntaxes
    {foo:, bar: baz}
    
    # good
    {foo:, bar:}
    
    # good - can't omit `baz`
    {foo: foo, bar: baz}

    Omit the hash value.
    Open

            { handles: handles, language: :en, query: query, size: 10, offset: 0, include: %w[audience

    Checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    This cop has EnforcedShorthandSyntax option. It can enforce either the use of the explicit hash value syntax or the use of Ruby 3.1's hash value shorthand syntax.

    The supported styles are:

    • always - forces use of the 3.1 syntax (e.g. {foo:})
    • never - forces use of explicit hash literal value
    • either - accepts both shorthand and explicit use of hash literal value
    • consistent - forces use of the 3.1 syntax only if all values can be omitted in the hash

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Example: EnforcedShorthandSyntax: always (default)

    # bad
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: never

    # bad
    {foo:, bar:}
    
    # good
    {foo: foo, bar: bar}

    Example: EnforcedShorthandSyntax: either

    # good
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: consistent

    # bad - `foo` and `bar` values can be omitted
    {foo: foo, bar: bar}
    
    # bad - `bar` value can be omitted
    {foo:, bar: bar}
    
    # bad - mixed syntaxes
    {foo:, bar: baz}
    
    # good
    {foo:, bar:}
    
    # good - can't omit `baz`
    {foo: foo, bar: baz}

    Omit the hash value.
    Open

            { handles: handles, language: :en, query: query, size: 10, offset: 0, include: %w[searchgov_custom1

    Checks hash literal syntax.

    It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

    A separate offense is registered for each problematic pair.

    The supported styles are:

    • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
    • hash_rockets - forces use of hash rockets for all hashes
    • nomixedkeys - simply checks for hashes with mixed syntaxes
    • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

    This cop has EnforcedShorthandSyntax option. It can enforce either the use of the explicit hash value syntax or the use of Ruby 3.1's hash value shorthand syntax.

    The supported styles are:

    • always - forces use of the 3.1 syntax (e.g. {foo:})
    • never - forces use of explicit hash literal value
    • either - accepts both shorthand and explicit use of hash literal value
    • consistent - forces use of the 3.1 syntax only if all values can be omitted in the hash

    Example: EnforcedStyle: ruby19 (default)

    # bad
    {:a => 2}
    {b: 1, :c => 2}
    
    # good
    {a: 2, b: 1}
    {:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
    {d: 1, 'e' => 2} # technically not forbidden

    Example: EnforcedStyle: hash_rockets

    # bad
    {a: 1, b: 2}
    {c: 1, 'd' => 5}
    
    # good
    {:a => 1, :b => 2}

    Example: EnforcedStyle: nomixedkeys

    # bad
    {:a => 1, b: 2}
    {c: 1, 'd' => 2}
    
    # good
    {:a => 1, :b => 2}
    {c: 1, d: 2}

    Example: EnforcedStyle: ruby19nomixed_keys

    # bad
    {:a => 1, :b => 2}
    {c: 2, 'd' => 3} # should just use hash rockets
    
    # good
    {a: 1, b: 2}
    {:c => 3, 'd' => 4}

    Example: EnforcedShorthandSyntax: always (default)

    # bad
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: never

    # bad
    {foo:, bar:}
    
    # good
    {foo: foo, bar: bar}

    Example: EnforcedShorthandSyntax: either

    # good
    {foo: foo, bar: bar}
    
    # good
    {foo:, bar:}

    Example: EnforcedShorthandSyntax: consistent

    # bad - `foo` and `bar` values can be omitted
    {foo: foo, bar: bar}
    
    # bad - `bar` value can be omitted
    {foo:, bar: bar}
    
    # bad - mixed syntaxes
    {foo:, bar: baz}
    
    # good
    {foo:, bar:}
    
    # good - can't omit `baz`
    {foo: foo, bar: baz}

    There are no issues that match your filters.

    Category
    Status