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

Make rubocop command aware of --server option from .rubocop and RUBOCOP_OPTS #10997

Conversation

koic
Copy link
Member

@koic koic commented Sep 8, 2022

Summary

This PR makes rubocop command aware of --server option from .rubocop and RUBOCOP_OPTS.

If RUBOCOP_OPTS environment variable or .rubocop file contains --server option, rubocop command defaults to server mode. Other server options such as stop-server, restart-server specified on the command line will take precedence over them.

This feature rides on the existing following feature.

Default command-line options are loaded from .rubocop and RUBOCOP_OPTS and
are combined with command-line options that are explicitly passed to rubocop.
Thus, the options have the following order of precedence (from highest to lowest):

  1. Explicit command-line options

  2. Options from RUBOCOP_OPTS environment variable

  3. Options from .rubocop file.

https://docs.rubocop.org/rubocop/1.36/usage/basic_usage.html#command-line-flags

Other Information

This PR adds .rubocop to .gitignore so that it used for RuboCop development is not mixed in git commit.


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.

…UBOCOP_OPTS

## Summary

This PR makes `rubocop` command aware of `--server` option from .rubocop and RUBOCOP_OPTS.

If `RUBOCOP_OPTS` environment variable or `.rubocop` file contains `--server` option,
`rubocop` command defaults to server mode.
Other server options such as `stop-server`, `restart-server` specified on the command line
will take precedence over them.

This feature rides on the existing following feature.

> Default command-line options are loaded from `.rubocop` and `RUBOCOP_OPTS` and
> are combined with command-line options that are explicitly passed to `rubocop`.
> Thus, the options have the following order of precedence (from highest to lowest):
>
> 1. Explicit command-line options
>
> 2. Options from RUBOCOP_OPTS environment variable
>
> 3. Options from .rubocop file.

https://docs.rubocop.org/rubocop/1.36/usage/basic_usage.html#command-line-flags

## Other Information

This PR adds .rubocop to .gitignore so that it used for RuboCop development is not mixed in git commit.
@koic koic force-pushed the make_rubocop_aware_of_server_option_from_file_and_env branch from cc1b7f7 to 0172484 Compare September 8, 2022 17:29
@bbatsov bbatsov merged commit 4b03060 into rubocop:master Sep 11, 2022
@bbatsov
Copy link
Collaborator

bbatsov commented Sep 11, 2022

Looks good!

@koic koic deleted the make_rubocop_aware_of_server_option_from_file_and_env branch September 11, 2022 19:42
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

2 participants