Skip to content

Commit

Permalink
Fixes #19775 - Fix Layout/ExtraSpacing cop
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoll authored and tbrisker committed Jun 14, 2018
1 parent b697e51 commit 630061d
Show file tree
Hide file tree
Showing 42 changed files with 54 additions and 60 deletions.
6 changes: 0 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ Layout/CaseIndentation:
Layout/ClosingParenthesisIndentation:
Enabled: false

# Offense count: 55
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
Layout/ExtraSpacing:
Enabled: false

# Offense count: 30
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2/hostgroups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def show
param :domain_id, :number, :desc => N_('Domain ID')
param :realm_id, :number, :desc => N_('Realm ID')
param :config_group_ids, Array, :desc => N_("IDs of associated config groups")
param :group_parameters_attributes, Array, :required => false, :desc => N_("Array of parameters") do
param :group_parameters_attributes, Array, :required => false, :desc => N_("Array of parameters") do
param :name, String, :desc => N_("Name of the parameter"), :required => true
param :value, String, :desc => N_("Parameter value"), :required => true
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2/operatingsystems_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class OperatingsystemsController < V2::BaseController
param :ptable_id, String, :desc => N_("ID of partition table")
param :config_template_id, String, :desc => N_("ID of template")
param :provisioning_template_id, String, :desc => N_("ID of template")
param :os_parameters_attributes, Array, :required => false, :desc => N_("Array of parameters") do
param :os_parameters_attributes, Array, :required => false, :desc => N_("Array of parameters") do
param :name, String, :desc => N_("Name of the parameter"), :required => true
param :value, String, :desc => N_("Parameter value"), :required => true
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2/trends_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def show
end

api :POST, "/trends/", N_("Create a trend counter")
param :trendable_type, String, :required => true
param :trendable_type, String, :required => true
param :fact_name, String, :required => false
param :name, String, :required => false
def create
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/hosts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def setBuild

def cancelBuild
if @host.built(false)
process_success :success_msg => _("Canceled pending build for %s") % @host.name, :success_redirect => :back
process_success :success_msg => _("Canceled pending build for %s") % @host.name, :success_redirect => :back
else
process_error :redirect => :back, :error_msg => _("Failed to cancel pending build for %{hostname} with the following errors: %{errors}") % {:hostname => @host.name, :errors => @host.errors.full_messages.join(', ')}
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def edit_inline(object, property, options = {})
update_url = options[:update_url] || url_for(object)
type = options[:type]
title = options[:title]
select_values = [true, false].include?(value) ? [_('Yes'), _('No')] : options[:select_values]
select_values = [true, false].include?(value) ? [_('Yes'), _('No')] : options[:select_values]

editable(object, property, {:type => type, :title => title, :value => value, :class => klass, :source => select_values, :url => update_url}.compact)
end
Expand Down Expand Up @@ -553,7 +553,7 @@ def notifications
end

def toast_notifiations_data
selected_toast_notifiations = flash.select { |key, _| key != 'inline' }
selected_toast_notifiations = flash.select { |key, _| key != 'inline' }

selected_toast_notifiations.map do |type, notification|
notification.is_a?(Hash) ? notification : { :type => type, :message => notification }
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/home_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def render_vertical_menu(menu_name, mobile = false)
authorized_menu_actions(Menu::Manager.items(menu_name).children).map do |menu|
items = authorized_menu_actions(menu.children)
render "home/vertical_menu", :menu_items => items, :menu_title => _(menu.caption), :menu_icon => menu.icon,
:menu_name => menu.name, :mobile_class => mobile ? 'visible-xs-block' : '' if items.any?
:menu_name => menu.name, :mobile_class => mobile ? 'visible-xs-block' : '' if items.any?
end.join(' ').html_safe
end

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/hosts_and_hostgroups_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def realm_field(f, can_override = false, override = false)
:disable_button_enabled => override && !explicit_value?(:realm_id),
:user_set => user_set?(:realm_id)
},
{ :help_inline => :indicator }
{ :help_inline => :indicator }
).html_safe
end

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/reports_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def reports_since(builder)
choices += (1..7).map{|i| OpenStruct.new :name => n_("%s day ago", "%s days ago", i) % i, :value => i.days.ago }
choices += (1..3).map{|i| OpenStruct.new :name => n_("%s week ago", "%s weeks ago", i) % i, :value => i.week.ago }
choices += (1..3).map{|i| OpenStruct.new :name => n_("%s month ago", "%s months ago", i) % i, :value => i.month.ago }
choices += [OpenStruct.new(:name => _("All Reports"), :value => Report.first(:select => "created_at").created_at)]
choices += [OpenStruct.new(:name => _("All Reports"), :value => Report.first(:select => "created_at").created_at)]
builder.collection_select :reported_at_gt, choices, :value, :name, {:include_blank => _("Select a period")}
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/compute_resources/foreman/model/libvirt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def console(uuid)
# Listen address cannot be updated while the guest is running
# When we update the display password, we pass the existing listen address
vm.update_display(:password => password, :listen => vm.display[:listen], :type => vm.display[:type])
WsProxy.start(:host => hypervisor.hostname, :host_port => vm.display[:port], :password => password).merge(:type => vm.display[:type], :name=> vm.name)
WsProxy.start(:host => hypervisor.hostname, :host_port => vm.display[:port], :password => password).merge(:type => vm.display[:type], :name=> vm.name)
rescue ::Libvirt::Error => e
if e.message =~ /cannot change listen address/
logger.warn e
Expand Down
2 changes: 1 addition & 1 deletion app/models/compute_resources/foreman/model/openstack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def tenant=(name)

