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

RuboCop can't autocorrect default Rails setup script #2609

Closed
deivid-rodriguez opened this issue Jan 9, 2016 · 3 comments
Closed

RuboCop can't autocorrect default Rails setup script #2609

deivid-rodriguez opened this issue Jan 9, 2016 · 3 comments

Comments

@deivid-rodriguez
Copy link
Contributor

After getting the file

wget https://raw.githubusercontent.com/rails/rails/3186fe582c76f9f05bf3b87e4a4e2e5b09ce770c/railties/lib/rails/generators/rails/app/templates/bin/setup

running RuboCop on it spits an offense

$ bundle exec rubocop setup
Inspecting 1 file
C

Offenses:

setup:18:26: C: Use || instead of or.
  system('bundle check') or system!('bundle install')
                         ^^

1 file inspected, 1 offense detected

which is not corrected

$ bundle exec rubocop setup -a
Inspecting 1 file
C

Offenses:

setup:18:26: C: Use || instead of or.
  system('bundle check') or system!('bundle install')
                         ^^

1 file inspected, 1 offense detected

even though the auto-generated config tells me it is "correctable"

$ bundle exec rubocop setup --auto-gen-config
Inspecting 1 file
C

Offenses:

setup:18:26: C: Use || instead of or.
  system('bundle check') or system!('bundle install')
                         ^^

1 file inspected, 1 offense detected
Created .rubocop_todo.yml.
Run `rubocop --config .rubocop_todo.yml`, or add `inherit_from: .rubocop_todo.yml` in a .rubocop.yml file.

$ cat .rubocop_todo.yml 
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-01-09 17:28:15 +0100 using RuboCop version 0.35.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: always, conditionals
Style/AndOr:
  Exclude:
    - 'setup'

Bug or missing / misunderstanding something?

@alexdowad
Copy link
Contributor

This is a really interesting problem!! Thanks for finding it!

The problem is the __FILE__ which appears in the source file.

@alexdowad
Copy link
Contributor

I've got a fix. This made my day, thanks.

@alexdowad
Copy link
Contributor

The trickiest thing is coming up with a name for a new PR.

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

No branches or pull requests

2 participants