-
-
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
Feature request - add a cop to detect missing :environment
dependencies in rake tasks
#63
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding! |
Rails-related functionality has been moved to a standalone library (gem) named |
I think this could be helpful, but there are valid situations where a task doesn't depend on Rails, e.g.: task :clear_pending_uploads do
run "rm -f uploads/pending"
end So this might result in a lot of false positives. Checking real-world-rails:
So around half of all entries don't have a direct |
Sorry I overlooked this issue, but I implemented a cop that has the same behavior with this issue.#130
Interesting. When I investigated with our private application, I found most task definitions have But if people get many false positives, I guess we can improve the cop. Maybe the cop looks the content of rake task, or disable it by default. I'll close this issue because it is a feature request and it's done. But feel free to open a new issue if you have any problems. Thanks! |
Well, looks like this was implemented without it being fully featured. Sometimes you don't want to load in the entire environment for a simple task. |
I'm always frustrated when I commit a rake task to my rails project and I forget the
:environment
dependency. For example:This runs just fine in my dev environment, probably because spring is running and just forks off a process where the whole rails env is loaded. So I push to production. Later on production
Describe the solution you'd like
I would like a rails cop that warns if you write a rake task without an environment dependency. It is rarely what you want. It is also easy to miss in code reviews.
The text was updated successfully, but these errors were encountered: