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

Fixes #37425 - Fix Layout/ArgumentAlignment cop #10051

Merged
merged 1 commit into from
Oct 17, 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
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Layout/LineLength:
Layout/ParameterAlignment:
Enabled: false

Layout/ArgumentAlignment:
EnforcedStyle: with_fixed_indentation
IndentationWidth: 2

Metrics:
Enabled: false

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def check_media_type
def render_error(error, options = { })
options = set_error_details(error, options)
render options.merge(:template => "api/v2/errors/#{error}",
:layout => 'api/v2/layouts/error_layout')
:layout => 'api/v2/layouts/error_layout')
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def smart_proxy_exception(exception = nil)
process_error(:redirect => :back, :error_msg => exception.message)
else
process_error(:render => { :plain => exception.message },
:error_msg => exception.message)
:error_msg => exception.message)
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/compute_attributes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ComputeAttributesController < ApplicationController

def new
@set = ComputeAttribute.new(:compute_profile_id => params[:compute_profile_id].to_i,
:compute_resource_id => params[:compute_resource_id].to_i)
:compute_resource_id => params[:compute_resource_id].to_i)
end

def create
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/compute_resources_vms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def index
render :partial => "compute_resources_vms/index/#{@compute_resource.provider.downcase}.json"
else
render :json => _('JSON VM listing is not supported for this compute resource.'),
:status => :not_implemented
:status => :not_implemented
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def external_usergroups_error(group, exception)
group.errors.add(
:base,
_("Could not refresh external usergroups: %{e} - %{message} - %{suggestion}") %
{ :e => exception.class,
:message => exception.to_s,
:suggestion => suggestion_external_group(exception) }
{ :e => exception.class,
:message => exception.to_s,
:suggestion => suggestion_external_group(exception) }
)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def default_template_url(template, hostgroup)
protocol = uri.scheme

url_for(:only_path => false, :action => :hostgroup_template, :controller => '/unattended',
:id => template.name, :hostgroup => hostgroup.title, :protocol => protocol,
:host => host, :port => port)
:id => template.name, :hostgroup => hostgroup.title, :protocol => protocol,
:host => host, :port => port)
end

# convert the file upload into a simple string to save in our db.
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/key_pairs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def show
def create
if @compute_resource.recreate
process_success :success_msg => _('Successfully recreated'),
:success_redirect => compute_resource_path(@compute_resource)
:success_redirect => compute_resource_path(@compute_resource)
else
process_error :error_msg => _('Could not recreate a new SSH key')
end
Expand All @@ -29,7 +29,7 @@ def destroy
return not_found unless key_to_delete
if @compute_resource.delete_key_from_resource(key_to_delete)
process_success :success_msg => _('Successfully delete %s') % key_to_delete,
:success_redirect => compute_resource_path(@compute_resource)
:success_redirect => compute_resource_path(@compute_resource)
else
process_error :error_msg => _('Could not delete %s') % key_to_delete
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/notification_recipients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def destroy_group
count = NotificationRecipient.
joins(:notification_blueprint).
where(user_id: User.current.id,
notification_blueprints: { group: params[:group]}).
notification_blueprints: { group: params[:group]}).
delete_all

logger.debug("deleted #{count} notification recipents for group #{params[:group]}")
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ def load_history
return unless @template
@history = Audit.descending
.where(:auditable_id => @template.id,
:auditable_type => @template.class.base_class.name,
:action => %w(update create))
:auditable_type => @template.class.base_class.name,
:action => %w(update create))
.select { |audit| audit_template? audit }
end

Expand Down
2 changes: 1 addition & 1 deletion app/graphql/resolvers/concerns/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def filter_list(search: nil, sort_by: nil, sort_direction: 'ASC',

if has_taxonomix?
taxonomy_ids = taxonomy_ids_for_filter(location_id: location_id, organization_id: organization_id,
location: location, organization: organization)
location: location, organization: organization)
filters << taxonomy_id_filter(taxonomy_ids) if taxonomy_ids.any?
end

Expand Down
10 changes: 5 additions & 5 deletions app/helpers/common_parameters_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ def hidden_value_field(f, field, disabled, options = {})
html_class += " masked-input" if hidden

