Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a791b4d

Browse files
authored
Merge pull request rubocop#695 from rubocop-hq/sort-config-alphabetically
Sort config alphabetically
2 parents 507a7f7 + 89f4956 commit a791b4d

File tree

2 files changed

+49
-36
lines changed

2 files changed

+49
-36
lines changed

config/default.yml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@ AllCops:
1010
- spec/factories/**/*.rb
1111
- features/support/factories/**/*.rb
1212

13-
RSpec/AnyInstance:
14-
Description: Check that instances are not being stubbed globally.
15-
Enabled: true
16-
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AnyInstance
17-
18-
RSpec/AroundBlock:
19-
Description: Checks that around blocks actually run the test.
20-
Enabled: true
21-
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AroundBlock
22-
2313
RSpec/AlignLeftLetBrace:
2414
Description: Checks that left braces for adjacent single line lets are aligned.
2515
Enabled: false
@@ -30,6 +20,16 @@ RSpec/AlignRightLetBrace:
3020
Enabled: false
3121
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AlignRightLetBrace
3222

23+
RSpec/AnyInstance:
24+
Description: Check that instances are not being stubbed globally.
25+
Enabled: true
26+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AnyInstance
27+
28+
RSpec/AroundBlock:
29+
Description: Checks that around blocks actually run the test.
30+
Enabled: true
31+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AroundBlock
32+
3333
RSpec/Be:
3434
Description: Check for expectations where `be` is used without argument.
3535
Enabled: true
@@ -63,16 +63,6 @@ RSpec/DescribeClass:
6363
Enabled: true
6464
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeClass
6565

66-
RSpec/DescribedClass:
67-
Description: Checks that tests use `described_class`.
68-
SkipBlocks: false
69-
Enabled: true
70-
EnforcedStyle: described_class
71-
SupportedStyles:
72-
- described_class
73-
- explicit
74-
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribedClass
75-
7666
RSpec/DescribeMethod:
7767
Description: Checks that the second argument to `describe` specifies a method.
7868
Enabled: true
@@ -83,10 +73,15 @@ RSpec/DescribeSymbol:
8373
Enabled: true
8474
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeSymbol
8575

86-
RSpec/IteratedExpectation:
87-
Description: Check that `all` matcher is used instead of iterating over an array.
76+
RSpec/DescribedClass:
77+
Description: Checks that tests use `described_class`.
78+
SkipBlocks: false
8879
Enabled: true
89-
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IteratedExpectation
80+
EnforcedStyle: described_class
81+
SupportedStyles:
82+
- described_class
83+
- explicit
84+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribedClass
9085

9186
RSpec/EmptyExampleGroup:
9287
Description: Checks if an example group does not include any tests.
@@ -240,6 +235,11 @@ RSpec/ItBehavesLike:
240235
- it_should_behave_like
241236
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ItBehavesLike
242237

238+
RSpec/IteratedExpectation:
239+
Description: Check that `all` matcher is used instead of iterating over an array.
240+
Enabled: true
241+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IteratedExpectation
242+
243243
RSpec/LeadingSubject:
244244
Description: Enforce that subject is the first definition in the test.
245245
Enabled: true
@@ -369,6 +369,16 @@ RSpec/ReturnFromStub:
369369
- block
370370
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ReturnFromStub
371371

372+
RSpec/ScatteredLet:
373+
Description: Checks for let scattered across the example group.
374+
Enabled: true
375+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredLet
376+
377+
RSpec/ScatteredSetup:
378+
Description: Checks for setup scattered across multiple hooks in an example group.
379+
Enabled: true
380+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredSetup
381+
372382
RSpec/SharedContext:
373383
Description: Checks for proper shared_context and shared_examples usage.
374384
Enabled: true
@@ -384,16 +394,6 @@ RSpec/SingleArgumentMessageChain:
384394
Enabled: true
385395
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SingleArgumentMessageChain
386396

387-
RSpec/ScatteredLet:
388-
Description: Checks for let scattered across the example group.
389-
Enabled: true
390-
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredLet
391-
392-
RSpec/ScatteredSetup:
393-
Description: Checks for setup scattered across multiple hooks in an example group.
394-
Enabled: true
395-
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredSetup
396-
397397
RSpec/SubjectStub:
398398
Description: Checks for stubbed test subjects.
399399
Enabled: true

spec/project/default_config_spec.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
RuboCop::ConfigLoader.load_file('config/default.yml')
44
end
55

6-
let(:cop_names) do
7-
namespaces = {
6+
let(:namespaces) do
7+
{
88
'rspec' => 'RSpec',
99
'capybara' => 'Capybara',
1010
'factory_bot' => 'FactoryBot',
1111
'rails' => 'Rails'
1212
}
13+
end
14+
15+
let(:cop_names) do
1316
glob = SpecHelper::ROOT.join('lib', 'rubocop', 'cop', 'rspec',
1417
'{,capybara,factory_bot,rails}', '*.rb')
1518
cop_names =
@@ -38,7 +41,17 @@ def cop_configuration(config_key)
3841
end
3942

4043
it 'has configuration for all cops' do
41-
expect(default_config.keys.sort).to eq(config_keys.sort)
44+
expect(default_config.keys).to match_array(config_keys)
45+
end
46+
47+
it 'sorts configuration keys alphabetically' do
48+
namespaces.each do |_path, prefix|
49+
expected = config_keys.select { |key| key.start_with?(prefix) }.sort
50+
actual = default_config.keys.select { |key| key.start_with?(prefix) }
51+
actual.each_with_index do |key, idx|
52+
expect(key).to eq expected[idx]
53+
end
54+
end
4255
end
4356

4457
it 'has descriptions for all cops' do

0 commit comments

Comments
 (0)