# frozen_string_literal: true module NeetoCompliance class SidekiqQueuesVerifier < Base def local_copy "config/sidekiq.yml" end def queues @_queues ||= ["auth", "urgent", "default", "low"] end def valid? @errors = [] @missing_queues = [] sidekiq_yml = YAML.load(File.open(local_copy), aliases: true) local_queues = sidekiq_yml["queues"] || [] queues.map do |queue| unless local_queues.include?(queue) @missing_queues << queue @errors << "Add #{queue} to queues in #{local_copy}" end end @errors.length == 0 end def autofix_suggestion @errors.join("\n").yellow end def autofix_command "perl -p -i -e 's/queues:/queues:\n - #{@missing_queues.join("\n - ")}/g' config/sidekiq.yml" end end end