From 07a73d68ae83709626bb7c880ffa6421f0caaba9 Mon Sep 17 00:00:00 2001 From: Mahima Singh <105724608+smahima27@users.noreply.github.com> Date: Fri, 26 Dec 2025 17:09:57 +0530 Subject: [PATCH] Fix RuboCop style violations in circuit_breaker.rb --- lib/vmpooler/circuit_breaker.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/vmpooler/circuit_breaker.rb b/lib/vmpooler/circuit_breaker.rb index 48407c9..756b292 100644 --- a/lib/vmpooler/circuit_breaker.rb +++ b/lib/vmpooler/circuit_breaker.rb @@ -9,7 +9,7 @@ module Vmpooler # - OPEN: Provider is failing, reject requests immediately (fail fast) # - HALF_OPEN: Testing if provider has recovered with limited requests class CircuitBreaker - STATES = [:closed, :open, :half_open].freeze + STATES = %i[closed open half_open].freeze class CircuitOpenError < StandardError; end @@ -133,9 +133,7 @@ module Vmpooler @failure_count = 0 @logger.log('d', "[+] [circuit_breaker] '#{@name}' successful test request (#{@success_count}/#{@half_open_attempts})") - if @success_count >= @half_open_attempts - transition_to_closed - end + transition_to_closed if @success_count >= @half_open_attempts when :open # Should not happen, but reset if we somehow get a success transition_to_closed @@ -151,9 +149,7 @@ module Vmpooler case @state when :closed @logger.log('d', "[!] [circuit_breaker] '#{@name}' failure #{@failure_count}/#{@failure_threshold}: #{error.class}") - if @failure_count >= @failure_threshold - transition_to_open - end + transition_to_open if @failure_count >= @failure_threshold when :half_open @logger.log('d', "[!] [circuit_breaker] '#{@name}' failed during half-open test") transition_to_open