def tenants
if url =~ /\/v3\/auth\/tokens/
user_id = identity_client.current_user_id
user_id = identity_client.current_user_id
identity_client.list_user_projects(user_id).body["projects"].map { |p| Fog::Identity::OpenStack::V3::Project.new(p) }
else
client.tenants
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/hostext/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ module Search
end

if SETTINGS[:login]
scoped_search :relation => :search_users, :on => :login, :complete_value => true, :only_explicit => true, :rename => :'user.login', :operators => ['= ', '~ '], :ext_method => :search_by_user, :aliases => [:owner]
scoped_search :relation => :search_users, :on => :login, :complete_value => true, :only_explicit => true, :rename => :'user.login', :operators => ['= ', '~ '], :ext_method => :search_by_user, :aliases => [:owner]
scoped_search :relation => :search_users, :on => :firstname, :complete_value => true, :only_explicit => true, :rename => :'user.firstname', :operators => ['= ', '~ '], :ext_method => :search_by_user
scoped_search :relation => :search_users, :on => :lastname, :complete_value => true, :only_explicit => true, :rename => :'user.lastname', :operators => ['= ', '~ '], :ext_method => :search_by_user
scoped_search :relation => :search_users, :on => :mail, :complete_value => true, :only_explicit => true, :rename => :'user.mail', :operators => ['= ', '~ '], :ext_method => :search_by_user
Expand Down Expand Up @@ -138,7 +138,7 @@ def search_by_puppetclass(key, operator, value)
def search_by_hostgroup_and_descendants(key, operator, value)
conditions = sanitize_sql_for_conditions(["hostgroups.title #{operator} ?", value_to_sql(operator, value)])
# Only one hostgroup (first) is used to determined descendants. Future TODO - alert if result results more than one hostgroup
hostgroup = Hostgroup.unscoped.with_taxonomy_scope.find_by(conditions)
hostgroup = Hostgroup.unscoped.with_taxonomy_scope.find_by(conditions)
if hostgroup.present?
hostgroup_ids = hostgroup.subtree_ids
opts = "hosts.hostgroup_id IN (#{hostgroup_ids.join(',')})"
Expand Down
2 changes: 1 addition & 1 deletion app/models/host/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Base < ApplicationRecord

alias_attribute :hostname, :name

validates :name, :presence => true, :uniqueness => true, :format => {:with => Net::Validations::HOST_REGEXP, :message => _(Net::Validations::HOST_REGEXP_ERR_MSG)}
validates :name, :presence => true, :uniqueness => true, :format => {:with => Net::Validations::HOST_REGEXP, :message => _(Net::Validations::HOST_REGEXP_ERR_MSG)}
validate :host_has_required_interfaces
validate :uniq_interfaces_identifiers
validate :build_managed_only
Expand Down
2 changes: 1 addition & 1 deletion app/models/nic/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def fqdn

def clone
# do not copy system specific attributes
self.deep_clone(:except => [:name, :mac, :ip, :ip6, :host_id])
self.deep_clone(:except => [:name, :mac, :ip, :ip6, :host_id])
end

# if this interface does not have MAC and is attached to other interface,
Expand Down
2 changes: 1 addition & 1 deletion app/models/setting/provisioning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def validate_safemode_render(record)

def self.default_global_templates
map_pxe_kind do |pxe_kind, templates|
self.set("global_#{pxe_kind}", N_("Global default %s template. This template gets deployed to all configured TFTP servers. It will not be affected by upgrades.") % pxe_kind, ProvisioningTemplate.global_default_name(pxe_kind), N_("Global default %s template") % pxe_kind, nil, { :collection => templates })
self.set("global_#{pxe_kind}", N_("Global default %s template. This template gets deployed to all configured TFTP servers. It will not be affected by upgrades.") % pxe_kind, ProvisioningTemplate.global_default_name(pxe_kind), N_("Global default %s template") % pxe_kind, nil, { :collection => templates })
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/trends/fact_trend.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class FactTrend < Trend
validates :trendable_id, :presence => true, :uniqueness => {:scope => [:trendable_type, :fact_value] }, :allow_blank => false
validates :trendable_id, :presence => true, :uniqueness => {:scope => [:trendable_type, :fact_value] }, :allow_blank => false

