Skip to content

Commit

Permalink
Merge pull request rubocop#164 from dylnclrk/edit-rake-environment-copy
Browse files Browse the repository at this point in the history
Copyedit Rails/RakeEnvironment cop documentation.
  • Loading branch information
koic authored Dec 6, 2019
2 parents 5707bb9 + e43c772 commit 8d48d8d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ Rails/Present:
UnlessBlank: true

Rails/RakeEnvironment:
Description: 'Set `:environment` task as a dependency to all rake task.'
Description: 'Include `:environment` as a dependency for all Rake tasks.'
Enabled: true
Safe: false
VersionAdded: '2.4'
Expand Down
12 changes: 6 additions & 6 deletions lib/rubocop/cop/rails/rake_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
module RuboCop
module Cop
module Rails
# This cop checks rake task definition without `environment` dependency.
# `environment` dependency is important because it loads application code
# for the rake task. The rake task cannot use application code, such as
# models, without `environment` dependency.
# This cop checks for Rake tasks without the `:environment` task
# dependency. The `:environment` task loads application code for other
# Rake tasks. Without it, tasks cannot make use of application code like
# models.
#
# You can ignore the offense if the task satisfies at least one of the
# following conditions:
#
# * The task does not need application code.
# * The task invokes :environment task.
# * The task invokes the `:environment` task.
#
# @example
# # bad
Expand All @@ -26,7 +26,7 @@ module Rails
# end
#
class RakeEnvironment < Cop
MSG = 'Set `:environment` task as a dependency to all rake task.'
MSG = 'Include `:environment` task as a dependency for all Rake tasks.'

def_node_matcher :task_definition?, <<~PATTERN
(send nil? :task ...)
Expand Down
10 changes: 5 additions & 5 deletions manual/cops_rails.md
Original file line number Diff line number Diff line change
Expand Up @@ -1666,16 +1666,16 @@ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChan
--- | --- | --- | --- | ---
Enabled | No | No | 2.4 | -

This cop checks rake task definition without `environment` dependency.
`environment` dependency is important because it loads application code
for the rake task. The rake task cannot use application code, such as
models, without `environment` dependency.
This cop checks for Rake tasks without the `:environment` task
dependency. The `:environment` task loads application code for other
Rake tasks. Without it, tasks cannot make use of application code like
models.

You can ignore the offense if the task satisfies at least one of the
following conditions:

* The task does not need application code.
* The task invokes :environment task.
* The task invokes the `:environment` task.

### Examples

Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cop/rails/rake_environment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
it 'registers an offense to task without :environment' do
expect_offense(<<~RUBY)
task :foo do
^^^^^^^^^ Set `:environment` task as a dependency to all rake task.
^^^^^^^^^ Include `:environment` task as a dependency for all Rake tasks.
end
RUBY
end
Expand Down

0 comments on commit 8d48d8d

Please sign in to comment.