input = f.text_area(field, options.merge(:disabled => disabled,
:class => html_class,
:rows => 1,
:id => dom_id(f.object) + '_value',
:placeholder => _("Value"),
:value => f.object.value_before_type_cast))
:class => html_class,
:rows => 1,
:id => dom_id(f.object) + '_value',
:placeholder => _("Value"),
:value => f.object.value_before_type_cast))

input_group(input, input_group_btn(hidden_toggle(f.object.hidden_value?), fullscreen_button("$(this).closest('.input-group').find('input,textarea')")))
end
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/layout_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ def collapsing_header(title, target, collapsed = '')
def base_errors_for(obj)
if obj.errors[:base].present?
alert :header => _("Unable to save"),
:class => 'alert-danger base in fade',
:text => obj.errors[:base].map { |e| '<li>'.html_safe + e + '</li>'.html_safe }.join.html_safe
:class => 'alert-danger base in fade',
:text => obj.errors[:base].map { |e| '<li>'.html_safe + e + '</li>'.html_safe }.join.html_safe
end
end

Expand Down Expand Up @@ -249,7 +249,7 @@ def new_child_fields_template(form_builder, association, options = { })
content_tag(:div, :class => "#{association}_fields_template form_template", :style => "display: none;") do
form_builder.fields_for(association, options[:object], :child_index => "new_#{association}") do |f|
render(:partial => options[:partial], :layout => options[:layout],
:locals => { options[:form_builder_local] => f }.merge(options[:form_builder_attrs]))
:locals => { options[:form_builder_local] => f }.merge(options[:form_builder_attrs]))
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions app/helpers/provisioning_templates_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ def building_hosts_path(template)

def how_templates_are_determined
alert(:class => 'alert-info', :header => _('How templates are determined'),
:text => ('<p>' + _("When editing a template, you must assign a list \
:text => ('<p>' + _("When editing a template, you must assign a list \
of operating systems which this template can be used with. Optionally, you can \
restrict a template to a list of host groups.") + '</p>' +
'<p>' + _("When a Host requests a template (e.g. during provisioning), Foreman \
will select the best match from the available templates of that type, in the \
following order:") + '</p>' + '<ul>' +
'<li>' + _("Host group") + '</li>' +
'<li>' + _("Operating system default") + '</li>' +
'</ul>' +
(_("The final entry, Operating System default, can be set by editing the %s page.") %
(link_to _("Operating System"), operatingsystems_path))).html_safe)
'<li>' + _("Host group") + '</li>' +
'<li>' + _("Operating system default") + '</li>' +
'</ul>' +
(_("The final entry, Operating System default, can be set by editing the %s page.") %
(link_to _("Operating System"), operatingsystems_path))).html_safe)
end
end
2 changes: 1 addition & 1 deletion app/helpers/templates_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module TemplatesHelper
def snippet_message(template)
return unless template.snippet
alert(:class => 'alert-info', :header => '',
:text => _("Not relevant for snippet"))
:text => _("Not relevant for snippet"))
end

def default_template_description
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class ApplicationMailer < ActionMailer::Base
include Roadie::Rails::Automatic
default :delivery_method => proc { Setting[:delivery_method] },
:from => proc { Setting[:email_reply_address] || "[email protected]" }
:from => proc { Setting[:email_reply_address] || "[email protected]" }
after_action :set_delivery_options

def self.delivery_settings
Expand Down
36 changes: 18 additions & 18 deletions app/models/concerns/orchestration/compute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,38 +61,38 @@ def queue_compute

