Skip to content

Commit

Permalink
Started work on #679, saw 300+ errors, stopped
Browse files Browse the repository at this point in the history
  • Loading branch information
thesecretmaster committed Jul 8, 2020
1 parent dd02a23 commit 9138f0c
Show file tree
Hide file tree
Showing 107 changed files with 546 additions and 473 deletions.
28 changes: 28 additions & 0 deletions .ruumba.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
AllCops:
Include:
- '**/*.erb'
TargetRubyVersion: 2.4


Style/TrailingWhitespace:
Enabled: false
Metrics/LineLength:
Max: 200
Style/IndentationConsistency:
Enabled: false
Style/IndentationWidth:
Enabled: false
Style/InitialIndentation:
Enabled: false
Style/SpaceBeforeSemicolon:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Style/TrailingBlankLines:
Enabled: false
Lint/Void:
Enabled: false
Style/Semicolon:
Enabled: false
Style/ExtraSpacing:
Enabled: false
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ gem 'chartkick'
gem 'groupdate', '~> 3.0.0'

gem 'rubocop', '~> 0.48.1', require: false, group: :test
gem 'ruumba'
gem 'simplecov', require: false, group: :test

gem 'blazer', '2.2.1.charcoal', github: 'Charcoal-SE/blazer'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ GEM
i18n
ruby-progressbar (1.10.1)
ruby2_keywords (0.0.2)
ruumba (0.1.16)
rubocop
safe_yaml (1.0.5)
safely_block (0.2.2)
errbase (>= 0.1.1)
Expand Down Expand Up @@ -479,6 +481,7 @@ DEPENDENCIES
rotp (~> 4.0)
rqrcode
rubocop (~> 0.48.1)
ruumba
sass-rails
sensible_routes (~> 0.1.2)
simplecov
Expand Down
8 changes: 4 additions & 4 deletions app/views/abuse_reports/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<span class="glyphicon glyphicon-question-sign"></span> What are you reporting? *
<% end %><br/>
<%= f.select :reportable_type,
options_for_select([['SpamDomain', 'SpamDomain'], ['Post', 'Post'], ['DomainTag', 'DomainTag']], report.reportable_type),
{ include_blank: true }, { class: 'form-control' } %>
options_for_select([%w[SpamDomain SpamDomain], %w[Post Post], %w[DomainTag DomainTag]], report.reportable_type),
{ include_blank: true }, class: 'form-control' %>
</div>
<div class="col-md-8">
<%= f.label :reportable_id, raw('&nbsp;') %><br/>
Expand All @@ -23,8 +23,8 @@
<span class="small text-muted">Not listed? <a href="#" data-toggle="modal" data-target="#create-contact-modal">Create it now.</a></span>
<br/>
<%= f.select :abuse_contact_id, options_for_select(AbuseContact.all.map { |ac| [ac.name, ac.id] }, report.abuse_contact_id || flash[:abuse_contact_id]),
{ include_blank: true }, { class: 'form-control selectpicker',
data: { live_search: true, actions_box: true, dropup_auto: false } } %>
{ include_blank: true }, class: 'form-control selectpicker',
data: { live_search: true, actions_box: true, dropup_auto: false } %>
</div><br/>
<div class="field">
<%= f.label :details do %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/abuse_reports/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1>New Abuse Report</h1>

