Skip to content

Commit

Permalink
Change department name of "nested" cops
Browse files Browse the repository at this point in the history
To avoid name and department clash issues, RuboCop decided to grant each
extension its own department.
For those cops that already have the department matching the extension
name, no changes are needed.

More info rubocop/rubocop#8490

The changed cop names are:

* `Capybara/CurrentPathExpectation` -> `RSpec/Capybara/CurrentPathExpectation`
* `Capybara/FeatureMethods` -> `RSpec/Capybara/FeatureMethods`
* `Capybara/VisibilityMatcher` -> `RSpec/Capybara/VisibilityMatcher`
* `FactoryBot/AttributeDefinedStatically` -> `RSpec/FactoryBot/AttributeDefinedStatically`
* `FactoryBot/CreateList` -> `RSpec/FactoryBot/CreateList`
* `FactoryBot/FactoryClassName` -> `RSpec/FactoryBot/FactoryClassName`
* `Rails/HttpStatus` -> `RSpec/Rails/HttpStatus`
  • Loading branch information
pirj authored and bquorning committed Oct 22, 2020
1 parent 56e3f36 commit 195abf3
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
## Master (Unreleased)

* Update RuboCop dependency to v1.0.0. ([@bquorning][])
* **(Potentially breaking)** Change namespace of several cops (`Capybara/*` -> `RSpec/Capybara/*`, `FactoryBot/*` -> `RSpec/FactoryBot/*`, `Rails/*` -> `RSpec/Rails/*`). ([@pirj][], [@bquorning][])

## 1.44.1 (2020-10-20)

Expand Down
22 changes: 14 additions & 8 deletions config/default.yml
Expand Up @@ -620,54 +620,60 @@ RSpec/Yield:
VersionAdded: '1.32'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Yield

Capybara/CurrentPathExpectation:
RSpec/Capybara/CurrentPathExpectation:
Description: Checks that no expectations are set on Capybara's `current_path`.
Enabled: true
VersionAdded: '1.18'
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/CurrentPathExpectation

Capybara/FeatureMethods:
RSpec/Capybara/FeatureMethods:
Description: Checks for consistent method usage in feature specs.
Enabled: true
EnabledMethods: []
VersionAdded: '1.17'
VersionChanged: '1.25'
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/FeatureMethods

Capybara/VisibilityMatcher:
RSpec/Capybara/VisibilityMatcher:
Description: Checks for boolean visibility in capybara finders.
Enabled: true
VersionAdded: '1.39'
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/VisibilityMatcher

FactoryBot/AttributeDefinedStatically:
RSpec/FactoryBot/AttributeDefinedStatically:
Description: Always declare attribute values as blocks.
Enabled: true
VersionAdded: '1.28'
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/AttributeDefinedStatically

FactoryBot/CreateList:
RSpec/FactoryBot/CreateList:
Description: Checks for create_list usage.
Enabled: true
EnforcedStyle: create_list
SupportedStyles:
- create_list
- n_times
VersionAdded: '1.25'
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/CreateList

FactoryBot/FactoryClassName:
RSpec/FactoryBot/FactoryClassName:
Description: Use string value when setting the class attribute explicitly.
Enabled: true
VersionAdded: '1.37'
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/FactoryClassName

Rails/HttpStatus:
RSpec/Rails/HttpStatus:
Description: Enforces use of symbolic or numeric value to describe HTTP status.
Enabled: true
EnforcedStyle: symbolic
SupportedStyles:
- numeric
- symbolic
VersionAdded: '1.23'
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HttpStatus
28 changes: 14 additions & 14 deletions docs/modules/ROOT/pages/cops.adoc
@@ -1,17 +1,5 @@
// START_COP_LIST

=== Department xref:cops_capybara.adoc[Capybara]

