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 use_builtin_english_names style to Style/SpecialGlobalVars #10521

Merged

Conversation

splattael
Copy link
Contributor

@splattael splattael commented Apr 10, 2022

Refs #5891

It behaves like use_perl_names but enforces some builtin global
English variables which does not need to require "English":

  • $LOAD_PATH
  • $LOADED_FEATURES
  • $PROGRAM_NAME

Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • 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.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@splattael splattael force-pushed the Style/SpecialGlobalVars-use-builtin-names branch 2 times, most recently from 21886bf to 2d16f70 Compare April 10, 2022 09:40
PERL_VARS = ENGLISH_VARS.flat_map { |k, vs| vs.map { |v| [v, [k]] } }.to_h

ENGLISH_VARS.merge!(ENGLISH_VARS.flat_map { |_, vs| vs.map { |v| [v, [v]] } }.to_h)
PERL_VARS.merge!(PERL_VARS.flat_map { |_, vs| vs.map { |v| [v, [v]] } }.to_h)
BUILTIN_VARS = PERL_VARS.merge(
NON_ENGLISH_VARS
.select { |v| v.start_with?('$') }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to workaround the ❄️ ARGV otherwise we keep suggesting to use ARGV for $* with use_builtin_names which is not what we want here.

@splattael splattael marked this pull request as ready for review April 10, 2022 09:42
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 10, 2022

I'm fine with the proposal, but I'm not sure that the option name is clear - I mean the Perl-style names are all built-in as well. :-) I don't have any great alternatives though - only use_built_descriptive_names or something along those lines.

@splattael
Copy link
Contributor Author

I'm fine with the proposal, but I'm not sure that the option name is clear - I mean the Perl-style names are all built-in as well. :-) I don't have any great alternatives though - only use_built_descriptive_names or something along those lines.

@bbatsov Yes, you are right 😅

Would be use_builtin_english_names too confusing? 🤔

@godfat Do you have other suggestions? 🙏

It behaves like `use_perl_names` but enforces some builtin global
English variables which does not need to `require "English"`:
* $LOAD_PATH
* $LOADED_FEATURES
* $PROGRAM_NAME
@splattael splattael force-pushed the Style/SpecialGlobalVars-use-builtin-names branch from 2d16f70 to fd20b9a Compare April 11, 2022 11:59
@splattael splattael changed the title Add use_builtin_names style to Style/SpecialGlobalVars Add use_builtin_english_names style to Style/SpecialGlobalVars Apr 11, 2022
@godfat
Copy link

godfat commented Apr 12, 2022 via email

@bbatsov bbatsov merged commit 709c452 into rubocop:master Apr 13, 2022
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 13, 2022

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