diff --git a/app/models/config/rubocop.rb b/app/models/config/rubocop.rb index b828c3cfa..7a9d37dec 100644 --- a/app/models/config/rubocop.rb +++ b/app/models/config/rubocop.rb @@ -22,6 +22,10 @@ def parse_inherit_from(config) end end + def parse(content) + super(ERB.new(content).result) + end + def safe_parse(content) parse(content) rescue Psych::Exception => exception diff --git a/spec/models/config/rubocop_spec.rb b/spec/models/config/rubocop_spec.rb index 96e0735d1..1b38e6440 100644 --- a/spec/models/config/rubocop_spec.rb +++ b/spec/models/config/rubocop_spec.rb @@ -26,6 +26,24 @@ end end + context "when the configuration uses pre-processing" do + it "runs the config through ERB" do + raw_config = <<~CONFIG + Style/Encoding: + Enabled: <%= 1 + 1 == 2 %> + <% 42 # This should be ignored and not cause an error %> + CONFIG + + config = build_config(raw_config) + + expect(config.content).to eq( + "Style/Encoding" => { + "Enabled" => true, + }, + ) + end + end + context "when the configuration uses `inherit_from`" do it "returns the merged configuration using `inherit_from`" do repo_config = <<~EOS