<%= render 'form', report: AbuseReport.new(reportable_type: params[:reportable_type], reportable_id: params[:reportable_id]),
url: create_abuse_report_path %>
url: create_abuse_report_path %>
4 changes: 2 additions & 2 deletions app/views/abuse_reports/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<%= form_tag update_abuse_report_status_path(@report), class: 'form-inline' do %>
<%= label_tag :status_id, 'Update report status:' %>
<%= select_tag :status_id, options_from_collection_for_select(AbuseReportStatus.all, 'id', 'name'), include_blank: true,
class: 'form-control input-sm' %>
class: 'form-control input-sm' %>
<%= submit_tag 'Update', class: 'btn btn-success btn-sm' %>
<% end %><br/>
<% end %>
Expand Down Expand Up @@ -67,7 +67,7 @@
<%= f.hidden_field :abuse_report_id, value: @report.id %>
<div class="field">
<%= f.text_area :text, rows: 3, cols: 100, placeholder: 'Useful information about this report that others might need...',
class: 'form-control' %>
class: 'form-control' %>
</div>
<div class="actions">
<%= f.submit 'Add Comment', class: 'btn btn-primary' %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/_roles_admin.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<% roles.each do |role| %>
<td>
<label class="permissions-checkbox-label">
<%= check_box_tag "#{user.id}[#{role.to_s}]", 'foo', user.has_cached_role?(role),
disabled: (role == :developer and not user.has_cached_role?(role)),
class: "permissions-checkbox", data: {user_id: user.id, role: role.to_s } %>
<%= check_box_tag "#{user.id}[#{role}]", 'foo', user.has_cached_role?(role),
disabled: (role == :developer && !user.has_cached_role?(role)),
class: 'permissions-checkbox', data: { user_id: user.id, role: role.to_s } %>
</label>
</td>
<% end %>
2 changes: 1 addition & 1 deletion app/views/admin/api_feedback.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<% end %>
</td>
<td class="<%= element_class_for_feedback f %>"><%= f.feedback_type %></td>
<td><%= link_to truncate(f.post.title, length: 50, separator: ' '), "/post/" + f.post_id.to_s %></td>
<td><%= link_to truncate(f.post.title, length: 50, separator: ' '), '/post/' + f.post_id.to_s %></td>
<td><%= f.api_key.app_name %></td>
<td><%= time_ago_in_words(f.created_at) %> ago</td>
</tr>
Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h3><%= title "Tools" %></h3>
<h3><%= title 'Tools' %></h3>
<p>Someone thought these were useful, at some point. We take no responsibility for whether they actually are or not.</p>
<p>
<ul>
Expand All @@ -8,10 +8,10 @@
<% if current_user.try(:has_role?, :admin) %>
<li><a href="/admin/flagged">Posts with Admin Reports</a></li>
<li><a href="/admin/keys">API Keys</a></li>
<li><%= link_to "User Permissions", admin_permissions_path %></li>
<li><%= link_to 'User Permissions', admin_permissions_path %></li>
<% end %>
<% if current_user&.has_role?(:developer) %>
<li><%= link_to "Production log", url_for(controller: :developer, action: :production_log), class: "text-danger" %></li>
<li><%= link_to 'Production log', url_for(controller: :developer, action: :production_log), class: 'text-danger' %></li>
<% end %>
</ul>
</p>
2 changes: 1 addition & 1 deletion app/views/admin/recently_invalidated.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<%= f.user_name %>
<% end %>
</td>
<td><%= time_ago_in_words(f.invalidated_at) + " ago" if f.invalidated_at %></td>
<td><%= time_ago_in_words(f.invalidated_at) + ' ago' if f.invalidated_at %></td>
<td><%= f.invalidated_by&.username %></td>
</tr>
<% end %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/user_feedback.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
</thead>
<tbody>
<% @feedback.each do |f| %>
<tr class="<%= "danger" if f.invalidated_at %>">
<tr class="<%= 'danger' if f.invalidated_at %>">
<td><a href="/post/<%= f.post_id %>"><%= f.title %></a></td>
<td class="<%= element_class_for_feedback f %>"><%= f.feedback_type %></td>
<td><%= f.invalidated_at ? "Yes" : "No" %></td>
<td><%= time_ago_in_words(f.created_at) + " ago" if f.created_at.present? %></td>
<td><%= f.invalidated_at ? 'Yes' : 'No' %></td>
<td><%= time_ago_in_words(f.created_at) + ' ago' if f.created_at.present? %></td>
</tr>
<% end %>
</tbody>
Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/users.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<th>ID</th>
<th>Username</th>
<% if current_user&.has_role?(:admin) %>
<% @roles.map {|r| r.to_s.humanize.titlecase }.each do |role_name| %>
<% @roles.map { |r| r.to_s.humanize.titlecase }.each do |role_name| %>
<th><%= role_name %></th>
<% end %>
<% else %>
Expand All @@ -32,9 +32,9 @@
<td><%= user.id %></td>
<td><%= link_to_if user.stack_exchange_account_id.present?, sanitize(user.username), "//stackexchange.com/users/#{user.stack_exchange_account_id}" %></td>
<% if current_user&.has_role?(:admin) %>
<%= render partial: 'roles_admin', locals: {roles: @roles, user: user} %>
<%= render partial: 'roles_admin', locals: { roles: @roles, user: user } %>
<% else %>
<td><%= user.roles.map(&:name).map{|n| n.humanize.downcase}.to_sentence.capitalize %></td>
<td><%= user.roles.map(&:name).map { |n| n.humanize.downcase }.to_sentence.capitalize %></td>
<% end %>
<td><%= link_to 'Feedback', admin_user_feedback_path(user_id: user.id) %></td>
<% if current_user&.has_role?(:admin) %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/announcements/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<% end %>
<span class="text-muted">Created <%= announcement.created_at %>, expires <%= announcement.expiry %>.</span>
<% if announcement.current? && current_user&.has_role?(:admin) %>
<%= link_to "Expire now", announcements_expire_path(announcement), class: "text-danger", method: :post, data: { confirm: "Are you sure? This can't be undone" } %>
<%= link_to 'Expire now', announcements_expire_path(announcement), class: 'text-danger', method: :post, data: { confirm: "Are you sure? This can't be undone" } %>
<% end %>
</p>
<%= render "announcements/announcement", announcement: announcement %>
<%= render 'announcements/announcement', announcement: announcement %>
<hr />
<% end %>
4 changes: 2 additions & 2 deletions app/views/announcements/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<%= text_area_tag :text, nil, rows: 5, cols: 80, class: 'form-control' %>
</div><br/>
<div class="field">
<%= label_tag :expiry_date, "Expiry (date & time)" %><br/>
<%= label_tag :expiry_date, 'Expiry (date & time)' %><br/>
<div class="input-group datetime">
<span class="input-group-addon">Date</span>
<%= date_field_tag :expiry_date, nil, class: 'form-control' %>
Expand All @@ -17,6 +17,6 @@
</div>
</div><br/>
<div class="actions">
<%= submit_tag "Create", class: 'btn btn-success' %>
<%= submit_tag 'Create', class: 'btn btn-success' %>
</div>
<% end %>
18 changes: 9 additions & 9 deletions app/views/api_keys/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
<%= form_for @key, url: url_for(controller: :api_keys, action: :update) do |f| %>
<div class="field">
<%= f.label :key %><br/>
<%= f.text_field :key, value: @key.key, class: "form-control" %>
<%= f.text_field :key, value: @key.key, class: 'form-control' %>
</div><br/>
<div class="field">
<%= f.label :app_name %><br/>
<%= f.text_field :app_name, class: "form-control" %>
<%= f.text_field :app_name, class: 'form-control' %>
</div><br/>
<div class="field">
<%= f.label :user_id, "Owner" %><br/>
<%= f.label :user_id, 'Owner' %><br/>
<% if @key.user %>
<%= f.select :user_id, options_for_select(User.all.map{|u| [u.username, u.id]}, [@key.user.username, @key.user.id]),
{ include_blank: true }, { class: "form-control" } %>
<%= f.select :user_id, options_for_select(User.all.map { |u| [u.username, u.id] }, [@key.user.username, @key.user.id]),
{ include_blank: true }, class: 'form-control' %>
<% else %>
<%= f.select :user_id, options_for_select(User.all.map{|u| [u.username, u.id]}), { include_blank: true }, { class: "form-control" } %>
<%= f.select :user_id, options_for_select(User.all.map { |u| [u.username, u.id] }), { include_blank: true }, class: 'form-control' %>
<% end %>
</div><br/>
<div class="field">
<%= f.label :github_link, "GitHub repository link" %><br/>
<%= f.text_field :github_link, class: "form-control" %>
<%= f.label :github_link, 'GitHub repository link' %><br/>
<%= f.text_field :github_link, class: 'form-control' %>
</div><br/>
<div class="field">
<%= f.submit "Save", class: "btn btn-primary" %>
<%= f.submit 'Save', class: 'btn btn-primary' %>
</div>
<% end %>
10 changes: 5 additions & 5 deletions app/views/api_keys/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<tr>
<td><%= key.key %></td>
<td><%= key.app_name %></td>
<td><%= link_to "Repo", key.github_link %></td>
<td><%= link_to 'Repo', key.github_link %></td>
<td>
<% if key.user %>
<%= key.user.username %>
Expand All @@ -26,12 +26,12 @@
<% end %>
</td>
<td><%= time_ago_in_words(key.created_at) %> ago</td>
<td><input type="checkbox" class="trust-checkbox" data-key-id="<%= key.id %>" <%= "checked" if key.is_trusted %> /></td>
<td><%= link_to "Edit", url_for(controller: :api_keys, action: :edit, id: key.id) %></td>
<td><%= link_to "Revoke write tokens", url_for(controller: :api_keys, action: :revoke_write_tokens, id: key.id), method: :delete, class: "text text-danger", data: { confirm: 'Are you sure?' } %></td>
<td><input type="checkbox" class="trust-checkbox" data-key-id="<%= key.id %>" <%= 'checked' if key.is_trusted %> /></td>
<td><%= link_to 'Edit', url_for(controller: :api_keys, action: :edit, id: key.id) %></td>
<td><%= link_to 'Revoke write tokens', url_for(controller: :api_keys, action: :revoke_write_tokens, id: key.id), method: :delete, class: 'text text-danger', data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>

<%= link_to "New API key", admin_new_key_url %>
<%= link_to 'New API key', admin_new_key_url %>
6 changes: 3 additions & 3 deletions app/views/api_keys/mine.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
<tr>
<td><%= key.key %></td>
<td><%= key.app_name %></td>
<td><%= link_to "Repo", key.github_link %></td>
<td><%= link_to 'Repo', key.github_link %></td>
<td><%= key.user.username %></td>
<td><%= time_ago_in_words(key.created_at) %> ago</td>
<td><%= link_to "Edit", url_for(controller: :api_keys, action: :owner_edit, id: key.id) %></td>
<td><%= link_to "Revoke write tokens", url_for(controller: :api_keys, action: :owner_revoke, id: key.id), method: :delete, class: "text text-danger", data: { confirm: 'Are you sure?' } %></td>
<td><%= link_to 'Edit', url_for(controller: :api_keys, action: :owner_edit, id: key.id) %></td>
<td><%= link_to 'Revoke write tokens', url_for(controller: :api_keys, action: :owner_revoke, id: key.id), method: :delete, class: 'text text-danger', data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
Expand Down
14 changes: 7 additions & 7 deletions app/views/api_keys/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
<%= form_for @key, url: url_for(controller: :api_keys, action: :create) do |f| %>
<div class="field">
<%= f.label :key %><br/>
<%= f.text_field :key, value: @key.key, class: "form-control" %>
<%= f.text_field :key, value: @key.key, class: 'form-control' %>
</div><br/>
<div class="field">
<%= f.label :app_name %><br/>
<%= f.text_field :app_name, class: "form-control" %>
<%= f.text_field :app_name, class: 'form-control' %>
</div><br/>
<div class="field">
<%= f.label :user_id, "Owner" %><br/>
<%= f.select :user_id, options_for_select(User.all.map{|u| [u.username, u.id]}), { include_blank: true }, { class: "form-control" } %>
<%= f.label :user_id, 'Owner' %><br/>
<%= f.select :user_id, options_for_select(User.all.map { |u| [u.username, u.id] }), { include_blank: true }, class: 'form-control' %>
</div><br/>
<div class="field">
<%= f.label :github_link, "GitHub repository link" %><br/>
<%= f.text_field :github_link, class: "form-control" %>
<%= f.label :github_link, 'GitHub repository link' %><br/>
<%= f.text_field :github_link, class: 'form-control' %>
</div><br/>
<div class="field">
<%= f.submit "Register", class: "btn btn-primary" %>
<%= f.submit 'Register', class: 'btn btn-primary' %>
</div>
<% end %>
8 changes: 4 additions & 4 deletions app/views/api_keys/owner_edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<%= form_for @key, url: url_for(controller: :api_keys, action: :owner_update) do |f| %>
<div class="field">
<%= f.label :app_name %><br/>
<%= f.text_field :app_name, class: "form-control" %>
<%= f.text_field :app_name, class: 'form-control' %>
</div><br/>
<div class="field">
<%= f.label :github_link, "GitHub repository link" %><br/>
<%= f.text_field :github_link, class: "form-control" %>
<%= f.label :github_link, 'GitHub repository link' %><br/>
<%= f.text_field :github_link, class: 'form-control' %>
</div><br/>
<div class="field">
<%= f.submit "Save", class: "btn btn-primary" %>
<%= f.submit 'Save', class: 'btn btn-primary' %>
</div>
<% end %>
2 changes: 1 addition & 1 deletion app/views/authentication/invalidate_tokens.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<%= form_tag url_for(controller: :authentication, action: :send_invalidations), method: :post do %>
<div class="field">
<%= label_tag 'users' %><br/>
<%= select_tag 'users', options_for_select(@users.map{|u| [u.username, u.id]}), { multiple: true, class: "form-control selectpicker", 'data-live-search' => true, 'data-actions-box' => true, 'data-dropup-auto' => false, title: "Choose users to invalidate API tokens for" } %>
<%= select_tag 'users', options_for_select(@users.map { |u| [u.username, u.id] }), multiple: true, class: 'form-control selectpicker', 'data-live-search' => true, 'data-actions-box' => true, 'data-dropup-auto' => false, title: 'Choose users to invalidate API tokens for' %>
</div>
<br/>
<div class="actions">
Expand Down
4 changes: 2 additions & 2 deletions app/views/authentication/status.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<p>Associate your metasmoke account with your Stack Exchange account to provide feedback through the API.</p>

<% if current_user.stack_exchange_account_id.nil? %>
<%= link_to "Authenticate", identify_auth_url, class: "btn btn-success" %>
<%= link_to 'Authenticate', identify_auth_url, class: 'btn btn-success' %>
<% else %>
<h4><strong>You have already authenticated. You do not need to do so again.</strong></h4>
<p>However, you can authenticate again (e.g. if you are experiencing problems).</p>
Expand All @@ -19,7 +19,7 @@
<li>with a budget of about four dollars a month</li>
</ul>
<br />
<%= link_to "Authenticate w/ Write Access", write_auth_url, class: "btn btn-danger" %>
<%= link_to 'Authenticate w/ Write Access', write_auth_url, class: 'btn btn-danger' %>
</div>
<% end %>
<% end %>
Loading

0 comments on commit 9138f0c

Please sign in to comment.