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 --init option to rubocop command #6928

Merged
merged 1 commit into from Apr 14, 2019

Conversation

koic
Copy link
Member

@koic koic commented Apr 13, 2019

This PR adds --init option to rubocop command.

% mkdir example
% cd /tmp/example
% rubocop --init
Writing new .rubocop.yml to /private/tmp/example/.rubocop.yml
% cat .rubocop.yml
# The behavior of RuboCop can be controlled via the .rubocop.yml
# configuration file. It makes it possible to enable/disable
# certain cops (checks) and to alter their behavior if they accept
# any parameters. The file can be placed either in your home
# directory or in some project directory.
#
# RuboCop will start looking for the configuration file in the directory
# where the inspected file is and continue its way up to the root directory.
#
# See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md
% rubocop --init # A warning will occur when .rubocop.yml already exists
.rubocop.yml already exists at /private/tmp/example/.rubocop.yml

It may be good to add a simple commented examples of basic configuration in the future.

First of all, this PR aims to generate .rubocop.yml which contains the following configuration URL.
https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md

And the generated .rubocop.yml text is quoted from the above URL.


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.

This PR adds `--init` option to `rubocop` command.

```console
% mkdir example
% cd /tmp/example
% rubocop --init
Writing new .rubocop.yml to /private/tmp/example/.rubocop.yml
% cat .rubocop.yml
# The behavior of RuboCop can be controlled via the .rubocop.yml
# configuration file. It makes it possible to enable/disable
# certain cops (checks) and to alter their behavior if they accept
# any parameters. The file can be placed either in your home
# directory or in some project directory.
#
# RuboCop will start looking for the configuration file in the directory
# where the inspected file is and continue its way up to the root directory.
#
# See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md
% rubocop --init # A warning will occur when .rubocop.yml already exists
.rubocop.yml already exists at /private/tmp/example/.rubocop.yml
```

It may be good to add a simple commented examples of basic configuration in the future.

First of all, this PR aims to generate .rubocop.yml which contains the following configuration URL.
https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md

And the generated .rubocop.yml text is quoted from the above URL.
@bbatsov bbatsov merged commit ab27faf into rubocop:master Apr 14, 2019
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 14, 2019

Good idea!

@koic
Copy link
Member Author

koic commented Apr 14, 2019

This idea was proposed by rubocop/rubocop-jp#34 (Japanese text). Thanks, @sinsoku 👍

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