From e43c7729d7de6d1f9d33caf73f68e1e60fbaf843 Mon Sep 17 00:00:00 2001 From: Dylan Clark Date: Wed, 4 Dec 2019 13:11:55 -0800 Subject: [PATCH] Copyedit RakeEnvironment cop documentation * Tweak wording of offense message and supporting documentation to increase readability. --- config/default.yml | 2 +- lib/rubocop/cop/rails/rake_environment.rb | 12 ++++++------ manual/cops_rails.md | 10 +++++----- spec/rubocop/cop/rails/rake_environment_spec.rb | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/config/default.yml b/config/default.yml index ff58c4ed34..b732b02ed5 100644 --- a/config/default.yml +++ b/config/default.yml @@ -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' diff --git a/lib/rubocop/cop/rails/rake_environment.rb b/lib/rubocop/cop/rails/rake_environment.rb index b7b26ad719..c1c888ec08 100644 --- a/lib/rubocop/cop/rails/rake_environment.rb +++ b/lib/rubocop/cop/rails/rake_environment.rb @@ -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 @@ -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 ...) diff --git a/manual/cops_rails.md b/manual/cops_rails.md index 021730047f..e26535346a 100644 --- a/manual/cops_rails.md +++ b/manual/cops_rails.md @@ -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 diff --git a/spec/rubocop/cop/rails/rake_environment_spec.rb b/spec/rubocop/cop/rails/rake_environment_spec.rb index f92d564ffa..2ed34777a6 100644 --- a/spec/rubocop/cop/rails/rake_environment_spec.rb +++ b/spec/rubocop/cop/rails/rake_environment_spec.rb @@ -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