lib/govuk/lint/config_file.rb in govuk-lint-3.11.2 vs lib/govuk/lint/config_file.rb in govuk-lint-3.11.3

- old
+ new

@@ -7,14 +7,11 @@ CONFIG_PATH = File.expand_path("../../../../configs", __FILE__) BASE_CONFIG_FILE = File.join(CONFIG_PATH, "rubocop/all.yml") def config_file_path return BASE_CONFIG_FILE unless File.exist?(local_config_file_path) - - config = merged_global_and_local_configs - file = create_tempfile_for_configs(config) - file.path + tempfile_for_configs.path end private def merged_global_and_local_configs @@ -36,14 +33,16 @@ def local_config_file_path @local_config_file_path ||= File.join(Dir.pwd, ".rubocop.yml") end - def create_tempfile_for_configs(config) - file = Tempfile.new('tmp-rubocop-all.yml') - file.write(config.to_yaml) - file.close - file + def tempfile_for_configs + @tempfile_for_configs ||= begin + file = Tempfile.new('tmp-rubocop-all.yml') + file.write(merged_global_and_local_configs.to_yaml) + file.close + file + end end end end end