From 1f673a51fab1112ed75e7dc24afcc1b4a301f470 Mon Sep 17 00:00:00 2001 From: John Mitsch Date: Wed, 25 Oct 2017 21:31:06 +0000 Subject: [PATCH] Fixes #21467 - Updates to rubocop 0.51.0 --- .rubocop.yml | 18 +++++++++++++++++- .rubocop_todo.yml | 4 ++-- .../api/rhsm/candlepin_proxies_controller.rb | 2 +- .../api/v2/package_groups_controller.rb | 2 +- .../katello/api/v2/repositories_controller.rb | 2 +- .../concerns/smart_proxy_helper_extensions.rb | 2 +- .../candlepin/listen_on_candlepin_events.rb | 2 +- .../content_view_puppet_environment/clone.rb | 4 ++-- app/lib/actions/katello/event_queue/monitor.rb | 2 +- app/lib/actions/katello/host/register.rb | 2 +- app/lib/actions/katello/host/update.rb | 4 +--- .../pulp/consumer/abstract_content_action.rb | 2 +- app/lib/katello/errors.rb | 4 ---- app/lib/katello/util/support.rb | 2 +- .../katello/candlepin/product_content.rb | 1 + .../concerns/content_facet_host_extensions.rb | 4 ++-- .../katello/concerns/smart_proxy_extensions.rb | 3 ++- .../subscription_facet_host_extensions.rb | 2 +- app/models/katello/content_view.rb | 2 +- .../katello/glue/candlepin/activation_key.rb | 2 +- app/models/katello/glue/candlepin/pool.rb | 4 ++-- app/models/katello/glue/pulp/repo.rb | 2 +- app/models/katello/host/subscription_facet.rb | 14 ++++++-------- app/models/katello/rhsm_fact_importer.rb | 4 ++-- app/models/katello/rhsm_fact_parser.rb | 2 +- app/models/katello/sync_plan.rb | 2 +- ...nt_view_version_description_to_histories.rb | 4 +--- lib/katello/tasks/rubocop.rake | 2 +- lib/katello/tasks/virt_who_report.rake | 4 ++-- spec/models/model_spec_helper.rb | 8 ++++---- .../katello/event_queue_monitor_test.rb | 2 +- .../api/v2/sync_plans_controller_test.rb | 2 +- test/katello_test_helper.rb | 4 ++-- test/lib/capsule_content_test.rb | 2 +- test/models/erratum_test.rb | 6 +++--- test/models/host/content_facet_test.rb | 4 ++-- test/models/host/subscription_facet_test.rb | 8 ++++---- test/models/sync_plan_test.rb | 10 +++++----- test/support/candlepin/owner_support.rb | 2 +- test/support/capsule_support.rb | 2 +- test/support/fixtures_support.rb | 2 +- 41 files changed, 82 insertions(+), 74 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index c3e945283ae..aae77599688 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -46,6 +46,9 @@ IfUnlessModifier: RescueModifier: Enabled: false +RescueWithoutErrorClass: + Enabled: false + WhileUntilModifier: Enabled: false @@ -104,7 +107,7 @@ Style/StringLiterals: Style/WordArray: Enabled: false # don't force usage of %w() -Style/FileName: +Naming/FileName: Exclude: ['script/**', 'db/seeds.d/**'] # scripts are hyphened case Rails/ScopeArgs: @@ -125,3 +128,16 @@ Style/FrozenStringLiteralComment: Rails/HttpPositionalArguments: Enabled: false + +Gemspec/OrderedDependencies: + Enabled: false + +Style/CommentedKeyword: + Enabled: false + +# we use booleans as symbols for scoped search +Lint/BooleanSymbol: + Enabled: false + +Lint/UriEscapeUnescape: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 41ef2c1d00d..c452704ebd8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -232,7 +232,7 @@ Style/EmptyMethod: # Offense count: 2 # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms. # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS -Style/FileName: +Naming/FileName: Enabled: false # Offense count: 217 @@ -324,7 +324,7 @@ Style/UnneededInterpolation: # Offense count: 19 # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: snake_case, normalcase, non_integer -Style/VariableNumber: +Naming/VariableNumber: Enabled: false # Offense count: 15 diff --git a/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb b/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb index 024ab285f03..30062b7b6b1 100644 --- a/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +++ b/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb @@ -270,7 +270,7 @@ def facts end def serials - @host.subscription_facet.last_checkin = DateTime.now + @host.subscription_facet.last_checkin = Time.now @host.subscription_facet.save! render :json => Katello::Resources::Candlepin::Consumer.serials(@host.subscription_facet.uuid) end diff --git a/app/controllers/katello/api/v2/package_groups_controller.rb b/app/controllers/katello/api/v2/package_groups_controller.rb index 50621145a3a..34eb8cbc5d0 100644 --- a/app/controllers/katello/api/v2/package_groups_controller.rb +++ b/app/controllers/katello/api/v2/package_groups_controller.rb @@ -54,7 +54,7 @@ def destroy render :json => {:status => "success"} end - def available_for_content_view_filter(filter, collection) + def available_for_content_view_filter(filter, _collection) collection_ids = [] current_ids = filter.package_group_rules.map(&:uuid) filter.applicable_repos.each do |repo| diff --git a/app/controllers/katello/api/v2/repositories_controller.rb b/app/controllers/katello/api/v2/repositories_controller.rb index 8bca9d50ece..38c897d6bb0 100644 --- a/app/controllers/katello/api/v2/repositories_controller.rb +++ b/app/controllers/katello/api/v2/repositories_controller.rb @@ -195,7 +195,7 @@ def sync :source_url => params[:source_url] } - if params[:source_url].present? && params[:source_url] !~ /\A#{URI.regexp}\z/ + if params[:source_url].present? && params[:source_url] !~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/ fail HttpErrors::BadRequest, _("source URL is malformed") end diff --git a/app/helpers/katello/concerns/smart_proxy_helper_extensions.rb b/app/helpers/katello/concerns/smart_proxy_helper_extensions.rb index f1dd9cbc6c4..aa8f700efde 100644 --- a/app/helpers/katello/concerns/smart_proxy_helper_extensions.rb +++ b/app/helpers/katello/concerns/smart_proxy_helper_extensions.rb @@ -4,7 +4,7 @@ module SmartProxyHelperExtensions def disks(storage) mount_points = {} disks = [] - storage.each do |_name, values| + storage.each_value do |values| mount = values['mounted'] mount_points[mount].nil? ? mount_points[mount] = [values['path']] : mount_points[mount] << values['path'] values['header'] = "#{mount_points[mount].to_sentence} (on #{values['filesystem']})" diff --git a/app/lib/actions/candlepin/listen_on_candlepin_events.rb b/app/lib/actions/candlepin/listen_on_candlepin_events.rb index b07343e3420..8a3f01f8f31 100644 --- a/app/lib/actions/candlepin/listen_on_candlepin_events.rb +++ b/app/lib/actions/candlepin/listen_on_candlepin_events.rb @@ -172,7 +172,7 @@ def act_on_event(event) output[:connection] = "Connected" Actions::Candlepin::ImportPoolHandler.new(Rails.logger).handle(event) output[:last_message] = "#{event.message_id} - #{event.subject}" - output[:last_message_time] = DateTime.now.to_s + output[:last_message_time] = Time.now.to_s output[:messages] = event.message_id rescue => e output[:last_event_error] = e.message diff --git a/app/lib/actions/katello/content_view_puppet_environment/clone.rb b/app/lib/actions/katello/content_view_puppet_environment/clone.rb index 93e160a1a08..466e4ddaee7 100644 --- a/app/lib/actions/katello/content_view_puppet_environment/clone.rb +++ b/app/lib/actions/katello/content_view_puppet_environment/clone.rb @@ -61,7 +61,7 @@ def setup_puppet_environment_clone(from_version, clone) def find_or_build_puppet_env(version, environment, puppet_modules_present) puppet_env = ::Katello::ContentViewPuppetEnvironment.in_content_view(version.content_view). in_environment(environment).readonly(false).first - puppet_env = version.content_view.build_puppet_env(:environment => environment) unless puppet_env + puppet_env ||= version.content_view.build_puppet_env(:environment => environment) if puppet_env.puppet_environment.nil? && puppet_modules_present puppet_env.puppet_environment = ::Katello::Foreman.build_puppet_environment(version.content_view.organization, @@ -72,7 +72,7 @@ def find_or_build_puppet_env(version, environment, puppet_modules_present) def find_or_build_puppet_archive(new_version) puppet_env = new_version.archive_puppet_environment - puppet_env = new_version.content_view.build_puppet_env(:version => new_version) unless puppet_env + puppet_env ||= new_version.content_view.build_puppet_env(:version => new_version) puppet_env end end diff --git a/app/lib/actions/katello/event_queue/monitor.rb b/app/lib/actions/katello/event_queue/monitor.rb index 443753fac07..81c5b41a6b1 100644 --- a/app/lib/actions/katello/event_queue/monitor.rb +++ b/app/lib/actions/katello/event_queue/monitor.rb @@ -5,7 +5,7 @@ class Monitor < Actions::Base include ::Dynflow::Action::Singleton Event = Algebrick.type do - fields! event_type: String, object_id: Integer, created_at: DateTime + fields! event_type: String, object_id: Integer, created_at: Time end Fatal = Algebrick.type do diff --git a/app/lib/actions/katello/host/register.rb b/app/lib/actions/katello/host/register.rb index 8105c068e44..1264ab999ca 100644 --- a/app/lib/actions/katello/host/register.rb +++ b/app/lib/actions/katello/host/register.rb @@ -112,7 +112,7 @@ def plan_content_facet(host, content_view_environment) def plan_subscription_facet(host, activation_keys, consumer_params) subscription_facet = host.subscription_facet || ::Katello::Host::SubscriptionFacet.new(:host => host) - subscription_facet.last_checkin = DateTime.now + subscription_facet.last_checkin = Time.now subscription_facet.update_from_consumer_attributes(consumer_params.except(:installedProducts, :guestIds, :facts)) subscription_facet.save! subscription_facet.activation_keys = activation_keys diff --git a/app/lib/actions/katello/host/update.rb b/app/lib/actions/katello/host/update.rb index 60a4a334290..9a075a7d65e 100644 --- a/app/lib/actions/katello/host/update.rb +++ b/app/lib/actions/katello/host/update.rb @@ -10,9 +10,7 @@ def plan(host, consumer_params = nil) host.content_facet.save! if host.content_facet if host.subscription_facet - unless consumer_params - consumer_params = host.subscription_facet.consumer_attributes - end + consumer_params ||= host.subscription_facet.consumer_attributes cp_update = plan_action(::Actions::Candlepin::Consumer::Update, host.subscription_facet.uuid, consumer_params) end diff --git a/app/lib/actions/pulp/consumer/abstract_content_action.rb b/app/lib/actions/pulp/consumer/abstract_content_action.rb index 19cd240fcbb..9eedc788455 100644 --- a/app/lib/actions/pulp/consumer/abstract_content_action.rb +++ b/app/lib/actions/pulp/consumer/abstract_content_action.rb @@ -34,7 +34,7 @@ def find_errors(tasks) messages = [] tasks.each do |pulp_task| if pulp_task[:result] && pulp_task[:result][:details] - pulp_task[:result][:details].each do |_content_type, result| + pulp_task[:result][:details].each_value do |result| unless result[:succeeded] messages << result[:details][:message] end diff --git a/app/lib/katello/errors.rb b/app/lib/katello/errors.rb index 5ff1eff7489..7f31abdfaf6 100644 --- a/app/lib/katello/errors.rb +++ b/app/lib/katello/errors.rb @@ -68,10 +68,6 @@ def initialize(msg, errors = []) super(msg) end - def errors - return @errors - end - def message if @errors.nil? "#{to_s}: " + _("No errors") diff --git a/app/lib/katello/util/support.rb b/app/lib/katello/util/support.rb index 06bcf893555..924d89fe040 100644 --- a/app/lib/katello/util/support.rb +++ b/app/lib/katello/util/support.rb @@ -12,7 +12,7 @@ def self.time end def self.scrub(params, &block_to_match) - params.keys.each do |key| + params.each_key do |key| if params[key].is_a?(Hash) scrub(params[key], &block_to_match) elsif block_to_match.call(key, params[key]) diff --git a/app/models/katello/candlepin/product_content.rb b/app/models/katello/candlepin/product_content.rb index db807d4587b..9a1b0c245c4 100644 --- a/app/models/katello/candlepin/product_content.rb +++ b/app/models/katello/candlepin/product_content.rb @@ -21,6 +21,7 @@ def destroy @content.destroy end + # rubocop:disable Lint/DuplicateMethods def product @product ||= Product.find(@product_id) if @product_id @product diff --git a/app/models/katello/concerns/content_facet_host_extensions.rb b/app/models/katello/concerns/content_facet_host_extensions.rb index 2d8f1201576..85db44e2a13 100644 --- a/app/models/katello/concerns/content_facet_host_extensions.rb +++ b/app/models/katello/concerns/content_facet_host_extensions.rb @@ -17,10 +17,10 @@ module ContentFacetHostExtensions :updated => Katello::TraceStatus::UP_TO_DATE }.freeze - has_one :errata_status_object, :class_name => 'Katello::ErrataStatus', :foreign_key => 'host_id' + has_one :errata_status_object, :class_name => 'Katello::ErrataStatus', :foreign_key => 'host_id', :dependent => :destroy scoped_search :on => :status, :relation => :errata_status_object, :rename => :errata_status, :complete_value => ERRATA_STATUS_MAP - has_one :trace_status_object, :class_name => 'Katello::TraceStatus', :foreign_key => 'host_id' + has_one :trace_status_object, :class_name => 'Katello::TraceStatus', :foreign_key => 'host_id', :dependent => :destroy scoped_search :on => :status, :relation => :trace_status_object, :rename => :trace_status, :complete_value => TRACE_STATUS_MAP diff --git a/app/models/katello/concerns/smart_proxy_extensions.rb b/app/models/katello/concerns/smart_proxy_extensions.rb index d4dccc70c7b..591aae07d0b 100644 --- a/app/models/katello/concerns/smart_proxy_extensions.rb +++ b/app/models/katello/concerns/smart_proxy_extensions.rb @@ -1,3 +1,4 @@ +# rubocop:disable Style/MixinUsage module Katello module Concerns module SmartProxyExtensions @@ -43,7 +44,7 @@ module SmartProxyExtensions :inverse_of => :content_source, :dependent => :nullify has_many :hostgroups, :class_name => "::Hostgroup", :foreign_key => :content_source_id, - :inverse_of => :content_source + :inverse_of => :content_source, :dependent => :nullify validates :download_policy, inclusion: { :in => DOWNLOAD_POLICIES, diff --git a/app/models/katello/concerns/subscription_facet_host_extensions.rb b/app/models/katello/concerns/subscription_facet_host_extensions.rb index c75cfaec722..852afbdbd8e 100644 --- a/app/models/katello/concerns/subscription_facet_host_extensions.rb +++ b/app/models/katello/concerns/subscription_facet_host_extensions.rb @@ -18,7 +18,7 @@ module SubscriptionFacetHostExtensions has_many :activation_keys, :through => :subscription_facet has_many :pools, :through => :subscription_facet has_many :subscriptions, :through => :pools - has_one :subscription_status_object, :class_name => 'Katello::SubscriptionStatus', :foreign_key => 'host_id' + has_one :subscription_status_object, :class_name => 'Katello::SubscriptionStatus', :foreign_key => 'host_id', :dependent => :destroy has_one :hypervisor_host, :through => :subscription_facet scoped_search :on => :status, :relation => :subscription_status_object, :rename => :subscription_status, diff --git a/app/models/katello/content_view.rb b/app/models/katello/content_view.rb index 7d37c5a20bc..e9b2ee91682 100644 --- a/app/models/katello/content_view.rb +++ b/app/models/katello/content_view.rb @@ -165,7 +165,7 @@ def publish_puppet_environment? def promoted? # if the view exists in more than 1 environment, it has been promoted - self.environments.length > 1 ? true : false + self.environments.many? end #NOTE: this function will most likely become obsolete once we drop api v1 diff --git a/app/models/katello/glue/candlepin/activation_key.rb b/app/models/katello/glue/candlepin/activation_key.rb index f015280cd0f..c1e745bf005 100644 --- a/app/models/katello/glue/candlepin/activation_key.rb +++ b/app/models/katello/glue/candlepin/activation_key.rb @@ -1,4 +1,4 @@ -# rubocop:disable Style/AccessorMethodName +# rubocop:disable Naming/AccessorMethodName module Katello module Glue::Candlepin::ActivationKey def self.included(base) diff --git a/app/models/katello/glue/candlepin/pool.rb b/app/models/katello/glue/candlepin/pool.rb index f20dd388655..ad33849f8d6 100644 --- a/app/models/katello/glue/candlepin/pool.rb +++ b/app/models/katello/glue/candlepin/pool.rb @@ -115,11 +115,11 @@ def import_data(index_hosts = true) pool_attributes[:pool_type] = pool_json["type"] if pool_json.key?("type") if pool_attributes.key?(:multi_entitlement) - pool_attributes[:multi_entitlement] = pool_attributes[:multi_entitlement] == "yes" ? true : false + pool_attributes[:multi_entitlement] = pool_attributes[:multi_entitlement] == "yes" end if pool_attributes.key?(:virtual) - pool_attributes[:virt_only] = pool_attributes["virtual"] == 'true' ? true : false + pool_attributes[:virt_only] = pool_attributes["virtual"] == 'true' end pool_attributes[:host_id] = pool_attributes["requiresHost"] if pool_attributes.key?("requiresHost") diff --git a/app/models/katello/glue/pulp/repo.rb b/app/models/katello/glue/pulp/repo.rb index cac8d877252..f68858dd51a 100644 --- a/app/models/katello/glue/pulp/repo.rb +++ b/app/models/katello/glue/pulp/repo.rb @@ -648,7 +648,7 @@ def needs_metadata_publish? return false if last_sync.nil? return true if last_publish.nil? - DateTime.parse(last_sync) >= DateTime.parse(last_publish) + Time.parse(last_sync) >= Time.parse(last_publish) end def last_sync_task diff --git a/app/models/katello/host/subscription_facet.rb b/app/models/katello/host/subscription_facet.rb index d2b0912c8ad..d906be0eeca 100644 --- a/app/models/katello/host/subscription_facet.rb +++ b/app/models/katello/host/subscription_facet.rb @@ -140,19 +140,17 @@ def self.new_host_from_facts(facts, org, location) def self.update_facts(host, rhsm_facts) return if host.build? || rhsm_facts.nil? rhsm_facts[:_type] = RhsmFactName::FACT_TYPE - rhsm_facts[:_timestamp] = DateTime.now.to_s + rhsm_facts[:_timestamp] = Time.now.to_s host.import_facts(rhsm_facts) end def self.find_or_create_host(organization, rhsm_params) host = find_host(rhsm_params[:facts], organization) - unless host - host = Katello::Host::SubscriptionFacet.new_host_from_facts( - rhsm_params[:facts], - organization, - Location.unscoped.find_by_title(::Setting[:default_location_subscribed_hosts]) - ) - end + host ||= Katello::Host::SubscriptionFacet.new_host_from_facts( + rhsm_params[:facts], + organization, + Location.unscoped.find_by_title(::Setting[:default_location_subscribed_hosts]) + ) host.organization = organization unless host.organization host end diff --git a/app/models/katello/rhsm_fact_importer.rb b/app/models/katello/rhsm_fact_importer.rb index 9be807024d8..e28dbfe5c6f 100644 --- a/app/models/katello/rhsm_fact_importer.rb +++ b/app/models/katello/rhsm_fact_importer.rb @@ -4,7 +4,7 @@ def fact_name_class Katello::RhsmFactName end - def normalize(facts) + def normalize(_facts) facts = super facts = change_separator(facts) add_compose_facts(facts) @@ -12,7 +12,7 @@ def normalize(facts) def add_compose_facts(facts) additional_keys = [] - facts.keys.each do |fact_name| + facts.each_key do |fact_name| parts = fact_name.split(RhsmFactName::SEPARATOR) additional_keys += parts[0..-2].reduce([]) { |memo, part| memo << [memo.last, part].compact.join(RhsmFactName::SEPARATOR) } end diff --git a/app/models/katello/rhsm_fact_parser.rb b/app/models/katello/rhsm_fact_parser.rb index fe846ec03cd..3302bb94565 100644 --- a/app/models/katello/rhsm_fact_parser.rb +++ b/app/models/katello/rhsm_fact_parser.rb @@ -37,7 +37,7 @@ def interfaces end end - # rubocop:disable Style/AccessorMethodName: + # rubocop:disable Naming/AccessorMethodName: def get_interfaces mac_keys = facts.keys.select { |f| f =~ /net\.interface\..*\.mac_address/ } names = mac_keys.map do |key| diff --git a/app/models/katello/sync_plan.rb b/app/models/katello/sync_plan.rb index 6d0a9949a03..7496bc7112a 100644 --- a/app/models/katello/sync_plan.rb +++ b/app/models/katello/sync_plan.rb @@ -58,7 +58,7 @@ def plan_date_time def schedule_format return nil if DURATION[self.interval].nil? date = self.sync_date - date = next_sync_date if enabled? && self.sync_date < DateTime.now + date = next_sync_date if enabled? && self.sync_date < Time.now "#{date.iso8601}/P#{DURATION[self.interval]}" end diff --git a/db/migrate/20161014133811_move_content_view_version_description_to_histories.rb b/db/migrate/20161014133811_move_content_view_version_description_to_histories.rb index c14c6e03c39..5c94a76a4d6 100644 --- a/db/migrate/20161014133811_move_content_view_version_description_to_histories.rb +++ b/db/migrate/20161014133811_move_content_view_version_description_to_histories.rb @@ -22,13 +22,11 @@ class CVHistory < ApplicationRecord def up FakeContentViewVersion.find_each do |version| publish_history = version.history.publish.successful.first - unless publish_history - publish_history = CVHistory.create!(action: CVHistory.actions[:publish], + publish_history ||= CVHistory.create!(action: CVHistory.actions[:publish], katello_content_view_version_id: version.id, status: 'successful', user: '' ) - end publish_history.update_attributes!(notes: version[:description]) end diff --git a/lib/katello/tasks/rubocop.rake b/lib/katello/tasks/rubocop.rake index e3732ab2ce9..b5a301b7db3 100644 --- a/lib/katello/tasks/rubocop.rake +++ b/lib/katello/tasks/rubocop.rake @@ -3,7 +3,7 @@ require File.expand_path("../engine", File.dirname(__FILE__)) namespace :katello do desc "Runs Rubocop style checker on Katello code" task :rubocop do - system("bundle exec rubocop #{Katello::Engine.root}") + system("bundle exec rubocop -D #{Katello::Engine.root}") exit($CHILD_STATUS.exitstatus) end diff --git a/lib/katello/tasks/virt_who_report.rake b/lib/katello/tasks/virt_who_report.rake index 26c89941cc4..add503aad41 100644 --- a/lib/katello/tasks/virt_who_report.rake +++ b/lib/katello/tasks/virt_who_report.rake @@ -1,12 +1,12 @@ namespace :katello do - desc <<-END_DESC + desc <<-DESCRIPTION Report on hypervisors without VDC subscriptions and guests consuming virtual entitlements. Returns non-negative exit code if any issue is found. Options: CSV - Output in csv format. Example: CSV=true LIMIT - only execute on a specified number of hosts (useful when re-running with different options). Example: LIMIT=500 IGNORE - ignore one or more pools, separated via a pipe character '|'. Example: IGNORE="Red Hat Enterprise Linux Server with Smart Management, Standard (Physical or Virtual Nodes)|Some Other Pool" -END_DESC +DESCRIPTION task :virt_who_report => ["environment", "check_ping"] do class ProblemItem attr_accessor :host, :hypervisor, :message diff --git a/spec/models/model_spec_helper.rb b/spec/models/model_spec_helper.rb index 49e67d1e297..f06c1b17da5 100644 --- a/spec/models/model_spec_helper.rb +++ b/spec/models/model_spec_helper.rb @@ -2,7 +2,7 @@ module Katello module OrchestrationHelper - CERT = < '123') diff --git a/test/actions/katello/event_queue_monitor_test.rb b/test/actions/katello/event_queue_monitor_test.rb index 978da0eb48d..5431c17c9ae 100644 --- a/test/actions/katello/event_queue_monitor_test.rb +++ b/test/actions/katello/event_queue_monitor_test.rb @@ -32,7 +32,7 @@ class Actions::Katello::EventQueueMonitorTest < ActiveSupport::TestCase Katello::Events::ImportHostApplicability.any_instance.expects(:run).once action = run_action planned_action - action.run(action_class::Event[event.event_type, event.object_id, event.created_at.to_datetime]) + action.run(action_class::Event[event.event_type, event.object_id, event.created_at.to_time]) end end end diff --git a/test/controllers/api/v2/sync_plans_controller_test.rb b/test/controllers/api/v2/sync_plans_controller_test.rb index fc7c66a9fab..f72166222ed 100644 --- a/test/controllers/api/v2/sync_plans_controller_test.rb +++ b/test/controllers/api/v2/sync_plans_controller_test.rb @@ -29,7 +29,7 @@ def setup login_user(User.find(users(:admin).id)) @request.env['HTTP_ACCEPT'] = 'application/json' Repository.any_instance.stubs(:sync_status).returns(PulpSyncStatus.new({})) - Repository.any_instance.stubs(:last_sync).returns(DateTime.now.to_s) + Repository.any_instance.stubs(:last_sync).returns(Time.now.to_s) models permissions end diff --git a/test/katello_test_helper.rb b/test/katello_test_helper.rb index 1dafeb95e65..fd6a1a329c2 100644 --- a/test/katello_test_helper.rb +++ b/test/katello_test_helper.rb @@ -133,7 +133,7 @@ def setup_controller_defaults_api alias_method :login_user, :set_user - # rubocop:disable Style/AccessorMethodName + # rubocop:disable Naming/AccessorMethodName def set_organization(org) session[:current_organization_id] = org.id end @@ -264,7 +264,7 @@ def stub_lazy_accessors(model, stubs) model_class = model.class end return unless model_class.ancestors.include?(Katello::LazyAccessor) - stubs.keys.each do |attr| + stubs.each_key do |attr| unless model_class.lazy_attributes.include?(attr) fail "#{attr} is not a lazy attribute for #{model_class}, expected one of #{model_class.lazy_attributes}" end diff --git a/test/lib/capsule_content_test.rb b/test/lib/capsule_content_test.rb index 44f481230b9..553a959f205 100644 --- a/test/lib/capsule_content_test.rb +++ b/test/lib/capsule_content_test.rb @@ -61,7 +61,7 @@ def assert_tasks_equal(expected_tasks, actual_tasks) @tasks[:running1] = FactoryGirl.create(:dynflow_task, :running) @tasks[:running2] = FactoryGirl.create(:dynflow_task, :running) - @tasks.values.each do |task| + @tasks.each_value do |task| ForemanTasks::Lock.link!(capsule_content.capsule, task.id) end diff --git a/test/models/erratum_test.rb b/test/models/erratum_test.rb index 100b45d6847..79ec7b100d9 100644 --- a/test/models/erratum_test.rb +++ b/test/models/erratum_test.rb @@ -89,7 +89,7 @@ def test_not_applicable_to_hosts def test_update_from_json errata = katello_errata(:security) - json = errata.attributes.merge('description' => 'an update', 'updated' => DateTime.now, 'reboot_suggested' => true) + json = errata.attributes.merge('description' => 'an update', 'updated' => Time.now, 'reboot_suggested' => true) errata.update_from_json(json) errata = Erratum.find(errata.id) assert_equal errata.description, json['description'] @@ -118,7 +118,7 @@ def test_update_from_json_truncates_title "fortune. Omitted, all the voyage of their life is bound in shallows and in miseries. "\ "On such a full sea are we now afloat. And we must take the current when it serves, or "\ "lose our ventures. - William Shakespeare" - json = errata.attributes.merge('description' => 'an update', 'updated' => DateTime.now, 'title' => title) + json = errata.attributes.merge('description' => 'an update', 'updated' => Time.now, 'title' => title) errata.update_from_json(json) assert_equal Erratum.find(errata.id).title.size, 255 end @@ -129,7 +129,7 @@ def test_update_from_json_duplicate_packages #Issue 9312 errata = katello_errata(:security) pkg_count = errata.packages.count - json = errata.attributes.merge('description' => 'an update', 'updated' => DateTime.now, 'pkglist' => [{'packages' => pkg_list}]) + json = errata.attributes.merge('description' => 'an update', 'updated' => Time.now, 'pkglist' => [{'packages' => pkg_list}]) errata.update_from_json(json) assert_equal errata.reload.packages.count, pkg_count + 1 diff --git a/test/models/host/content_facet_test.rb b/test/models/host/content_facet_test.rb index a756fab06f4..64e09218c6f 100644 --- a/test/models/host/content_facet_test.rb +++ b/test/models/host/content_facet_test.rb @@ -360,7 +360,7 @@ def test_lifecycle_environment_id_search def test_errata_status_search status = host.get_status(Katello::ErrataStatus) status.status = Katello::ErrataStatus::NEEDED_ERRATA - status.reported_at = DateTime.now + status.reported_at = Time.now status.save! assert_includes ::Host::Managed.search_for("errata_status = errata_needed"), content_facet.host @@ -369,7 +369,7 @@ def test_errata_status_search def test_trace_status_search status = host.get_status(Katello::TraceStatus) status.status = Katello::TraceStatus::REQUIRE_PROCESS_RESTART - status.reported_at = DateTime.now + status.reported_at = Time.now status.save! assert_includes ::Host::Managed.search_for("trace_status = process_restart_needed"), content_facet.host diff --git a/test/models/host/subscription_facet_test.rb b/test/models/host/subscription_facet_test.rb index a82fcacc8f5..8f1470ceedf 100644 --- a/test/models/host/subscription_facet_test.rb +++ b/test/models/host/subscription_facet_test.rb @@ -50,7 +50,7 @@ def test_search_uuid end def test_search_last_checkin - subscription_facet.last_checkin = DateTime.now - 1.hour + subscription_facet.last_checkin = Time.now - 1.hour subscription_facet.save! assert_includes ::Host.search_for('last_checkin > "3 hours ago"'), host @@ -62,7 +62,7 @@ def test_create end def test_update_from_consumer_attributes - params = { :lastCheckin => DateTime.now, :autoheal => true, :serviceLevel => "Premium", :releaseVer => "7Server" } + params = { :lastCheckin => Time.now, :autoheal => true, :serviceLevel => "Premium", :releaseVer => "7Server" } subscription_facet.update_from_consumer_attributes(params.with_indifferent_access) assert_equal subscription_facet.last_checkin, params[:lastCheckin] @@ -72,7 +72,7 @@ def test_update_from_consumer_attributes end def test_update_from_consumer_attributes_release_version - params = { :lastCheckin => DateTime.now, :autoheal => true, :serviceLevel => "Premium", :releaseVer => {'releaseVer' => "7Server" }} + params = { :lastCheckin => Time.now, :autoheal => true, :serviceLevel => "Premium", :releaseVer => {'releaseVer' => "7Server" }} subscription_facet.update_from_consumer_attributes(params.with_indifferent_access) assert_equal '7Server', subscription_facet.release_version @@ -129,7 +129,7 @@ def test_find_or_create_host_no_org def test_subscription_status status = Katello::SubscriptionStatus.new(:host => host) status.status = Katello::SubscriptionStatus::INVALID - status.reported_at = DateTime.now + status.reported_at = Time.now status.save! assert_includes ::Host::Managed.search_for("subscription_status = invalid"), host diff --git a/test/models/sync_plan_test.rb b/test/models/sync_plan_test.rb index e2abcfb8cdf..a78fd7f794f 100644 --- a/test/models/sync_plan_test.rb +++ b/test/models/sync_plan_test.rb @@ -4,7 +4,7 @@ module Katello class SyncPlanTest < ActiveSupport::TestCase def setup @organization = get_organization - @plan = SyncPlan.new(:name => 'Norman Rockwell', :organization => @organization, :sync_date => DateTime.now, :interval => 'daily') + @plan = SyncPlan.new(:name => 'Norman Rockwell', :organization => @organization, :sync_date => Time.now, :interval => 'daily') end def test_invalid_intervals @@ -102,7 +102,7 @@ def test_delete def test_schedule_format @plan.interval = 'weekly' - @plan.sync_date = DateTime.now + 3.days + @plan.sync_date = Time.now + 3.days schedule = @plan.schedule_format refute_nil schedule @@ -112,7 +112,7 @@ def test_schedule_format def test_schedule_format_past_weekly @plan.interval = 'weekly' - @plan.sync_date = DateTime.now - 3.days + @plan.sync_date = Time.now - 3.days schedule = @plan.schedule_format refute_nil schedule @@ -122,7 +122,7 @@ def test_schedule_format_past_weekly def test_schedule_format_past_daily @plan.interval = 'daily' - @plan.sync_date = DateTime.now - 3.days + @plan.sync_date = Time.now - 3.days schedule = @plan.schedule_format refute_nil schedule @@ -132,7 +132,7 @@ def test_schedule_format_past_daily def test_schedule_format_disabled @plan.interval = 'daily' - @plan.sync_date = DateTime.now - 3.days + @plan.sync_date = Time.now - 3.days @plan.enabled = false schedule = @plan.schedule_format diff --git a/test/support/candlepin/owner_support.rb b/test/support/candlepin/owner_support.rb index 3b3680e87a4..1ca13c3376c 100644 --- a/test/support/candlepin/owner_support.rb +++ b/test/support/candlepin/owner_support.rb @@ -1,6 +1,6 @@ require 'katello_test_helper' -# rubocop:disable Style/AccessorMethodName +# rubocop:disable Naming/AccessorMethodName module Katello module CandlepinOwnerSupport @organization = nil diff --git a/test/support/capsule_support.rb b/test/support/capsule_support.rb index 965f232873b..387d1997bcc 100644 --- a/test/support/capsule_support.rb +++ b/test/support/capsule_support.rb @@ -5,7 +5,7 @@ def pulp_feature end def proxy_with_pulp(proxy_resource = nil) - proxy_resource = :four unless proxy_resource + proxy_resource ||= :four smart_proxies(proxy_resource).tap do |proxy| unless proxy.features.include?(pulp_feature) proxy.features << pulp_feature diff --git a/test/support/fixtures_support.rb b/test/support/fixtures_support.rb index 4838b2806b7..7d96c4e653d 100644 --- a/test/support/fixtures_support.rb +++ b/test/support/fixtures_support.rb @@ -42,7 +42,7 @@ module FixturesSupport :katello_subscription_facet_pools => Katello::SubscriptionFacetPool }.freeze - # rubocop:disable Style/AccessorMethodName + # rubocop:disable Naming/AccessorMethodName def self.set_fixture_classes(test_class) FIXTURE_CLASSES.each { |k, v| test_class.set_fixture_class(k => v) } end