From 0d4a032f525b082e656891c598c3bacfa302789f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 25 Aug 2022 23:02:33 +0200 Subject: [PATCH] Add and apply Lint/NonAtomicFileOperation rule This rule was added in Rubocop 1.31.0; it follows the principles mentioned in the Ruby Style Guide [1]. https://rubystyle.guide/#atomic-file-operations --- .rubocop.yml | 3 +++ spec/lib/tasks/sitemap_spec.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7e9941d1d..d44255479 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -179,6 +179,9 @@ Lint/EmptyFile: Lint/LiteralAsCondition: Enabled: true +Lint/NonAtomicFileOperation: + Enabled: true + Lint/ParenthesesAsGroupedExpression: Enabled: true diff --git a/spec/lib/tasks/sitemap_spec.rb b/spec/lib/tasks/sitemap_spec.rb index d72bb9061..dc2fa7edd 100644 --- a/spec/lib/tasks/sitemap_spec.rb +++ b/spec/lib/tasks/sitemap_spec.rb @@ -4,7 +4,7 @@ describe "rake sitemap:create", type: :system do let(:file) { Rails.root.join("public", "sitemap.xml") } before do - File.delete(file) if File.exist?(file) + FileUtils.rm_f(file) Rake::Task["sitemap:create"].reenable end