def queue_compute_create
if find_image.try(:user_data)
queue.create(:name => _("Render user data template for %s") % self, :priority => 2,
:action => [self, :setUserData])
queue.create(:name => _("Render user data template for %s") % self, :priority => 2,
:action => [self, :setUserData])
end
queue.create(:name => _("Set up compute instance %s") % self, :priority => 3,
:action => [self, :setCompute])
queue.create(:name => _("Set up compute instance %s") % self, :priority => 3,
:action => [self, :setCompute])
if compute_provides?(:ip) || compute_provides?(:ip6)
queue.create(:name => _("Acquire IP addresses for %s") % self, :priority => 4,
:action => [self, :setComputeIP])
queue.create(:name => _("Acquire IP addresses for %s") % self, :priority => 4,
:action => [self, :setComputeIP])
end
queue.create(:name => _("Query instance details for %s") % self, :priority => 5,
:action => [self, :setComputeDetails])
queue.create(:name => _("Query instance details for %s") % self, :priority => 5,
:action => [self, :setComputeDetails])
if compute_provides?(:mac) && (mac_based_ipam?(:subnet) || mac_based_ipam?(:subnet6))
queue.create(:name => _("Set IP addresses for %s") % self, :priority => 6,
:action => [self, :setComputeIPAM])
:action => [self, :setComputeIPAM])
end
if compute_attributes && compute_attributes[:start] == '1'
queue.create(:name => _("Power up compute instance %s") % self, :priority => 1000,
:action => [self, :setComputePowerUp])
:action => [self, :setComputePowerUp])
end
end

def queue_compute_update
return unless compute_update_required?
logger.debug("Detected a change is required for compute resource")
queue.create(:name => _("Compute resource update for %s") % old, :priority => 7,
:action => [self, :setComputeUpdate])
queue.create(:name => _("Compute resource update for %s") % old, :priority => 7,
:action => [self, :setComputeUpdate])
end

def queue_compute_destroy
return unless errors.empty? && compute_resource_id.present? && uuid
queue.create(:name => _("Removing compute instance %s") % self, :priority => 100,
:action => [self, :delCompute])
queue.create(:name => _("Removing compute instance %s") % self, :priority => 100,
:action => [self, :delCompute])
end

def setCompute
Expand Down Expand Up @@ -125,10 +125,10 @@ def setUserData
# actually used. For now, use foreman_url('built') in the template
if template.nil?
failure((_("%{image} needs user data, but %{os_link} is not associated to any provisioning template of the kind user_data. Please associate it with a suitable template or uncheck 'User data' for %{compute_resource_image_link}.") %
{ :image => image.name,
:os_link => "<a target='_blank' rel='noopener noreferrer' href='#{edit_operatingsystem_path(operatingsystem)}'>#{operatingsystem.title}</a>",
:compute_resource_image_link =>
"<a target='_blank' rel='noopener noreferrer' href='#{edit_compute_resource_image_path(:compute_resource_id => compute_resource.id, :id => image.id)}'>#{image.name}</a>"}).html_safe)
{ :image => image.name,
:os_link => "<a target='_blank' rel='noopener noreferrer' href='#{edit_operatingsystem_path(operatingsystem)}'>#{operatingsystem.title}</a>",
:compute_resource_image_link =>
"<a target='_blank' rel='noopener noreferrer' href='#{edit_compute_resource_image_path(:compute_resource_id => compute_resource.id, :id => image.id)}'>#{image.name}</a>"}).html_safe)
return false
end

Expand Down
8 changes: 4 additions & 4 deletions app/models/concerns/orchestration/dns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def queue_dns_create
DNSInterface::RECORD_TYPES.each do |record_type|
if dns_feasible?(record_type)
queue.create(:name => _("Create %{type} for %{host}") % {:host => self, :type => dns_class(record_type).human}, :priority => 10,
:action => [self, :set_dns_record, record_type])
:action => [self, :set_dns_record, record_type])
end
end
end
Expand All @@ -75,7 +75,7 @@ def queue_dns_update
DNSInterface::RECORD_TYPES.each do |record_type|
if old.dns_feasible?(record_type)
queue.create(:name => _("Remove %{type} for %{host}") % {:host => old, :type => dns_class(record_type).human }, :priority => 9,
:action => [old, :del_dns_record, record_type])
:action => [old, :del_dns_record, record_type])
end
end
queue_dns_create
Expand All @@ -86,7 +86,7 @@ def queue_dns_destroy
DNSInterface::RECORD_TYPES.each do |record_type|
if dns_feasible?(record_type)
queue.create(:name => _("Remove %{type} for %{host}") % {:host => self, :type => dns_class(record_type).human}, :priority => 1,
:action => [self, :del_dns_record, record_type])
:action => [self, :del_dns_record, record_type])
end
end
end
Expand All @@ -98,7 +98,7 @@ def queue_remove_dns_conflicts
DNSInterface::RECORD_TYPES.each do |record_type|
if dns_feasible?(record_type) && dns_record(record_type) && dns_record(record_type).conflicting?
queue.create(:name => _("Remove conflicting %{type} for %{host}") % {:host => self, :type => dns_class(record_type).human}, :priority => 0,
:action => [self, :del_conflicting_dns_record, record_type])
:action => [self, :del_conflicting_dns_record, record_type])
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions app/models/concerns/orchestration/puppet_ca.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ def queue_puppetca

