Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Style Cops #11067

Merged
merged 6 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,18 @@ Rails/UniqueValidationWithoutIndex:

Style/TrailingCommaInHashLiteral:
Enabled: true

Style/SingleArgumentDig:
Enabled: false

Style/RedundantBegin:
Enabled: false

Style/ExplicitBlockArgument:
Enabled: false

Style/GlobalStdStream:
Enabled: false

Style/RedundantFileExtensionInRequire:
Enabled: false
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def content_override
param :content_access_mode_env, :bool, :desc => N_("Limit content to just that available in the activation key's content view version")
param_group :search, Api::V2::ApiController
def product_content
# note this is just there as a place holder for apipie.
# NOTE: this is just there as a place holder for apipie.
# The routing would automatically redirect it to repository_sets#index
end

Expand Down
3 changes: 1 addition & 2 deletions app/controllers/katello/api/v2/environments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ def environment_params
attrs = [:name, :description, :registry_name_pattern, :registry_unauthenticated_pull]
end
attrs << :label if params[:action] == "create"
parms = params.require(:environment).permit(*attrs)
parms
params.require(:environment).permit(*attrs)
end

def find_content_view
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/katello/api/v2/repositories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ def index_relation
query = query.where(:root_id => RootRepository.where(:label => params[:label])) if params[:label]
query = index_relation_content_unit(query)
query = index_relation_content_view(query)
query = index_relation_environment(query)
query
index_relation_environment(query)
end

def index_relation_product(query)
Expand Down
23 changes: 11 additions & 12 deletions app/controllers/katello/api/v2/repository_sets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,17 @@ def check_airgapped
end

def sort_score(pc) # sort order for enabled
score = if pc.enabled_content_override&.value == "1"
4 # overridden to enabled
elsif pc.enabled_content_override.nil? && pc.enabled
3 # enabled
elsif pc.enabled_content_override.nil? && !pc.enabled
2 # disabled
elsif pc.enabled_content_override&.value == "0"
1 # overridden to disabled
else
0
end
score
if pc.enabled_content_override&.value == "1"
4 # overridden to enabled
elsif pc.enabled_content_override.nil? && pc.enabled
3 # enabled
elsif pc.enabled_content_override.nil? && !pc.enabled
2 # disabled
elsif pc.enabled_content_override&.value == "0"
1 # overridden to disabled
else
0
end
end

