From 8f1bcd1e0e78266b8d40131d511bf72ac07a9285 Mon Sep 17 00:00:00 2001
From: Alexander Olofsson <alexander.olofsson@liu.se>
Date: Tue, 18 Feb 2025 10:36:10 +0100
Subject: [PATCH] Make rubocop happier

---
 .../foreman_passwordstate/passwordlist_ensurance.rb       | 2 ++
 app/models/orchestration/passwordstate.rb                 | 8 ++++----
 lib/foreman_passwordstate/engine.rb                       | 4 +---
 lib/foreman_passwordstate/register.rb                     | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/app/models/concerns/foreman_passwordstate/passwordlist_ensurance.rb b/app/models/concerns/foreman_passwordstate/passwordlist_ensurance.rb
index 5210438..143ce93 100644
--- a/app/models/concerns/foreman_passwordstate/passwordlist_ensurance.rb
+++ b/app/models/concerns/foreman_passwordstate/passwordlist_ensurance.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 module ForemanPasswordstate
   module PasswordlistEnsurance
     extend ActiveSupport::Concern
diff --git a/app/models/orchestration/passwordstate.rb b/app/models/orchestration/passwordstate.rb
index 03aaf62..3a8c97d 100644
--- a/app/models/orchestration/passwordstate.rb
+++ b/app/models/orchestration/passwordstate.rb
@@ -10,7 +10,7 @@ module Orchestration
       # before_provision :remove_passwordstate_host, if: :passwordstate?
 
       before_destroy :remove_passwordstate_passwords!, if: :passwordstate?
-      # TODO - Remove passwords from old list if list ID is changing
+      # TODO: Remove passwords from old list if list ID is changing
       # before_update :remove_outdated_passwords, if: :passwordstate?
       after_update :ensure_passwordstate_passwords, if: :saved_change_to_name?
     end
@@ -71,12 +71,12 @@ module Orchestration
 
       pw_desc = "Foreman managed password for #{username} on #{fqdn} | #{stable_pw_desc.strip}"
       begin
-        pw = list.passwords.search(**params.merge(description: stable_pw_desc, user_name: username)).select { |e| e.description.ends_with? stable_pw_desc }.first
-        pw ||= list.passwords.create(**params.merge(title: "#{username}@#{fqdn}", description: pw_desc, user_name: username, generate_password: true)) if create
+        pw = list.passwords.search(**params, description: stable_pw_desc, user_name: username).select { |e| e.description.ends_with? stable_pw_desc }.first
+        pw ||= list.passwords.create(**params, title: "#{username}@#{fqdn}", description: pw_desc, user_name: username, generate_password: true) if create
 
         pw
       rescue ::Passwordstate::NotFoundError
-        return list.passwords.create(**params.merge(title: "#{username}@#{fqdn}", description: pw_desc, user_name: username, generate_password: true)) if create
+        return list.passwords.create(**params, title: "#{username}@#{fqdn}", description: pw_desc, user_name: username, generate_password: true) if create
 
         raise
       end
diff --git a/lib/foreman_passwordstate/engine.rb b/lib/foreman_passwordstate/engine.rb
index e45a036..5e5d2bd 100644
--- a/lib/foreman_passwordstate/engine.rb
+++ b/lib/foreman_passwordstate/engine.rb
@@ -28,9 +28,7 @@ module ForemanPasswordstate
       HostsController.prepend ForemanPasswordstate::HostsControllerExtensions
       HostgroupsController.prepend ForemanPasswordstate::HostgroupsControllerExtensions
       Operatingsystem.prepend ForemanPasswordstate::OperatingsystemExtensions
-      if Foreman::Plugin.installed?('foreman_discovery')
-        DiscoveredHostsController.prepend ForemanPasswordstate::HostsControllerExtensions
-      end
+      DiscoveredHostsController.prepend ForemanPasswordstate::HostsControllerExtensions if Foreman::Plugin.installed?('foreman_discovery')
     rescue StandardError => e
       Rails.logger.fatal "foreman_passwordstate: skipping engine hook (#{e})"
     end
diff --git a/lib/foreman_passwordstate/register.rb b/lib/foreman_passwordstate/register.rb
index 65eb65f..74ac9ad 100644
--- a/lib/foreman_passwordstate/register.rb
+++ b/lib/foreman_passwordstate/register.rb
@@ -71,7 +71,7 @@ Foreman::Plugin.register :foreman_passwordstate do
       :main_tabs,
       name: 'Passwords',
       partial: 'foreman_passwordstate/passwords_tab_pane_content',
-      onlyif: proc { |host| host.passwordstate_facet } # rubocop:disable Style/SymbolProc - Does not work with caller
+      onlyif: proc { |host| host.passwordstate_facet } # rubocop:disable Style/SymbolProc -- Does not work with caller
     )
   end
   %i[host hostgroup].each do |res|
-- 
GitLab