before_save :update_fact_name

Expand Down
4 changes: 2 additions & 2 deletions config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
require 'rack'

# load Rails environment
require ::File.expand_path('../config/environment', __FILE__)
require ::File.expand_path('../config/environment', __FILE__)

# apply a prefix to the application, if one is defined
# e.g. http://some.server.com/prefix where '/prefix' is defined by env variable
map ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do
map ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do
run Foreman::Application
end
4 changes: 2 additions & 2 deletions db/migrate/20180403144853_convert_vm_attrs_to_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def up
YML_PARAMS = /!ruby\/[\w-]+:ActionController::Parameters/

def transform_batch_columns(base, serialized_columns)
base.unscoped.select(serialized_columns + [:id]).find_each do |object|
base.unscoped.select(serialized_columns + [:id]).find_each do |object|
serialized_columns.each do |column|
attributes = object.send :read_attribute_before_type_cast, column
next if attributes.nil?
Expand Down Expand Up @@ -52,6 +52,6 @@ class FakeLookupValue < ApplicationRecord

class FakeLookupKey < ApplicationRecord
self.table_name = 'lookup_keys'
self.inheritance_column = nil
self.inheritance_column = nil
end
end
2 changes: 1 addition & 1 deletion lib/foreman/foreman_url_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def default_url_options
# returns the URL for Foreman based on the required action
def foreman_url(action = 'provision')
# Get basic stuff
config = URI.parse(Setting[:unattended_url])
config = URI.parse(Setting[:unattended_url])
url_options = foreman_url_options_from_settings_or_request(config)

host = @host
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/jenkins.rake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ begin
end
minitest_plugins = [:pre_ci, 'webpack:try_compile', 'ci:setup:minitest']
minitest_plugins << 'robottelo:setup:minitest' if ENV['GENERATE_ROBOTTELO_REPORT'] == 'true'
task :minitest => minitest_plugins
task :minitest => minitest_plugins
end

task :rubocop do
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/plugin_apipie.rake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ task 'plugin:apipie:cache', :engine do |t, args|
plugin = Foreman::Plugin.find(args[:engine])

Apipie.configuration.ignored = plugin.apipie_ignored_controllers || []
api_controllers = plugin.apipie_documented_controllers || ["#{@engine_root}/app/controllers/#{path_name}/api/*.rb"]
api_controllers = plugin.apipie_documented_controllers || ["#{@engine_root}/app/controllers/#{path_name}/api/*.rb"]
Apipie.configuration.api_controllers_matcher = api_controllers

Rake::Task['apipie:cache'].execute
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/puppet.rake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace :puppet do
namespace :import do
desc "
Update puppet environments and classes. Optional batch flag triggers run with no prompting\nUse proxy=<proxy name> to import from or get the first one by default"
task :puppet_classes, [:batch, :envname] => :environment do |t, args|
task :puppet_classes, [:batch, :envname] => :environment do |t, args|
User.as_anonymous_admin do
args.batch = args.batch == "true"
proxies = SmartProxy.with_features("Puppet")
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/reports.rake
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace :reports do
end
end

task :daily => :environment do
task :daily => :environment do
process_notifications :daily
end

Expand Down
2 changes: 1 addition & 1 deletion test/controllers/api/v2/auth_sources_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Api::V2::AuthSourcesControllerTest < ActionController::TestCase
assert_response :success
auth_sources = ActiveSupport::JSON.decode(@response.body)
refute_empty auth_sources
ids = auth_sources['results'].map { |hash| hash['id'] }
ids = auth_sources['results'].map { |hash| hash['id'] }
assert_includes ids, auth_sources(:internal).id
assert_includes ids, auth_sources(:external).id
assert_includes ids, auth_sources(:one).id
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/api/v2/interfaces_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Api::V2::InterfacesControllerTest < ActionController::TestCase
def setup
@host = FactoryBot.create(:host)
@nic = FactoryBot.create(:nic_managed, :host => @host)
@bond = FactoryBot.create(:nic_bond, :host => @host)
@bond = FactoryBot.create(:nic_bond, :host => @host)
end

test "get index for specific host" do
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/api/v2/locations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def setup

