From c174190a9bd9dd68b79aa6d65a2af5510552adbe Mon Sep 17 00:00:00 2001 From: Corey Osman Date: Thu, 5 Feb 2026 19:33:20 -0800 Subject: [PATCH 1/2] Revert "Disable rubocop checks for now" This reverts commit 819bc05d8cd8a96dfc26782954002ca106f1207c. --- .github/workflows/lint.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..2f5a19f --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +# Lint: RuboCop and style checks +name: Lint + +on: + pull_request: + push: + branches: [main, master] + +jobs: + rubocop: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.3" + bundler-cache: true + - name: Run RuboCop + run: bundle exec rubocop From 49d5bdead92b8f1064a5390492f778cca3865967 Mon Sep 17 00:00:00 2001 From: Corey Osman Date: Thu, 5 Feb 2026 19:37:56 -0800 Subject: [PATCH 2/2] CI: allow lint to fail; use safe navigation for logger calls - Add continue-on-error to lint workflow so failures are warnings only - Replace 'logger.method(...) if logger' with logger&.method(...) throughout Co-authored-by: Cursor --- .github/workflows/lint.yml | 1 + lib/rubyipmi.rb | 10 +++++----- lib/rubyipmi/commands/basecommand.rb | 10 +++++----- lib/rubyipmi/freeipmi/commands/bmcdevice.rb | 2 +- lib/rubyipmi/freeipmi/commands/chassis.rb | 2 +- lib/rubyipmi/ipmitool/commands/bmc.rb | 2 +- lib/rubyipmi/ipmitool/commands/chassis.rb | 2 +- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2f5a19f..82d014a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,6 +9,7 @@ on: jobs: rubocop: runs-on: ubuntu-latest + continue-on-error: true # Allow to fail - report as warning only steps: - uses: actions/checkout@v4 - name: Set up Ruby diff --git a/lib/rubyipmi.rb b/lib/rubyipmi.rb index 5a26792..675a5c2 100644 --- a/lib/rubyipmi.rb +++ b/lib/rubyipmi.rb @@ -98,7 +98,7 @@ def self.connect(user, pass, host, provider = 'any', opts = {:driver => 'lan20', opts[:timeout] ||= 'default' if opts[:privilege] && !supported_privilege_type?(opts[:privilege]) - logger.error("Invalid privilege type :#{opts[:privilege]}, must be one of: #{PRIV_TYPES.join("\n")}") if logger + logger&.error("Invalid privilege type :#{opts[:privilege]}, must be one of: #{PRIV_TYPES.join("\n")}") raise "Invalid privilege type :#{opts[:privilege]}, must be one of: #{PRIV_TYPES.join("\n")}" end @@ -119,7 +119,7 @@ def self.connect(user, pass, host, provider = 'any', opts = {:driver => 'lan20', # Support multiple drivers # Note: these are just generic names of drivers that need to be specified for each provider unless valid_drivers.include?(opts[:driver]) - logger.debug("You must specify a valid driver: #{valid_drivers.join(',')}") if logger + logger&.debug("You must specify a valid driver: #{valid_drivers.join(',')}") raise "You must specify a valid driver: #{valid_drivers.join(',')}" end @@ -130,12 +130,12 @@ def self.connect(user, pass, host, provider = 'any', opts = {:driver => 'lan20', elsif provider == "ipmitool" Rubyipmi::Ipmitool::Connection.new(user, pass, host, opts) else - logger.error("Incorrect provider given, must use one of #{valid_providers.join(', ')}") if logger + logger&.error("Incorrect provider given, must use one of #{valid_providers.join(', ')}") raise "Incorrect provider given, must use one of #{valid_providers.join(', ')}" end else # Can't find the provider command line tool, maybe try other provider? - logger.error("The IPMI provider: #{provider} is not installed") if logger + logger&.error("The IPMI provider: #{provider} is not installed") raise "The IPMI provider: #{provider} is not installed" end end @@ -167,7 +167,7 @@ def self.is_provider_installed?(provider) when "ipmitool" cmdpath = locate_command('ipmitool') else - logger.error("Invalid BMC provider type #{provider}") if logger + logger&.error("Invalid BMC provider type #{provider}") false end # return false if command was not found diff --git a/lib/rubyipmi/commands/basecommand.rb b/lib/rubyipmi/commands/basecommand.rb index 3f5b4ef..b2835e4 100644 --- a/lib/rubyipmi/commands/basecommand.rb +++ b/lib/rubyipmi/commands/basecommand.rb @@ -49,8 +49,8 @@ def locate_command(commandname) def runcmd @success = false @success = run - logger.debug(@lastcall.inspect) unless @lastcall.nil? if logger - logger.debug(@result) unless @result.nil? if logger + logger&.debug(@lastcall.inspect) unless @lastcall.nil? + logger&.debug(@result) unless @result.nil? @success end @@ -63,7 +63,7 @@ def run @cmd = locate_command(@cmdname) setpass @result = nil - logger.debug(makecommand) if logger + logger&.debug(makecommand) begin command = makecommand @lastcall = command @@ -76,7 +76,7 @@ def run retrycount = retrycount.next retry else - logger.error("Exhausted all auto fixes, cannot determine what the problem is") if logger + logger&.error("Exhausted all auto fixes, cannot determine what the problem is") raise "Exhausted all auto fixes, cannot determine what the problem is" end ensure @@ -96,7 +96,7 @@ def find_fix(result) fix = ErrorCodes.search(result) @options.merge_notify!(fix) rescue - Rubyipmi.logger.debug("Could not find fix for error code: \n#{result}") if logger + logger&.debug("Could not find fix for error code: \n#{result}") raise "Could not find fix for error code: \n#{result}" end end diff --git a/lib/rubyipmi/freeipmi/commands/bmcdevice.rb b/lib/rubyipmi/freeipmi/commands/bmcdevice.rb index 0f80975..b7df2a9 100644 --- a/lib/rubyipmi/freeipmi/commands/bmcdevice.rb +++ b/lib/rubyipmi/freeipmi/commands/bmcdevice.rb @@ -18,7 +18,7 @@ def reset(type = 'cold') key = "#{type}-reset" command(key) else - logger.error("reset type: #{type} is not a valid choice, use warm or cold") if logger + logger&.error("reset type: #{type} is not a valid choice, use warm or cold") raise "reset type: #{type} is not a valid choice, use warm or cold" end end diff --git a/lib/rubyipmi/freeipmi/commands/chassis.rb b/lib/rubyipmi/freeipmi/commands/chassis.rb index 7827d38..e43fabf 100644 --- a/lib/rubyipmi/freeipmi/commands/chassis.rb +++ b/lib/rubyipmi/freeipmi/commands/chassis.rb @@ -37,7 +37,7 @@ def bootdevice(device, reboot = false, persistent = false) bootstatus = config.bootdevice(device, persistent) power.cycle if reboot && bootstatus else - logger.error("Device with name: #{device} is not a valid boot device for host #{options['hostname']}") if logger + logger&.error("Device with name: #{device} is not a valid boot device for host #{options['hostname']}") raise "Device with name: #{device} is not a valid boot device for host #{options['hostname']}" end end diff --git a/lib/rubyipmi/ipmitool/commands/bmc.rb b/lib/rubyipmi/ipmitool/commands/bmc.rb index 67ec7ad..8630c8d 100644 --- a/lib/rubyipmi/ipmitool/commands/bmc.rb +++ b/lib/rubyipmi/ipmitool/commands/bmc.rb @@ -34,7 +34,7 @@ def reset(type = 'cold') @options.delete_notify("cmdargs") return value else - logger.error("reset type: #{type} is not a valid choice, use warm or cold") if logger + logger&.error("reset type: #{type} is not a valid choice, use warm or cold") raise "reset type: #{type} is not a valid choice, use warm or cold" end end diff --git a/lib/rubyipmi/ipmitool/commands/chassis.rb b/lib/rubyipmi/ipmitool/commands/chassis.rb index 835130b..d7b5f66 100644 --- a/lib/rubyipmi/ipmitool/commands/chassis.rb +++ b/lib/rubyipmi/ipmitool/commands/chassis.rb @@ -38,7 +38,7 @@ def bootdevice(device, reboot = false, persistent = false) bootstatus = config.bootdevice(device, persistent) power.cycle if reboot && status else - logger.debug("Device with name: #{device} is not a valid boot device for host #{options['hostname']}") if logger + logger&.debug("Device with name: #{device} is not a valid boot device for host #{options['hostname']}") raise "Device with name: #{device} is not a valid boot device for host #{options['hostname']}" end bootstatus