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

Add AllowKeywordBlockArguments option to UnderscorePrefixedVariableName #6887

Merged
merged 1 commit into from Apr 23, 2019

Conversation

dduugg
Copy link
Contributor

@dduugg dduugg commented Apr 5, 2019

This adds an AllowKeywordBlockArguments to the Lint/UnderscorePrefixedVariableName cop. When enabled, it permits use of underscore-prefixed keyword arguments in blocks.

It is inspired by the AllowUnusedKeywordArguments option in the Lint/Unused{Block,Method}Argument cops.


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@dduugg dduugg force-pushed the AllowKeywordBlockArguments-config branch 3 times, most recently from 363a6fe to 0e5ddd8 Compare April 6, 2019 15:31
@dduugg dduugg closed this Apr 6, 2019
@dduugg dduugg reopened this Apr 6, 2019
@dduugg dduugg force-pushed the AllowKeywordBlockArguments-config branch from 0e5ddd8 to 342c5bc Compare April 6, 2019 19:17
@mikegee
Copy link
Contributor

mikegee commented Apr 14, 2019

When enabled, it permits use of underscore-prefixed keyword arguments in blocks.

Indeed, but why would someone want this behavior?

@dduugg
Copy link
Contributor Author

dduugg commented Apr 14, 2019

@mikegee Thanks for your interest. I'm working with a MongoDB ODM which passes fields as kwargs, and every MondgoDB document has an _id field. (And in MongoDB, more generally, the semantics of leading underscores do not correspond to those of Ruby.)

@mikegee
Copy link
Contributor

mikegee commented Apr 14, 2019

@dduugg thanks for the justification. This PR seems legit to me. 👍

@dduugg dduugg force-pushed the AllowKeywordBlockArguments-config branch from 497408a to bf85996 Compare April 17, 2019 01:13
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 18, 2019

I'm fine with the change, but the cop documentation should be expand to account for it (rationale, some examples, etc).

@dduugg dduugg force-pushed the AllowKeywordBlockArguments-config branch 3 times, most recently from b82d9e5 to bf161b1 Compare April 21, 2019 00:15
@dduugg dduugg force-pushed the AllowKeywordBlockArguments-config branch from bf161b1 to 5215691 Compare April 21, 2019 00:18
@dduugg
Copy link
Contributor Author

dduugg commented Apr 21, 2019

@bbatsov done!
I've consolidated under a single @example tag for each config, as i find the resulting docs more readable this way (e.g. https://rubocop.readthedocs.io/en/latest/cops_style/#styleaccessmodifierdeclarations ). Happy to revert if you prefer the former style, however.

@bbatsov bbatsov merged commit cd1d1a7 into rubocop:master Apr 23, 2019
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 23, 2019

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

3 participants