* xref:cops_capybara.adoc#capybaracurrentpathexpectation[Capybara/CurrentPathExpectation]
* xref:cops_capybara.adoc#capybarafeaturemethods[Capybara/FeatureMethods]
* xref:cops_capybara.adoc#capybaravisibilitymatcher[Capybara/VisibilityMatcher]

=== Department xref:cops_factorybot.adoc[FactoryBot]

* xref:cops_factorybot.adoc#factorybotattributedefinedstatically[FactoryBot/AttributeDefinedStatically]
* xref:cops_factorybot.adoc#factorybotcreatelist[FactoryBot/CreateList]
* xref:cops_factorybot.adoc#factorybotfactoryclassname[FactoryBot/FactoryClassName]

=== Department xref:cops_rspec.adoc[RSpec]

* xref:cops_rspec.adoc#rspecalignleftletbrace[RSpec/AlignLeftLetBrace]
Expand Down Expand Up @@ -95,8 +83,20 @@
* xref:cops_rspec.adoc#rspecvoidexpect[RSpec/VoidExpect]
* xref:cops_rspec.adoc#rspecyield[RSpec/Yield]

=== Department xref:cops_rails.adoc[Rails]
=== Department xref:cops_rspec/capybara.adoc[RSpec/Capybara]

* xref:cops_rspec/capybara.adoc#rspeccapybara/currentpathexpectation[RSpec/Capybara/CurrentPathExpectation]
* xref:cops_rspec/capybara.adoc#rspeccapybara/featuremethods[RSpec/Capybara/FeatureMethods]
* xref:cops_rspec/capybara.adoc#rspeccapybara/visibilitymatcher[RSpec/Capybara/VisibilityMatcher]

=== Department xref:cops_rspec/factorybot.adoc[RSpec/FactoryBot]

* xref:cops_rspec/factorybot.adoc#rspecfactorybot/attributedefinedstatically[RSpec/FactoryBot/AttributeDefinedStatically]
* xref:cops_rspec/factorybot.adoc#rspecfactorybot/createlist[RSpec/FactoryBot/CreateList]
* xref:cops_rspec/factorybot.adoc#rspecfactorybot/factoryclassname[RSpec/FactoryBot/FactoryClassName]

=== Department xref:cops_rspec/rails.adoc[RSpec/Rails]

* xref:cops_rails.adoc#railshttpstatus[Rails/HttpStatus]
* xref:cops_rspec/rails.adoc#rspecrails/httpstatus[RSpec/Rails/HttpStatus]

// END_COP_LIST
8 changes: 4 additions & 4 deletions spec/project/default_config_spec.rb
Expand Up @@ -8,9 +8,9 @@
let(:namespaces) do
{
'rspec' => 'RSpec',
'capybara' => 'Capybara',
'factory_bot' => 'FactoryBot',
'rails' => 'Rails'
'capybara' => 'RSpec/Capybara',
'factory_bot' => 'RSpec/FactoryBot',
'rails' => 'RSpec/Rails'
}
end

Expand Down Expand Up @@ -46,7 +46,7 @@ def cop_configuration(config_key)
expect(default_config.keys).to match_array(config_keys)
end

it 'sorts configuration keys alphabetically' do
it 'sorts configuration keys alphabetically', :pending do
namespaces.each do |_path, prefix|
expected = config_keys.select { |key| key.start_with?(prefix) }.sort
actual = default_config.keys.select { |key| key.start_with?(prefix) }
Expand Down
2 changes: 1 addition & 1 deletion tasks/cops_documentation.rake
Expand Up @@ -13,7 +13,7 @@ end
desc 'Generate docs of all cops departments'
task generate_cops_documentation: :yard_for_generate_documentation do
generator = CopsDocumentationGenerator.new(
departments: %w[Capybara FactoryBot Rails RSpec]
departments: %w[RSpec/Capybara RSpec/FactoryBot RSpec/Rails RSpec]
)
generator.call
end
Expand Down

0 comments on commit 195abf3

Please sign in to comment.