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

Always exit 2 when specified configuration file does not exist #5395

Merged
merged 1 commit into from
Jan 5, 2018

Conversation

pocke
Copy link
Collaborator

@pocke pocke commented Jan 5, 2018

RuboCop exits with 2 status code on an error.

However when a specified configuration file does not exist, RuboCop exit with a status code that depends on environments. Because errno depends on the environment in which Ruby runs.
https://ruby-doc.org/core-2.5.0/Errno.html

https://github.com/bbatsov/rubocop/blob/e7cb0e84ee55dcc475001f90b4cfe5aedc2a53f9/lib/rubocop/config_loader.rb#L183
https://github.com/bbatsov/rubocop/blob/e7cb0e84ee55dcc475001f90b4cfe5aedc2a53f9/lib/rubocop/cli.rb#L39-L41

I think it exits with 2 also in the case. This pull-request replace the errno with STATUS_ERROR.


And this pull-request replace magic numbers with constants.


Note: In my environment (Linux), Errno::ENOENT::Errno is 2. So this pull-request has nothing changes in my environment (and maybe in Linux).


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 rake default or rake parallel. It executes all tests and RuboCop for itself, and generates the documentation.

RuboCop exits with 2 status code on an error.

> - 2 if RuboCop terminates abnormally due to invalid configuration, invalid CLI
>   options, or an internal error.
> https://github.com/bbatsov/rubocop/blob/e7cb0e84ee55dcc475001f90b4cfe5aedc2a53f9/manual/basic_usage.md#exit-codes

However when a specified configuration file does not exist, RuboCop exit with a status code that depends on environments. Because `errno` depends on the environment in which Ruby runs.
https://ruby-doc.org/core-2.5.0/Errno.html

https://github.com/bbatsov/rubocop/blob/e7cb0e84ee55dcc475001f90b4cfe5aedc2a53f9/lib/rubocop/config_loader.rb#L183
https://github.com/bbatsov/rubocop/blob/e7cb0e84ee55dcc475001f90b4cfe5aedc2a53f9/lib/rubocop/cli.rb#L39-L41

I think it exits with 2 also in the case. This pull-request replace the `errno` with `STATUS_ERROR`.

---

And this pull-request replace magic numbers with constants.

---

Note: In my environment (Linux), `Errno::ENOENT::Errno` is `2`. So this pull-request has nothing changes in my environment (and maybe in Linux).
@bbatsov
Copy link
Collaborator

bbatsov commented Jan 5, 2018

Nice change! 👍

@bbatsov bbatsov merged commit c51af4c into rubocop:master Jan 5, 2018
@pocke pocke deleted the exit-code branch January 5, 2018 10:52
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.

2 participants