From 0395d2fe1e94f9b662e94fff71aec8b450206ab1 Mon Sep 17 00:00:00 2001 From: Sam Bostock Date: Fri, 18 Aug 2023 16:43:34 -0400 Subject: [PATCH] Return `nil` from `Iteration#perform` `perform` should be treated as `void`, with consumers not coupling to its return value. Explicitly returning `nil` ensures the return value does not change if we happen to change the implementation. --- lib/job-iteration/iteration.rb | 2 ++ test/unit/iteration_test.rb | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/lib/job-iteration/iteration.rb b/lib/job-iteration/iteration.rb index 7a6224a2..11edf7bd 100644 --- a/lib/job-iteration/iteration.rb +++ b/lib/job-iteration/iteration.rb @@ -125,6 +125,8 @@ def deserialize(job_data) # @private def perform(*params) # @private interruptible_perform(*params) + + nil end def retry_job(*, **) diff --git a/test/unit/iteration_test.rb b/test/unit/iteration_test.rb index 36198b7e..642b1f8c 100644 --- a/test/unit/iteration_test.rb +++ b/test/unit/iteration_test.rb @@ -485,6 +485,11 @@ def test_nested_each_iteration_instrumentation assert_equal(expected, events) end + def test_perform_returns_nil + # i.e. perform is "void", and nobody should depend on the return value + assert_nil(JobWithRightMethods.perform_now({})) + end + private # Allows building job classes that read max_job_runtime during the test,