-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
[Fix #1062] Correct rake tasks with arguments #1063
[Fix #1062] Correct rake tasks with arguments #1063
Conversation
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def correct_task_arguments_dependency(task_method) | ||
"#{task_arguments(task_method).source} => [:environment]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you tweak the autocorrection code? It seems to work with symbol instead of array.
"#{task_arguments(task_method).source} => [:environment]" | |
"#{task_arguments(task_method).source} => :environment" |
args_deps_hash = correct_task_arguments_dependency(task_method) | ||
corrector.replace(task_method.arguments[1], args_deps_hash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you refactor?
args_deps_hash = correct_task_arguments_dependency(task_method) | |
corrector.replace(task_method.arguments[1], args_deps_hash) | |
new_task_dependency = correct_task_arguments_dependency(task_method) | |
corrector.replace(task_arguments(task_method), new_task_dependency) |
task_name = task_method.arguments[0] | ||
task_dependency = correct_task_dependency(task_name) | ||
corrector.replace(task_name, task_dependency) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
task_name = task_method.arguments[0] | |
task_dependency = correct_task_dependency(task_name) | |
corrector.replace(task_name, task_dependency) | |
task_name = task_method.first_argument | |
new_task_dependency = correct_task_dependency(task_name) | |
corrector.replace(task_name, new_task_dependency) |
RUBY | ||
|
||
expect_correction(<<~RUBY) | ||
task :foo, [:arg] => [:environment] do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
task :foo, [:arg] => [:environment] do | |
task :foo, [:arg] => :environment do |
Looks good to me. Can you squash your commits into one? |
Account for rake tasks that accept arguments.
23149d7
to
dd17d2d
Compare
I was hoping that you would ask! I have squashed my fixes back into the original commit. |
Thanks! |
When auto-correcting rake tasks to include the
:environment
prerequisite, account for rake tasks that accept arguments.closes #1062
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.