def queue_puppetca_certname_reset
post_queue.create(:name => _("Reset PuppetCA certname for %s") % self, :priority => 49,
:action => [self, :resetCertname])
:action => [self, :resetCertname])
end

def queue_puppetca_create
post_queue.create(:name => _("Cleanup PuppetCA certificates for %s") % self, :priority => 51,
:action => [self, :delCertificate])
:action => [self, :delCertificate])
post_queue.create(:name => _("Enable PuppetCA autosigning for %s") % self, :priority => 55,
:action => [self, :setAutosign])
:action => [self, :setAutosign])
end

def queue_puppetca_update
Expand All @@ -97,13 +97,13 @@ def queue_puppetca_destroy
return unless puppetca? && errors.empty?
return unless Setting[:manage_puppetca]
post_queue.create(:name => _("Delete PuppetCA certificates for %s") % self, :priority => 59,
:action => [self, :delCertificate])
:action => [self, :delCertificate])
queue_puppetca_autosign_destroy
true
end

def queue_puppetca_autosign_destroy
post_queue.create(:name => _("Disable PuppetCA autosigning for %s") % self, :priority => 50,
:action => [self, :delAutosign])
:action => [self, :delAutosign])
end
end
6 changes: 3 additions & 3 deletions app/models/concerns/orchestration/realm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ def queue_realm

def queue_realm_create
queue.create(:name => _("Create realm entry for %s") % self, :priority => 1,
:action => [self, :set_realm])
:action => [self, :set_realm])
end

def queue_realm_update
# Update if the hostgroup is changed or if the realm is changed
if hostgroup_id_changed? || realm_id_changed?
queue.create(:name => _("Update realm entry for %s") % self, :priority => 1,
:action => [self, :update_realm])
:action => [self, :update_realm])
end
end

def queue_realm_destroy
return unless realm? && errors.empty?
queue.create(:name => _("Delete realm entry for %s") % self, :priority => 50,
:action => [self, :del_realm])
:action => [self, :del_realm])
end
end
6 changes: 3 additions & 3 deletions app/models/concerns/orchestration/ssh_provision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ def queue_ssh_provision
# I guess this is not going to happen on create as we might not have an ip address yet.
def queue_ssh_provision_create
post_queue.create(:name => _("Prepare post installation script for %s") % self, :priority => 2000,
:action => [self, :setSSHProvisionScript])
:action => [self, :setSSHProvisionScript])
post_queue.create(:name => _("Wait for %s to come online") % self, :priority => 2001,
:action => [self, :setSSHWaitForResponse])
:action => [self, :setSSHWaitForResponse])
post_queue.create(:name => _("Configure instance %s via SSH") % self, :priority => 2003,
:action => [self, :setSSHProvision])
:action => [self, :setSSHProvision])
end

def queue_ssh_provision_update
Expand Down
8 changes: 4 additions & 4 deletions app/models/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ def same_resource_type_permissions
errors.add(
:permissions,
_('must be of same resource type (%{types}) - Role (%{role})') %
{
types: types.join(','),
role: role.name,
}
{
types: types.join(','),
role: role.name,
}
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/host/managed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def handle_realm
def disk_layout_source
@disk_layout_source ||= if disk.present?
Foreman::Renderer::Source::String.new(name: 'Custom disk layout',
content: disk.tr("\r", ''))
content: disk.tr("\r", ''))
elsif ptable.present?
Foreman::Renderer::Source::Database.new(ptable)
end
Expand Down
Loading
Loading