Hi, I found that disabling the RSpec department does not seem to work.
(see also the core document about disabling a department)
The following warning is output when Enabled: is present for RSpec:.
Warning: RSpec does not support Enabled parameter.
Supported parameters are:
- Include
- Language
Please see the reproduction below.
Given Gemfile and .rubocop.yml:
source "https://rubygems.org"
gem "rubocop"
gem "rubocop-rspec"
gem "rubocop-performance"
require:
- rubocop-performance
- rubocop-rspec
AllCops:
NewCops: enable
TargetRubyVersion: 2.7
Style:
Enabled: false
Performance:
Enabled: false
RSpec:
Enabled: false
Run:
$ docker run --rm -it -v $PWD:/work -w /work ruby:2.7 bash
root@d0a1a9251ecb:/work# bundle install
...(omitted)...
root@d0a1a9251ecb:/work# bundle exec rubocop
Warning: RSpec does not support Enabled parameter.
Supported parameters are:
- Include
- Language
Inspecting 1 file
C
Offenses:
Gemfile:5:1: C: Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem rubocop-performance should appear before rubocop-rspec.
gem "rubocop-performance"
^^^^^^^^^^^^^^^^^^^^^^^^^
1 file inspected, 1 offense detected, 1 offense auto-correctable
Environment:
root@d0a1a9251ecb:/work# bundle exec rubocop -V
Warning: RSpec does not support Enabled parameter.
Supported parameters are:
- Include
- Language
1.3.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.1 x86_64-linux)
- rubocop-performance 1.8.1
- rubocop-rspec 2.0.0
Maybe, this problem might be due to the core logic.
It's our humble way to promote our underappreciated cops. Enjoy!
Jokes aside.
Do you mind checking if:
Style:
Enabled: false
disables RuboCop core's Style cops?
We don't have a default Enabled: true setting for our RSpec department or our FactoryBot/Rails sub-departments. But neither does RuboCop itself.
If there is a difference, and there's no error on setting Enabled: false for core departments and departments defined by extensions, I'll transfer the issue to rubocop after doing a quick research if we've broken this in inject.rb.
The doc is pretty sound that it's possible:
Style:
Enabled: true
and it doesn't mention that it should be AllCops/Style:.
If there's a similar error, I'll, again, transfer this issue to rubocop, this time with no investigation.
I'm inclined to only add explicit Enabled: true to our config/default.yml if it's a last resort.
As a side note, by disabling all cops you miss out on newly introduced cops. You may like or dislike it, but the new RSpec/StubbedMock is there for you.
Sorry for not reading this attentively. It seems that Style/Enabled: false works flawlessly on your side.
Let me quickly transfer the issue.
@koic I don't seem to be able to transfer to rubocop. Can you please have a look?
@pirj Thank you for your explanation and quick response. I could not have the confidence which I should open an issue to rubocop or rubocop-rspec.
I hope this issue would be present in an appropriate repository.
No worries. It could have been a bug on our side, and it still can be. But I'd love RuboCop guys to assess this first.
I would like to add that disabling/enabling actually works, but you still get:
Warning: RSpec does not support Enabled parameter
To make sure add any file violating the rubocop-rspec cops and you will see, i.e. spec/factories.rb
FactoryBot.define do
factory :order_item, class: Violation do
end
end
With the following .rubocop.yml:
require:
- rubocop-rspec
AllCops:
DisabledByDefault: true
RSpec:
Enabled: true
The output of bundle exec rubocop will be:
Warning: RSpec does not support Enabled parameter.
Supported parameters are:
- Include
- Language
Inspecting 33 files
.C..
Offenses:
spec/factories.rb:2:31: C: RSpec/FactoryBot/FactoryClassName: Pass 'Violation' string instead of Violation constant.
factory :order_item, class: Violation do
^^^^^^^^^
If you set Enabled: false, rubocop will not report any error, but still will display that nasty warning.
Thanks for the heads up! 馃憤
Since it's not a showstopper, I suggest opening a ticket in https://github.com/rubocop-hq/rubocop
We could work this around by adding Enabled: true to our config/default.yml, but I'm inclined not to hide the underlying issue.