File tree Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change
1
+ * [ #13981 ] ( https://github.com/rubocop/rubocop/pull/13981 ) : Prevent redundant plugin loading when a duplicate plugin is specified in an inherited config. ([ @koic ] [ ] )
Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ module RuboCop
9
9
# @api private
10
10
class ConfigLoaderResolver # rubocop:disable Metrics/ClassLength
11
11
def resolve_plugins ( rubocop_config , plugins )
12
- return if ( plugins = Array ( plugins ) ) . empty?
12
+ plugins = Array ( plugins ) - ConfigLoader . loaded_plugins . map { |plugin | plugin . about . name }
13
+ return if plugins . empty?
13
14
14
15
Plugin . integrate_plugins ( rubocop_config , plugins )
15
16
end
Original file line number Diff line number Diff line change @@ -104,6 +104,48 @@ module FooBarBaz
104
104
end
105
105
end
106
106
107
+ context 'when plugins are specified' do
108
+ before do
109
+ create_file ( '.rubocop.yml' , <<~YAML )
110
+ plugins:
111
+ - rubocop-performance
112
+ - rubocop-rspec
113
+ YAML
114
+ end
115
+
116
+ it 'returns the extensions' do
117
+ expect ( extension_versions ) . to contain_exactly (
118
+ /- rubocop-performance \d +\. \d +\. \d +/ ,
119
+ /- rubocop-rspec \d +\. \d +\. \d +/
120
+ )
121
+ end
122
+ end
123
+
124
+ context 'when a duplicate plugin is specified in an inherited config' do
125
+ before do
126
+ create_file ( 'base.yml' , <<~YAML )
127
+ plugins:
128
+ - rubocop-performance
129
+ YAML
130
+
131
+ create_file ( '.rubocop.yml' , <<~YAML )
132
+ inherit_from:
133
+ - base.yml
134
+
135
+ plugins:
136
+ - rubocop-performance
137
+ - rubocop-rspec
138
+ YAML
139
+ end
140
+
141
+ it 'returns each extension exactly once' do
142
+ expect ( extension_versions ) . to contain_exactly (
143
+ /- rubocop-performance \d +\. \d +\. \d +/ ,
144
+ /- rubocop-rspec \d +\. \d +\. \d +/
145
+ )
146
+ end
147
+ end
148
+
107
149
context 'with an invalid cop in config' do
108
150
before do
109
151
create_file ( '.rubocop.yml' , <<~YAML )
You can’t perform that action at this time.
0 commit comments