Skip to content

Commit

Permalink
Use ensure block for File.unlink tempfile (#342)
Browse files Browse the repository at this point in the history
This ensures that temporary files are removed even if the begin block
fails. This has been happening on some dev machines.
  • Loading branch information
Nitrodist committed Jul 18, 2020
1 parent 4b40721 commit 7ead7ee
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -26,10 +26,10 @@ def process
store = RuboCop::ConfigStore.new
redirect_stdout { RuboCop::Runner.new(options, store).run(paths) }
result = File.read(tempfile)
File.unlink tempfile
format original, result
rescue RuboCop::ValidationError, RuboCop::ConfigNotFoundError => e
set_error(Solargraph::LanguageServer::ErrorCodes::INTERNAL_ERROR, "[#{e.class}] #{e.message}")
ensure
File.unlink tempfile
end
end
Expand Down

0 comments on commit 7ead7ee

Please sign in to comment.