From f6202ac5c52c6a01c1c60acb548fd489976c4b57 Mon Sep 17 00:00:00 2001 From: Ed Robinson Date: Mon, 3 Jun 2024 11:58:29 +0100 Subject: [PATCH] Invert guard condition to make operation clearer --- lib/millrace/rate_limit.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/millrace/rate_limit.rb b/lib/millrace/rate_limit.rb index 62c0dd8..db44975 100644 --- a/lib/millrace/rate_limit.rb +++ b/lib/millrace/rate_limit.rb @@ -1,4 +1,4 @@ -require "digest" +girequire "digest" require "prorate" module Millrace @@ -17,7 +17,7 @@ def before(controller) bucket = get_bucket(controller.request.remote_ip) level = bucket.fillup(1).level - return unless level > threshold + return if level < threshold if level - 1 < threshold level = bucket.fillup(penalty).level