Skip to content

Rails/RakeEnvironment autocorrect does not handle parameters #1062

Closed
@fastjames

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions