Skip to content

Commit

Permalink
Fixes #37281 - Add erb linting
Browse files Browse the repository at this point in the history
  • Loading branch information
dosas committed Mar 20, 2024
1 parent 6c77d09 commit 5918f55
Show file tree
Hide file tree
Showing 145 changed files with 325 additions and 329 deletions.
39 changes: 39 additions & 0 deletions .erb-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
linters:
AllowedScriptType:
enabled: false
ClosingErbTagIndent:
enabled: true
CommentSyntax:
enabled: true
ExtraNewline:
enabled: true
FinalNewline:
enabled: true
NoJavascriptTagHelper:
enabled: false
ParserErrors:
enabled: true
PartialInstanceVariable:
enabled: false
RequireInputAutocomplete:
enabled: false
RightTrim:
enabled: true
SelfClosingTag:
enabled: true
SpaceAroundErbTag:
enabled: true
SpaceIndentation:
enabled: false
SpaceInHtmlTag:
enabled: true
TrailingWhitespace:
enabled: true
DeprecatedClasses:
enabled: false
ErbSafety:
enabled: false
Rubocop:
enabled: false
RequireScriptNonce:
enabled: false
16 changes: 16 additions & 0 deletions .github/workflows/foreman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ jobs:
- name: Run rubocop
run: bundle exec rubocop -P

rubocop:
name: erb lint
needs: setup_matrix
runs-on: ubuntu-latest
env:
BUNDLE_WITHOUT: assets:console:development:dynflow_sidekiq:ec2:journald:jsonp:libvirt:openid:openstack:ovirt:redis:service:telemetry:vmware
steps:
- uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ fromJson(needs.setup_matrix.outputs.matrix).ruby[0] }}
bundler-cache: true
- name: lint erb files
run: bundle exec erblint --lint-all

tests:
name: "${{ matrix.task }} - Ruby ${{ matrix.ruby }} and Node ${{ matrix.node }} on PostgreSQL ${{ matrix.postgresql }}"
runs-on: ubuntu-latest
Expand Down
14 changes: 7 additions & 7 deletions app/views/about/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="col-md-7">

<div class="stats-well">
<h4><%=_("System Status")%></h4>
<h4><%= _("System Status") %></h4>
<ul class="nav nav-tabs" data-tabs="tabs">
<li class="active"><a href="#smart_proxies" data-toggle="tab"><%= _('Smart Proxies') %></a></li>
<li><a href="#available_providers" data-toggle="tab"><%= _('Available Providers') %></a></li>
Expand All @@ -28,9 +28,9 @@
</thead>
<tbody>
<% @smart_proxies.each do |proxy| %>
<tr class="proxy-show" data-url="<%= ping_smart_proxy_path(proxy) %>">
<tr class="proxy-show" data-url="<%= ping_smart_proxy_path(proxy) %>">
<td><%= link_to_if_authorized proxy.name, hash_for_smart_proxy_path(proxy) %></td>
<td><%=h proxy.features.map(&:name).to_sentence %></td>
<td><%= h proxy.features.map(&:name).to_sentence %></td>
<td><div class="proxy-show-status"><%= spinner %></div></td>
<td><div class="proxy-version"><%= spinner %></div></td>
</tr>
Expand Down Expand Up @@ -79,7 +79,7 @@
<tr>
<td class="ellipsis"><%= link_to(compute.name, compute) %></td>
<td><%= compute.provider_friendly_name %></td>
<td><div class="compute-status" data-url=<%= ping_compute_resource_path(compute) %>><%= spinner %></div></td>
<td><div class="compute-status" data-url="<%= ping_compute_resource_path(compute) %>"><%= spinner %></div></td>
</tr>
<% end %>
</tbody>
Expand All @@ -102,9 +102,9 @@
<tbody>
<% @plugins.each do |plugin| %>
<tr>
<td><%= plugin.url.blank? ? plugin.name : link_to(plugin.name, plugin.url, :rel=>'external')%></td>
<td><%= plugin.url.blank? ? plugin.name : link_to(plugin.name, plugin.url, :rel=>'external') %></td>
<td class="ellipsis"><%= _(plugin.description) %></td>
<td class="ellipsis"><%= plugin.author_url.blank? ? plugin.author : link_to(plugin.author, plugin.author_url)%></td>
<td class="ellipsis"><%= plugin.author_url.blank? ? plugin.author : link_to(plugin.author, plugin.author_url) %></td>
<td><%= plugin.version %></td>
</tr>
<% end %>
Expand All @@ -126,7 +126,7 @@
<li><%= link_to _('Wiki'), external_link_path(type: 'wiki'), :rel => "external" %></li>
</ul>
<h6><%= _("IRC") %></h6>
<p><%= (_("You can find The Foreman on the %{liberachat} (irc.libera.chat) network. For general support, please visit #theforeman and for development specific related chat, please visit #theforeman-dev.") % {:liberachat => link_to("Libera.Chat", external_link_path(type: 'chat'), :rel => "external")}).html_safe %></p>
<p><%= (_("You can find The Foreman on the %{liberachat} (irc.libera.chat) network. For general support, please visit #theforeman and for development specific related chat, please visit #theforeman-dev.") % {:liberachat => link_to("Libera.Chat", external_link_path(type: 'chat'), :rel => "external")}).html_safe %></p>
<h6><%= _("Forums") %></h6>
<p><%= (_("You can use the %{community_forums} to ask for help or advice, participate in discussions around challenges or ideas you have with Foreman.") % {:community_forums => link_to( _('community forums'), external_link_path(type: 'forums'), :rel => "external")}).html_safe %></p>
<h6><%= _("Issue tracker") %></h6>
Expand Down
1 change: 0 additions & 1 deletion app/views/apipie_dsl/apipie_dsls/help.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<li><%= _('Remote execution job templates') %></li>
</ul>


<p><%= _('When the system asks for evaluated template, the code in the ERB tags is executed and the variables are replaced with their current values. This process is referred to as rendering. Typically rendering occurs during provisioning, when Kickstart file is asked by Anaconda or partition table is about to be deployed. Rendering also happens when a Remote Execution job is triggered to render the script to be executed. While the ERB exposes the power of programming language executed on the application server, the rendering mechanism has the safemode rendering option enabled by default, which prevents any harmful code being executed from templates.') %></p>
<p><%= _('Each template type rendering capabilities slightly differ, e.g. a provisioning template is always rendered for a single host object and therefore a @host variable is defined. Another example is a report template, where report formatting specific macros are available.') %></p>

Expand Down
2 changes: 1 addition & 1 deletion app/views/audit_mailer/summary.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<b>
<%= link_to(audit.username, audits_url(:search => user_search_param)) %>
<span style="color: #cccccc"><%= audit_remote_address audit %></span>
<%= audit_action_name audit%> <%= audited_type audit %>:
<%= audit_action_name audit %> <%= audited_type audit %>:
<%= link_to(audit_title(audit), audits_url(search: "id = #{audit.id}"), {:style => 'color: #2a6496'}) %>
</b>
<ul style="list-style-type: none;">
Expand Down
3 changes: 1 addition & 2 deletions app/views/auth_source_externals/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
}
],
switchable: false,
)
%>
) %>
<% title _("Edit External Authentication Source") %>
<%= render :partial => 'form' %>
8 changes: 4 additions & 4 deletions app/views/auth_source_ldaps/_ldap_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<tbody>
<% auth_source_ldaps.each do |auth_source_ldap| %>
<tr>
<td class=""><%=link_to_if_authorized trunc_with_tooltip(auth_source_ldap.name), hash_for_edit_auth_source_ldap_path(:id => auth_source_ldap) %></td>
<td><%=h auth_source_ldap.host %></td>
<td><%=checked_icon auth_source_ldap.onthefly_register %></td>
<td><%=checked_icon auth_source_ldap.tls %></td>
<td class=""><%= link_to_if_authorized trunc_with_tooltip(auth_source_ldap.name), hash_for_edit_auth_source_ldap_path(:id => auth_source_ldap) %></td>
<td><%= h auth_source_ldap.host %></td>
<td><%= checked_icon auth_source_ldap.onthefly_register %></td>
<td><%= checked_icon auth_source_ldap.tls %></td>
<td class='col-md-1'><%= action_buttons display_delete_if_authorized hash_for_auth_source_ldap_path(:id => auth_source_ldap), :data => { :confirm => _("Delete %s?") % auth_source_ldap.name } %></td>
</tr>
<% end %>
Expand Down
3 changes: 1 addition & 2 deletions app/views/auth_source_ldaps/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
}
],
switchable: false,
)
%>
) %>
<% title _("Edit %s") % @auth_source_ldap.to_label %>
<%= render :partial => 'form' %>
3 changes: 1 addition & 2 deletions app/views/auth_source_ldaps/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
}
],
switchable: false,
)
%>
) %>
<% title _("Create LDAP Auth Source") %>
<%= render :partial => 'form' %>
2 changes: 1 addition & 1 deletion app/views/auth_sources/_welcome.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<% content_for(:title, _("Authentication Sources")) %>
<% content_for(:title, _("Authentication Sources")) %>
<%= react_component('WelcomeAuthSource', {canCreate: authorized_for(action: :new)}) %>
4 changes: 2 additions & 2 deletions app/views/autosign/_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<tbody>
<% autosign.each do |cert| %>
<tr>
<td><%= h cert%>
<td><%= h cert %>
</td>
<td>
<%= action_buttons(display_delete_if_authorized hash_for_smart_proxy_autosign_path(:smart_proxy_id => @proxy, :id => cert).merge(:auth_object => @proxy))%>
<%= action_buttons(display_delete_if_authorized hash_for_smart_proxy_autosign_path(:smart_proxy_id => @proxy, :id => cert).merge(:auth_object => @proxy)) %>
</td>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/bookmarks/welcome.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% content_for(:title, _("Bookmarks")) %>
<% description = _("You don't seem to have any bookmarks. Bookmarks are saved search queries. To save them, click on 'Bookmark this search' on the dropdown next to every search button.")%>
<% description = _("You don't seem to have any bookmarks. Bookmarks are saved search queries. To save them, click on 'Bookmark this search' on the dropdown next to every search button.") %>
<%= react_component('EmptyState', {
:icon => 'bookmark',
:iconType => 'fa',
Expand Down
4 changes: 2 additions & 2 deletions app/views/common/403.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</div>
<h1><%= _("Permission denied") %></h1>
<p>
<%= _("You are not authorized to perform this action.") %></br>
<%= _("Please request one of the required permissions listed below from a Foreman administrator:") %></br>
<%= _("You are not authorized to perform this action.") %><br>
<%= _("Please request one of the required permissions listed below from a Foreman administrator:") %><br>
<%= content_tag(:ul, permissions.join.html_safe, class: 'list-unstyled') %>
</p>
<p><%= link_to(_('Back'), main_app.root_path, :class => 'btn btn-default') %></p>
Expand Down
4 changes: 2 additions & 2 deletions app/views/common/500.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
</p>

<div class="pull-right">
<%= documentation_button("7.3GettingHelp")%>
</div>
<%= documentation_button("7.3GettingHelp") %>
</div>
3 changes: 1 addition & 2 deletions app/views/common/_login.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<%= react_component('LoginPage', props.to_json)%>

<%= react_component('LoginPage', props.to_json) %>
6 changes: 3 additions & 3 deletions app/views/common/_pagination.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id='pagination'>
<%= react_component('Pagination', {
itemCount: collection.total_entries,
<div id='pagination'>
<%= react_component('Pagination', {
itemCount: collection.total_entries,
className: options[:pagination_classes],
noSidePadding: true,
}) %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/common/confirm_class_clean_up.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<h1><%= _('Unknown records found in the database') %></h1>
<% if User.current&.admin? %>
<%= alert(text: _('Creating a DB backup before proceeding is highly recommended!'), class: 'alert-danger', close: false) %>

<%= (_('Foreman has detected definitions of unknown classes in your database. This can happen after a plugin removal which did not properly cleaned up data it created. Would you like to delete all records from SQL table <b>"%{table}"</b> with column <b>"%{column}"</b> having the value <b>"%{value}"</b>') % { table: @parent_class.table_name, column: @parent_class.inheritance_column, value: @unknown_class_name}).html_safe %>

<br><br>
<%= link_to _('Delete'), '?confirm_data_deletion=yes', class: 'btn btn-danger', data: { confirm: _('The data deletion can not be undone, are you sure you want to proceed?') } %>
<% else %>
Expand Down
3 changes: 1 addition & 2 deletions app/views/common/os_selection/_architecture.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
:class => 'host-architecture-os-select',
:data => { :url => method_path('os_selected'), :type => controller_name.singularize },
:required => !item.is_a?(Hostgroup),
:placeholder => arch_oss.empty? ? _("No options available for selected Architecture") : nil }
%>
:placeholder => arch_oss.empty? ? _("No options available for selected Architecture") : nil } %>
<% end %>
6 changes: 2 additions & 4 deletions app/views/common/os_selection/_operatingsystem.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
{:include_blank => blank_or_inherit_f(f, :medium), :selected => item.medium_id},
{:label => _("Media"), :help_inline => :indicator, :class => 'host-os-media-select',
:data => { :url => method_path('medium_selected'), :type => controller_name.singularize },
:required => !item.is_a?(Hostgroup), :placeholder => os_media.empty? ? _("No options available for selected Operating System") : nil }
%>
:required => !item.is_a?(Hostgroup), :placeholder => os_media.empty? ? _("No options available for selected Operating System") : nil } %>
<%= select_f f, :ptable_id, os_ptable, :id, :to_label,
{:include_blank => blank_or_inherit_f(f, :ptable), :selected => item.ptable_id},
{:label => _("Partition Table"), :required => !item.is_a?(Hostgroup), :placeholder => os_ptable.empty? ? _("No options available for selected Operating System") : nil }
%>
{:label => _("Partition Table"), :required => !item.is_a?(Hostgroup), :placeholder => os_ptable.empty? ? _("No options available for selected Operating System") : nil } %>

<% if @operatingsystem && @operatingsystem.supports_image %>
<%= render "common/os_selection/image_details", {:item => item} %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/common_parameters/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
:class => "form-control no-stretch #{'masked-input' if @common_parameter.hidden_value?}" %>
<%= checkbox_f f, :hidden_value, :class => 'hidden_value_textarea_switch', :onchange => 'turn_textarea_switch()', :checked => f.object.hidden_value? %>

<input type="hidden" id="old" value="<%= @common_parameter.value %>" />
<input type="hidden" id="new" value="<%= @common_parameter.value %>" />
<input type="hidden" id="old" value="<%= @common_parameter.value %>">
<input type="hidden" id="new" value="<%= @common_parameter.value %>">

<%= submit_or_cancel f %>
<% end %>
9 changes: 4 additions & 5 deletions app/views/common_parameters/_inherited_parameters.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
<% keys = inherited_parameters.keys.sort %>
<% keys.each do |name| %>
<% overriden = parameters.detect{|param| param.name == name}.present?
param_obj = inherited_parameters[name]
%>
<tr class="<%="override-param" if overriden %>">
<td class="ellipsis"><%= content_tag :span, name, :id => "name_#{name}"%>
param_obj = inherited_parameters[name] %>
<tr class="<%= "override-param" if overriden %>">
<td class="ellipsis"><%= content_tag :span, name, :id => "name_#{name}" %>
</td>
<td class="ellipsis"><%= content_tag :span, param_obj[:parameter_type], :id => "parameter_type_#{param_obj[:parameter_type]}"%>
<td class="ellipsis"><%= content_tag :span, param_obj[:parameter_type], :id => "parameter_type_#{param_obj[:parameter_type]}" %>
</td>
<td><%= parameter_value_field param_obj %></td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/common_parameters/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<% title _("Edit %s") % @common_parameter.to_s %>
<% title _("Edit %s") % @common_parameter.to_s %>

<%= render :partial => 'form' %>
9 changes: 4 additions & 5 deletions app/views/common_parameters/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@
<% title_actions new_link(_("Create Parameter")),
documentation_button('4.2.3Parameters') %>


<table class="<%= table_css_classes('table-hover table-fixed')%>">
<table class="<%= table_css_classes('table-hover table-fixed') %>">
<thead>
<tr>
<th class="col-md-3"><%= sort :name, :as => s_("Parameter|Name") %></th>
<th class="col-md-6" style='min-width: 60%;'><%= sort :value, :as => s_("Parameter|Value")%></th>
<th class="col-md-2"><%= sort :parameter_type, :as => s_("Parameter|Type")%></th>
<th class="col-md-6" style='min-width: 60%;'><%= sort :value, :as => s_("Parameter|Value") %></th>
<th class="col-md-2"><%= sort :parameter_type, :as => s_("Parameter|Type") %></th>
<th class="col-md-1"><%= _('Actions') %></th>
</tr>
</thead>
<tbody>
<% for common_parameter in @common_parameters %>
<tr id="<%= dom_id(common_parameter) %>_row">
<td class="ellipsis"><%= link_to_if_authorized common_parameter, hash_for_edit_common_parameter_path(:id => common_parameter).merge(:auth_object => common_parameter, :authorizer => authorizer, :permission => 'edit_params') %></td>
<td class='ellipsis parameter-value' >
<td class='ellipsis parameter-value'>
<%= common_parameter.hidden_value? ? common_parameter.hidden_value : common_parameter.value %>
</td>
<td class='ellipsis'><%= common_parameter.parameter_type %></td>
Expand Down
4 changes: 2 additions & 2 deletions app/views/common_parameters/welcome.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% content_for(:title, _("Global Parameters")) %>
<% description = _("Foreman allows to define a hierarchy of parameter inheritance, where global parameters accessible from any manifest.")%>
<% action = { :title => _("Create Global Parameter"), :url => new_common_parameter_path } if authorized_for(:action => :new)%>
<% description = _("Foreman allows to define a hierarchy of parameter inheritance, where global parameters accessible from any manifest.") %>
<% action = { :title => _("Create Global Parameter"), :url => new_common_parameter_path } if authorized_for(:action => :new) %>
<%= react_component('EmptyState', {
:icon => 'list-ul',
:iconType => 'fa',
Expand Down
3 changes: 1 addition & 2 deletions app/views/compute_attributes/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
}
],
switchable: false,
)
%>
) %>

<%= render 'form' %>
3 changes: 1 addition & 2 deletions app/views/compute_attributes/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
caption: _('New %s' % @set.compute_profile.to_label)
}
]
)
%>
) %>

<%= render 'form' %>
2 changes: 1 addition & 1 deletion app/views/compute_profiles/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<td class="ellipsis"><%= link_to_if_authorized compute_profile.name, hash_for_compute_profile_path(compute_profile).merge(:auth_object => compute_profile, :authorizer => authorizer, :auth_action => 'edit') %></td>
<td><%= action_buttons(
display_link_if_authorized(_('Rename'), hash_for_edit_compute_profile_path(compute_profile).merge(:auth_object => compute_profile, :authorizer => authorizer)),
display_delete_if_authorized(hash_for_compute_profile_path(compute_profile).merge(:auth_object => compute_profile, :authorizer => authorizer), :data => { :confirm => _('Delete %s?') % compute_profile.name }))%>
display_delete_if_authorized(hash_for_compute_profile_path(compute_profile).merge(:auth_object => compute_profile, :authorizer => authorizer), :data => { :confirm => _('Delete %s?') % compute_profile.name })) %>
</td>
</tr>
<% end %>
Expand Down
3 changes: 1 addition & 2 deletions app/views/compute_profiles/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<p>
<%= _("Click on the link of a compute resource to edit its default VM attributes.") %>
</p>
<br />
<br>

<table class="<%= table_css_classes %>">
<thead>
Expand All @@ -29,4 +29,3 @@
<% end %>
</tbody>
</table>

4 changes: 2 additions & 2 deletions app/views/compute_profiles/welcome.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% content_for(:title, _("Compute Profiles")) %>
<% description = _("A compute profile is a way of expressing a set of defaults for VMs created on a specific compute resource that can be mapped to an operator-defined label. This means an administrator can express, for example, what 'Small', 'Medium' or 'Large' means on all of the individual compute resources present for a given installation.")%>
<% action = { :title => _("Create Compute Profile"), :url => new_compute_profile_path } if authorized_for(:action => :new)%>
<% description = _("A compute profile is a way of expressing a set of defaults for VMs created on a specific compute resource that can be mapped to an operator-defined label. This means an administrator can express, for example, what 'Small', 'Medium' or 'Large' means on all of the individual compute resources present for a given installation.") %>
<% action = { :title => _("Create Compute Profile"), :url => new_compute_profile_path } if authorized_for(:action => :new) %>
<%= react_component('EmptyState', {
:icon => 'list-alt',
:iconType => 'fa',
Expand Down
2 changes: 1 addition & 1 deletion app/views/compute_resources/form/_libvirt.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:label => _("Console Passwords"),
:help_inline => _("Set a randomly generated password on the display connection") %>

<% hypervisor = f.object.hypervisor.uuid rescue nil%>
<% hypervisor = f.object.hypervisor.uuid rescue nil %>
<% if hypervisor %>
<%= f.hidden_field :uuid, :value => hypervisor %>
<% end %>
Expand Down
Loading

0 comments on commit 5918f55

Please sign in to comment.