def custom_sort_results(unsorted_relation)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/katello/katello_urls_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def subscription_manager_configuration_url(host = nil, rpm = true, hostname: nil
returns String, desc: 'Absolute path to a file'
end
def repository_url(content_path, _content_type = nil, schema = 'http')
return content_path if content_path =~ %r|^([\w\-\+]+)://|
return content_path if content_path =~ %r|^([\w\-+]+)://|
url = if @host.content_source
"#{schema}://#{@host.content_source.hostname}"
else
Expand Down
3 changes: 1 addition & 2 deletions app/lib/actions/katello/capsule_content/verify_checksum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def repos_to_repair(smart_proxy, environment, content_view, repository)
if repository
[repository]
else
repositories = smart_proxy_helper.repositories_available_to_capsule(environment, content_view).by_rpm_count
repositories
smart_proxy_helper.repositories_available_to_capsule(environment, content_view).by_rpm_count
end
end

Expand Down
6 changes: 2 additions & 4 deletions app/lib/actions/pulp3/abstract_async_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,9 @@ def rescue_external_task(error)
def transform_task_response(response)
response = [] if response.nil?
response = [response] unless response.is_a?(Array)
response = response.map do |task|
response.map do |task|
task.as_json
end
response
end

def check_for_errors
Expand Down Expand Up @@ -166,8 +165,7 @@ def poll_external_task
def get_task_label(name, href)
name = name.split('.').last if name
href = href.split('-').last[0...-1] if href
label = "%s (ID: %s)" % [name, href]
label
"%s (ID: %s)" % [name, href]
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions app/lib/actions/pulp3/capsule_content/verify_checksum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ def repos_to_repair(smart_proxy, environment, content_view, repository)
if repository
[repository]
else
repositories = smart_proxy_helper.repositories_available_to_capsule(environment, content_view).by_rpm_count
repositories
smart_proxy_helper.repositories_available_to_capsule(environment, content_view).by_rpm_count
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/lib/katello/lazy_accessor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def lazy_attributes_options(attr)
def lazy_accessor(*args)
options = args.extract_options!
@lazy_attributes = [] if @lazy_attributes.nil?
@lazy_attributes = @lazy_attributes.concat args
@lazy_attributes.concat args
@lazy_attributes_options ||= {}
fail ArgumentError, "Attribute names must be symbols" if args.any? { |attribute| !attribute.is_a?(Symbol) }
redefined_attr = args.find { |attribute| instance_methods.include?(attribute.to_s) }
Expand Down
3 changes: 1 addition & 2 deletions app/lib/katello/resources/candlepin/pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ def get_for_owner(owner_key, include_temporary_guests = false)
end

def create(owner_key, attrs)
pool = self.post("/candlepin/owners/#{owner_key}/pools", attrs.to_json, self.default_headers).body
pool
self.post("/candlepin/owners/#{owner_key}/pools", attrs.to_json, self.default_headers).body
end

def find(pool_id)
Expand Down
3 changes: 1 addition & 2 deletions app/lib/katello/util/cdn_var_substitutor.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module Katello
module Util
class CdnVarSubstitutor
attr_reader :good_listings
attr_reader :bad_listings
attr_reader :good_listings, :bad_listings

# cdn_resource - an object providing access to CDN. It has to
# provide a get method that takes a path (e.g.
Expand Down
2 changes: 1 addition & 1 deletion app/lib/katello/util/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def self.valid_package_name_format(package)
end

def self.valid_package_characters
/[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-\.\_\+\,]+/
/[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-._+,]+/
end

def self.setup_shared_unique_filter(repoids, search_mode, search_results)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def validate_each(record, attribute, value)
end

def self.validate_name(name)
if name.empty? || name.length > 255 || !/\A([a-z0-9]+[a-z0-9\-\_\.]*)+(\/[a-z0-9]+[a-z0-9\-\_\.]*)*\z/.match?(name)
if name.empty? || name.length > 255 || !/\A([a-z0-9]+[a-z0-9\-_.]*)+(\/[a-z0-9]+[a-z0-9\-_.]*)*\z/.match?(name)
return false
end
true
Expand Down
3 changes: 1 addition & 2 deletions app/models/katello/authorization/host_tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ module Authorization::HostTracer

module ClassMethods
def resolvable
relation = joins_authorized(::Host::Managed, :edit_hosts)
relation
joins_authorized(::Host::Managed, :edit_hosts)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/katello/candlepin/repository_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def name
sorted_substitutions = substitutions.sort_by { |k, _| k.to_s }.map(&:last)
repo_name_parts = [content.name,
sorted_substitutions].flatten.compact
repo_name_parts.join(" ").gsub(/[^a-z0-9\-\._ ]/i, "")
repo_name_parts.join(" ").gsub(/[^a-z0-9\-._ ]/i, "")
end

def path
Expand Down
2 changes: 1 addition & 1 deletion app/models/katello/concerns/host_managed_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def yum_names_for_job_template(action:, search:, versions: nil)
versions_by_name_arch = {}
if versions.present?
JSON.parse(versions).each do |nvra|
nvra =~ /([^\.]*)-[-\.\w]*\.(\w+)/
nvra =~ /([^.]*)-[-.\w]*\.(\w+)/
versions_by_name_arch[[Regexp.last_match(1), Regexp.last_match(2)]] = nvra
end
end
Expand Down
3 changes: 1 addition & 2 deletions app/models/katello/concerns/smart_proxy_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ module SmartProxyExtensions

module Overrides
def refresh
errors = super
errors
super
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/katello/erratum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def self.backend_identifier_field
end

def self.applicable_to_hosts(hosts)
# Note: ContentFacetErrata actually holds the "Applicable Errata" to that host
# NOTE: ContentFacetErrata actually holds the "Applicable Errata" to that host
# It is not the errata "belonging" to the host. Its rather the errata that is "applicable"
# which is calculated elsewhere.

Expand Down
2 changes: 1 addition & 1 deletion app/models/katello/event.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Katello
class Event < Katello::Model
validate :validate_event_type
# Note: Do not use active record call backs or dependent references on this class
# NOTE: Do not use active record call backs or dependent references on this class
# Direct deletes are made in EventQueue#clear_events (instead of destroys).

serialize :metadata, Hash
Expand Down
3 changes: 1 addition & 2 deletions app/models/katello/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,12 @@ def serializable_hash(options = {})
options = {} if options.nil?

hash = super(options.merge(:except => [:cp_id, :id]))
hash = hash.merge(:multiplier => self.multiplier,
hash.merge(:multiplier => self.multiplier,
:attributes => self.attrs,
:id => self.cp_id,
:sync_plan_name => self.sync_plan ? self.sync_plan.name : nil,
:sync_state => self.sync_state,
:last_sync => self.last_sync)
hash
end

def redhat?
Expand Down
3 changes: 1 addition & 2 deletions app/models/katello/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ def anonymous_provider?
def serializable_hash(options = {})
options = {} if options.nil?
hash = super(options)
hash = hash.merge(:sync_state => self.sync_state,
hash.merge(:sync_state => self.sync_state,
:last_sync => self.last_sync)
hash
end

def manifest_task
Expand Down
4 changes: 2 additions & 2 deletions app/models/katello/rpm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def self.scoped_search_sortable(column, operator, value)
# https://github.com/wvanbergen/scoped_search/blob/master/lib/scoped_search/query_builder.rb
if ['LIKE', 'NOT LIKE'].include?(operator)
conditions = "#{self.table_name}.#{column} #{operator} ?"
parameter = (value !~ /^\%|\*/ && value !~ /\%|\*$/) ? "%#{value}%" : value.tr_s('%*', '%')
parameter = (value !~ /^%|\*/ && value !~ /%|\*$/) ? "%#{value}%" : value.tr_s('%*', '%')
return { :conditions => conditions, :parameter => [parameter] }
elsif ['IN', 'NOT IN'].include?(operator)
conditions = "#{self.table_name}.#{column} #{operator} (#{value.split(',').collect { '?' }.join(',')})"
Expand Down Expand Up @@ -124,7 +124,7 @@ def self.scoped_search_evr_in(operator, value)
end

def self.scoped_search_evr_like(operator, value)
val = (value !~ /^\%|\*/ && value !~ /\%|\*$/) ? "%#{value}%" : value.tr_s('%*', '%')
val = (value !~ /^%|\*/ && value !~ /%|\*$/) ? "%#{value}%" : value.tr_s('%*', '%')
evr = Util::Package.parse_evr(val)
(e, v, r) = [evr[:epoch], evr[:version], evr[:release]]
conditions = []
Expand Down
2 changes: 1 addition & 1 deletion app/models/katello/subscription_facet_pool.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Katello
class SubscriptionFacetPool < Katello::Model
# Note: Do not use active record call backs or dependent references on this class
# NOTE: Do not use active record call backs or dependent references on this class
# Direct deletes are made in Pool#import_hosts (instead of destroys).
belongs_to :subscription_facet, :inverse_of => :subscription_facet_pools, :class_name => 'Katello::Host::SubscriptionFacet'
belongs_to :pool, :inverse_of => :subscription_facet_pools, :class_name => 'Katello::Pool'
Expand Down
4 changes: 1 addition & 3 deletions app/services/katello/pulp3/alternate_content_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ module Katello
module Pulp3
class AlternateContentSource
include Katello::Pulp3::ServiceCommon
attr_accessor :acs
attr_accessor :smart_proxy
attr_accessor :repository
attr_accessor :acs, :smart_proxy, :repository

def initialize(acs, smart_proxy, repository = nil)
@acs = acs
Expand Down
2 changes: 1 addition & 1 deletion app/services/katello/pulp3/api/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def self.fetch_from_list
(response.count && (page_opts['offset'] < response.count)) ||
page_opts["offset"] == 0)
response = yield page_opts
results = results.concat(response.results)
results.concat(response.results)
page_opts[:offset] += page_size
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ def find_unique_name(metadata_product)
end

def update_params(metadata_product)
params = {
{
gpg_key_id: gpg_key_id(metadata_product),
description: metadata_product.description
}

params
end

def gpg_key_id(metadata_product)
Expand Down
3 changes: 1 addition & 2 deletions app/services/katello/pulp3/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ module Pulp3
class Repository
include Katello::Util::HttpProxy
include Katello::Pulp3::ServiceCommon
attr_accessor :repo
attr_accessor :smart_proxy
attr_accessor :repo, :smart_proxy

delegate :root, to: :repo
delegate :pulp3_api, to: :smart_proxy
Expand Down
2 changes: 1 addition & 1 deletion config/routes/api/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ class ActionDispatch::Routing::Mapper
api_resources :packages, :only => [:index, :show]
api_resources :package_groups, :only => [:index, :show]
api_resources :files, :only => [:index, :show], :controller => 'file_units'
api_resources :errata, :only => [:index, :show], :constraints => {:id => /[0-9a-zA-Z\-\+%_.:]+/}
api_resources :errata, :only => [:index, :show], :constraints => {:id => /[0-9a-zA-Z\-+%_.:]+/}
api_resources :docker_manifests, :only => [:index, :show]
api_resources :docker_manifest_lists, :only => [:index, :show]
api_resources :docker_tags, :only => [:index, :show]
Expand Down
10 changes: 5 additions & 5 deletions test/controllers/api/v2/environments_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def test_update
assert_equal new_name, @staging.name
assert_equal new_description, @staging.description
assert @staging.registry_unauthenticated_pull
# note: label is not editable; therefore, confirm that it is unchanged
# NOTE: label is not editable; therefore, confirm that it is unchanged
assert_equal original_label, @staging.label
end

Expand All @@ -172,7 +172,7 @@ def test_update_pattern_async

assert_response :success
assert_equal 'New Name', @staging.reload.name
# note: label is not editable; therefore, confirm that it is unchanged
# NOTE: label is not editable; therefore, confirm that it is unchanged
assert_equal original_label, @staging.label
end

Expand All @@ -192,7 +192,7 @@ def test_update_pattern_sync

assert_response :success
assert_equal 'New Name', @staging.reload.name
# note: label is not editable; therefore, confirm that it is unchanged
# NOTE: label is not editable; therefore, confirm that it is unchanged
assert_equal original_label, @staging.label
end

Expand All @@ -211,7 +211,7 @@ def test_update_pull_async

assert_response :success
assert_equal 'New Name', @staging.reload.name
# note: label is not editable; therefore, confirm that it is unchanged
# NOTE: label is not editable; therefore, confirm that it is unchanged
assert_equal original_label, @staging.label
end

Expand All @@ -231,7 +231,7 @@ def test_update_pull_sync

assert_response :success
assert_equal 'New Name', @staging.reload.name
# note: label is not editable; therefore, confirm that it is unchanged
# NOTE: label is not editable; therefore, confirm that it is unchanged
assert_equal original_label, @staging.label
end

Expand Down
2 changes: 1 addition & 1 deletion test/models/katello/ostree_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class OstreeTest < ActiveSupport::TestCase

def setup
skip "TODO: Until the ostree support is present in pulp packaging"
# NOTE in order for these tests to work the 'ostree' fixture will have to be enabled in
# NOTE: in order for these tests to work the 'ostree' fixture will have to be enabled in
# test/fixtures/models/katello_smart_proxy_features.yml
# capabilities:
# - ostree
Expand Down
Loading