test "should create location with parent" do
parent_id = Location.first.id
post :create, params: { :location => { :name => "Test Location", :parent_id => parent_id } }
post :create, params: { :location => { :name => "Test Location", :parent_id => parent_id } }
assert_response :success
show_response = ActiveSupport::JSON.decode(@response.body)
assert !show_response.empty?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Api::V2::OperatingsystemsControllerTest < ActionController::TestCase
test "should create os with name and major version only" do
os_params = minimum_required_os_params
assert_difference('Operatingsystem.count') do
post :create, params: { :operatingsystem => os_params}
post :create, params: { :operatingsystem => os_params}
end
assert_response :created
response = JSON.parse(@response.body)
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/api/v2/organizations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class Api::V2::OrganizationsControllerTest < ActionController::TestCase

test "search organization" do
organization = Organization.first
get :index, params: { :search => "name = \"#{organization.name}\"", :format => 'json' }
get :index, params: { :search => "name = \"#{organization.name}\"", :format => 'json' }
assert_response :success, "search organization name: '#{organization.name}' failed with code: #{@response.code}"
response = JSON.parse(@response.body)
assert_equal response['results'].length, 1
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/api/v2/override_values_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ class Api::V2::OverrideValuesControllerTest < ActionController::TestCase
lookup_key = FactoryBot.create(:variable_lookup_key, :puppetclass => puppetclasses(:two))
refute lookup_key.override
assert_difference('LookupValue.count', 1) do
post :create, params: { :smart_variable_id => lookup_key.id, :override_value => { :match => 'os=string'} }
post :create, params: { :smart_variable_id => lookup_key.id, :override_value => { :match => 'os=string'} }
end
assert_response :success
end
Expand Down Expand Up @@ -381,7 +381,7 @@ class Api::V2::OverrideValuesControllerTest < ActionController::TestCase
test_attributes :pid => 'bef0e457-16be-4ca6-bc56-fa32dff55a01'
test "should not create invalid matcher for non existing attribute" do
assert_difference('LookupValue.count', 0) do
post :create, params: { :smart_class_parameter_id => lookup_keys(:one).id, :override_value => { :match => 'hostgroup=nonexistingHG', :value => RFauxFactory.gen_alpha } }
post :create, params: { :smart_class_parameter_id => lookup_keys(:one).id, :override_value => { :match => 'hostgroup=nonexistingHG', :value => RFauxFactory.gen_alpha } }
end
assert_includes JSON.parse(response.body)['error']['message'], 'Validation failed: Match hostgroup=nonexistingHG does not match an existing host group'
end
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/api/v2/ptables_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def setup

test_attributes :pid => '08520746-444b-47c9-a8a3-438170147453'
test "search ptable" do
get :index, params: { :search => @ptable.name, :format => 'json' }
get :index, params: { :search => @ptable.name, :format => 'json' }
assert_response :success, "search ptable name: '#{@ptable.name}' failed with code: #{@response.code}"
response = JSON.parse(@response.body)
assert_equal response['results'].length, 1
Expand All @@ -162,7 +162,7 @@ def setup
org = Organization.first
@ptable.organizations = [org]
assert @ptable.save
get :index, params: {:search => @ptable.name, :organization_id => org.id, :format => 'json' }
get :index, params: {:search => @ptable.name, :organization_id => org.id, :format => 'json' }
assert_response :success, "search ptable by name and organization failed with code: #{@response.code}"
response = JSON.parse(@response.body)
assert_equal response['results'].length, 1
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/api/v2/smart_proxies_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Api::V2::SmartProxiesControllerTest < ActionController::TestCase
put :update, params: { :id => smart_proxies(:one).to_param, :smart_proxy => valid_attrs }
assert_response :success
response = JSON.parse(@response.body)
refute_empty response.keys.select { |key| any_needed_fields.include?(key) }
refute_empty response.keys.select { |key| any_needed_fields.include?(key) }
end

test_attributes :pid => '42d6b749-c047-4fd2-90ee-ffab7be558f9'
Expand All @@ -98,7 +98,7 @@ class Api::V2::SmartProxiesControllerTest < ActionController::TestCase
put :update, params: { :id => smart_proxies(:one).to_param, :smart_proxy => valid_attrs }
assert_response :success
response = JSON.parse(@response.body)
refute_empty response.keys.select { |key| any_needed_fields.include?(key) }
refute_empty response.keys.select { |key| any_needed_fields.include?(key) }
end

test_attributes :pid => 'f279640e-d7e9-48a3-aed8-7bf406e9d6f2'
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/environments_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def setup_import_classes
post :obsolete_and_new, params:
{ "changed"=>
{"obsolete" =>
{"env1" => '["a","b","c","_destroy_"]'}
{"env1" => '["a","b","c","_destroy_"]'}
}
}, session: set_session_user
assert Environment.unscoped.find_by_name("env1").hosts.count > 0
Expand Down
Loading

0 comments on commit 630061d

Please sign in to comment.