Skip to content

Commit

Permalink
Fixes #21467 - Updates to rubocop 0.51.0
Browse files Browse the repository at this point in the history
  • Loading branch information
John Mitsch committed Oct 26, 2017
1 parent fafe91d commit 1f673a5
Show file tree
Hide file tree
Showing 41 changed files with 82 additions and 74 deletions.
18 changes: 17 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ IfUnlessModifier:
RescueModifier:
Enabled: false

RescueWithoutErrorClass:
Enabled: false

WhileUntilModifier:
Enabled: false

Expand Down Expand Up @@ -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:
Expand All @@ -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
4 changes: 2 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/katello/api/v2/repositories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']})"
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/candlepin/listen_on_candlepin_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/katello/event_queue/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/katello/host/register.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions app/lib/actions/katello/host/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/pulp/consumer/abstract_content_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions app/lib/katello/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion app/lib/katello/util/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
1 change: 1 addition & 0 deletions app/models/katello/candlepin/product_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def destroy
@content.destroy
end

# rubocop:disable Lint/DuplicateMethods
def product
@product ||= Product.find(@product_id) if @product_id
@product
Expand Down
4 changes: 2 additions & 2 deletions app/models/katello/concerns/content_facet_host_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion app/models/katello/concerns/smart_proxy_extensions.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# rubocop:disable Style/MixinUsage
module Katello
module Concerns
module SmartProxyExtensions
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/models/katello/content_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/katello/glue/candlepin/activation_key.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# rubocop:disable Style/AccessorMethodName
# rubocop:disable Naming/AccessorMethodName
module Katello
module Glue::Candlepin::ActivationKey
def self.included(base)
Expand Down
4 changes: 2 additions & 2 deletions app/models/katello/glue/candlepin/pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion app/models/katello/glue/pulp/repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions app/models/katello/host/subscription_facet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/models/katello/rhsm_fact_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ def fact_name_class
Katello::RhsmFactName
end

def normalize(facts)
def normalize(_facts)
facts = super
facts = change_separator(facts)
add_compose_facts(facts)
end

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
Expand Down
2 changes: 1 addition & 1 deletion app/models/katello/rhsm_fact_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion app/models/katello/sync_plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/katello/tasks/rubocop.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/katello/tasks/virt_who_report.rake
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions spec/models/model_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Katello
module OrchestrationHelper
CERT = <<EOCERT.strip_heredoc.freeze
CERT = <<HERECERT.strip_heredoc.freeze
-----BEGIN CERTIFICATE-----
MIIF7DCCBVWgAwIBAgIIB1AMflT0SrswDQYJKoZIhvcNAQEFBQAwRjElMCMGA1UE
Awwca2lsbGluZy10aW1lLmFwcGxpZWRsb2dpYy5jYTELMAkGA1UEBhMCVVMxEDAO
Expand Down Expand Up @@ -37,9 +37,9 @@ module OrchestrationHelper
hqAQBzKqeQEoRml1CIZHgB7Q5OmVN+FC0ftv+Iy/PccyIFdcJh87UAI+1UoT80kR
A5qqap7hk8CDz3HWi9/YGGU89EjLlFpSF5SPbFAWpA8=
-----END CERTIFICATE-----
EOCERT
HERECERT

KEY = <<EOKEY.strip_heredoc.freeze
KEY = <<HEREKEY.strip_heredoc.freeze
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAlkidXB/p2Vj5zGF9Uh3WxvD6175G1JmA6kARy14ZlyEKVoWO
IvnbhHWi6bVrxtLLEvLBXeX8uJHnP+I/bthBDMfR3+yBBMrShnTKvTJz/pZk6HG0
Expand Down Expand Up @@ -67,7 +67,7 @@ module OrchestrationHelper
rKH9OkgKEvwkf8zQjO/XSvuoac83uBEFgKXJwYLHPA3U20JrchKU7klLwzSsmrXA
5JP55pqMjeCZBj2fNkfWrcNPQVdxq25zggRbM6Bmsl0JylpTr3Mt
-----END RSA PRIVATE KEY-----
EOKEY
HEREKEY

def disable_activation_key_orchestration
Resources::Candlepin::ActivationKey.stubs(:create).returns(:id => '123')
Expand Down
2 changes: 1 addition & 1 deletion test/actions/katello/event_queue_monitor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit 1f673a5

Please sign in to comment.