diff --git a/.rubocop.yml b/.rubocop.yml index 94b2b1a4e..d8b0e5bc2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -485,6 +485,12 @@ Style/ClassVars: Style/CollectionMethods: Enabled: true +Style/FileRead: + Enabled: true + +Style/FileWrite: + Enabled: true + Style/HashConversion: Enabled: true diff --git a/app/models/concerns/json_exporter.rb b/app/models/concerns/json_exporter.rb index b06ce42d2..171200fc6 100644 --- a/app/models/concerns/json_exporter.rb +++ b/app/models/concerns/json_exporter.rb @@ -2,7 +2,7 @@ module JsonExporter def to_json_file(filename) data = [] model.find_each { |record| data << json_values(record) } - File.open(filename, "w") { |file| file.write(data.to_json) } + File.write(filename, data.to_json) end private diff --git a/spec/system/admin/machine_learning_spec.rb b/spec/system/admin/machine_learning_spec.rb index 32a59f281..03a476026 100644 --- a/spec/system/admin/machine_learning_spec.rb +++ b/spec/system/admin/machine_learning_spec.rb @@ -216,9 +216,9 @@ describe "Machine learning" do kind: "comments_summary", updated_at: 2.minutes.from_now) comments_file = MachineLearning::DATA_FOLDER.join(MachineLearning.comments_filename) - File.open(comments_file, "w") { |file| file.write([].to_json) } + File.write(comments_file, [].to_json) proposals_comments_summary_file = MachineLearning::DATA_FOLDER.join(MachineLearning.proposals_comments_summary_filename) - File.open(proposals_comments_summary_file, "w") { |file| file.write([].to_json) } + File.write(proposals_comments_summary_file, [].to_json) end visit admin_machine_learning_path