diff --git a/CHANGELOG.md b/CHANGELOG.md index 840dfa93a..5bd8941f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,7 +37,7 @@ * Add `RSpec/RepeatedExampleGroupDescription` cop. ([@lazycoder9][]) * Add block name and other lines to `RSpec/ScatteredSetup` message. ([@elebow][]) * Fix `RSpec/RepeatedDescription` to take into account example metadata. ([@lazycoder9][]) -* Add `RSpec/NoLet` cop. ([@mockdeep][]) +* Add `RSpec/MemoizedHelpersInExampleGroup` cop. ([@mockdeep][]) ## 1.37.1 (2019-12-16) diff --git a/config/default.yml b/config/default.yml index b1f6b6c57..30f06c904 100644 --- a/config/default.yml +++ b/config/default.yml @@ -415,11 +415,11 @@ RSpec/NestedGroups: VersionChanged: '1.10' StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NestedGroups -RSpec/NoLet: +RSpec/MemoizedHelpersInExampleGroup: Description: Checks for usage of `let` blocks in specs. Enabled: false AllowSubject: false - StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NoLet + StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MemoizedHelpersInExampleGroup RSpec/NotToNot: Description: Checks for consistent method usage for negating expectations. diff --git a/lib/rubocop/cop/rspec/no_let.rb b/lib/rubocop/cop/rspec/memoized_helpers_in_example_group.rb similarity index 95% rename from lib/rubocop/cop/rspec/no_let.rb rename to lib/rubocop/cop/rspec/memoized_helpers_in_example_group.rb index dd76e7d03..06ae21a86 100644 --- a/lib/rubocop/cop/rspec/no_let.rb +++ b/lib/rubocop/cop/rspec/memoized_helpers_in_example_group.rb @@ -32,7 +32,7 @@ module RSpec # @example with AllowSubject configuration # # # rubocop.yml - # # RSpec/NoLet: + # # RSpec/MemoizedHelpersInExampleGroup: # # AllowSubject: true # # # bad @@ -54,7 +54,7 @@ module RSpec # end # end # - class NoLet < Cop + class MemoizedHelpersInExampleGroup < Cop MSG = 'Avoid using `%s` ' \ '– use a method call or local variable instead.' diff --git a/manual/cops.md b/manual/cops.md index 3721fcb74..9db4f9f50 100644 --- a/manual/cops.md +++ b/manual/cops.md @@ -67,7 +67,7 @@ * [RSpec/MultipleSubjects](cops_rspec.md#rspecmultiplesubjects) * [RSpec/NamedSubject](cops_rspec.md#rspecnamedsubject) * [RSpec/NestedGroups](cops_rspec.md#rspecnestedgroups) -* [RSpec/NoLet](cops_rspec.md#rspecnolet) +* [RSpec/MemoizedHelpersInExampleGroup](cops_rspec.md#rspecnolet) * [RSpec/NotToNot](cops_rspec.md#rspecnottonot) * [RSpec/OverwritingSetup](cops_rspec.md#rspecoverwritingsetup) * [RSpec/Pending](cops_rspec.md#rspecpending) diff --git a/manual/cops_rspec.md b/manual/cops_rspec.md index 16d667707..88a801135 100644 --- a/manual/cops_rspec.md +++ b/manual/cops_rspec.md @@ -2322,7 +2322,7 @@ Max | `3` | Integer * [https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NestedGroups](https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NestedGroups) -## RSpec/NoLet +## RSpec/MemoizedHelpersInExampleGroup Enabled by default | Supports autocorrection --- | --- @@ -2360,7 +2360,7 @@ end ```ruby # rubocop.yml -# RSpec/NoLet: +# RSpec/MemoizedHelpersInExampleGroup: # AllowSubject: true # bad @@ -2391,7 +2391,7 @@ AllowSubject | `false` | Boolean ### References -* [https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NoLet](https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NoLet) +* [https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MemoizedHelpersInExampleGroup](https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MemoizedHelpersInExampleGroup) ## RSpec/NotToNot diff --git a/spec/rubocop/cop/rspec/no_let_spec.rb b/spec/rubocop/cop/rspec/memoized_helpers_in_example_group_spec.rb similarity index 95% rename from spec/rubocop/cop/rspec/no_let_spec.rb rename to spec/rubocop/cop/rspec/memoized_helpers_in_example_group_spec.rb index 66cefeb48..f09df812c 100644 --- a/spec/rubocop/cop/rspec/no_let_spec.rb +++ b/spec/rubocop/cop/rspec/memoized_helpers_in_example_group_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe RuboCop::Cop::RSpec::NoLet do +RSpec.describe RuboCop::Cop::RSpec::MemoizedHelpersInExampleGroup do subject(:cop) { described_class.new(config) } let(:config) { RuboCop::Config.new }