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

Rails/RakeEnvironment autocorrect does not handle parameters #1062

Closed
fastjames opened this issue Aug 9, 2023 · 0 comments · Fixed by #1063
Closed

Rails/RakeEnvironment autocorrect does not handle parameters #1062

fastjames opened this issue Aug 9, 2023 · 0 comments · Fixed by #1063

Comments

@fastjames
Copy link
Contributor

Be clear, concise and precise in your description of the problem.
Open an issue with a descriptive title and a summary in grammatically correct,
complete sentences.

Use the template below when reporting bugs. Please, make sure that
you're running the latest stable RuboCop and that the problem you're reporting
hasn't been reported (and potentially fixed) already.

Before filing the ticket you should replace all text above the horizontal
rule with your own words.


Expected behavior

Given a rake task that looks like this:

task :foobar, [:username, :password] do |task, args|

The auto-corrected line should read

task :foobar, [:username, :password] => [:environment] do |task, args|

This is the correct syntax as seen in http://docs.seattlerb.org/rake/doc/rakefile_rdoc.html#label-Tasks+that+Expect+Parameters

Actual behavior

The auto-corrected line looks like this:

task foobar: :environment, [:username, :password] do |task, args|

The auto-correct line results in a syntax error.

Steps to reproduce the problem

  1. Add the rubocop-rails plugin to a rubocop config in a project.
  2. Add a rake task file to that project where the task definition includes parameters, as seen above.
  3. Run rubocop -A path/to/rake_task_file.rb.
  4. Observe the auto-corrected code.

RuboCop version

❯ bundle exec rubocop -V
1.52.1 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 2.7.8) [arm64-darwin22]
  - rubocop-rails 2.20.2
fastjames added a commit to fastjames/rubocop-rails that referenced this issue Aug 9, 2023
Account for rake tasks that accept arguments.
fastjames added a commit to fastjames/rubocop-rails that referenced this issue Aug 9, 2023
Account for rake tasks that accept arguments.
fastjames added a commit to fastjames/rubocop-rails that referenced this issue Aug 10, 2023
Account for rake tasks that accept arguments.
koic added a commit that referenced this issue Aug 10, 2023
…args

[Fix #1062] Correct rake tasks with arguments
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 a pull request may close this issue.

1 participant