Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint/SymbolConversion to provide an additional "consistent" option #9621

Closed
ritikesh opened this issue Mar 19, 2021 · 2 comments · Fixed by #9623
Closed

Lint/SymbolConversion to provide an additional "consistent" option #9621

ritikesh opened this issue Mar 19, 2021 · 2 comments · Fixed by #9623
Assignees

Comments

@ritikesh
Copy link

@ritikesh ritikesh commented Mar 19, 2021

Is your feature request related to a problem? Please describe.

For hashes where keys are mixed, wouldn't having a consistent key structure be more readable than be forced to use symbols for some keys and strings for the rest -

def method
  {
    'a': 1,
    'b-a': 2
  }
end

raises a Lint/SymbolConversion violation.

Describe the solution you'd like

# .rubocop.yml

Lint/SymbolConversion:
  EnforcedStyle: consistent

No violations for:

def method
  {
    'a': 1,
    'b-a': 2
  }
end

(OR)

def method
  {
    a: 1,
    b: 2
  }
end

violates for :

def method
  {
    a: 1,
    'b-a': 2
  }
end
@dvandersluis dvandersluis self-assigned this Mar 19, 2021
@dvandersluis
Copy link
Member

@dvandersluis dvandersluis commented Mar 19, 2021

I think this is a good suggestion, I'm going to take a look.

dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Mar 19, 2021
…to require all symbol keys in a hash to use the same convention.

The `consistent` style works the same as the previous default style (now called `strict`), in that symbol conversions should be explicit. However, in the case of a hash with a mix of symbol keys requiring quoting and not, this style now enforces that all keys are quoted for consistency.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Mar 22, 2021
…to require all symbol keys in a hash to use the same convention.

The `consistent` style works the same as the previous default style (now called `strict`), in that symbol conversions should be explicit. However, in the case of a hash with a mix of symbol keys requiring quoting and not, this style now enforces that all keys are quoted for consistency.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Mar 22, 2021
…to require all symbol keys in a hash to use the same convention.

The `consistent` style works the same as the previous default style (now called `strict`), in that symbol conversions should be explicit. However, in the case of a hash with a mix of symbol keys requiring quoting and not, this style now enforces that all keys are quoted for consistency.
bbatsov pushed a commit that referenced this issue Mar 22, 2021
…ire all symbol keys in a hash to use the same convention.

The `consistent` style works the same as the previous default style (now called `strict`), in that symbol conversions should be explicit. However, in the case of a hash with a mix of symbol keys requiring quoting and not, this style now enforces that all keys are quoted for consistency.
@ritikesh
Copy link
Author

@ritikesh ritikesh commented Mar 22, 2021

That was quick! Thanks @dvandersluis and @bbatsov.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants