Skip to content

Commit

Permalink
Invert guard condition to make operation clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
errm committed Jun 3, 2024
1 parent a640bb2 commit f6202ac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/millrace/rate_limit.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "digest"
girequire "digest"
require "prorate"

module Millrace
Expand All @@ -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
Expand Down

0 comments on commit f6202ac

Please sign in to comment.