Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
247bad8
setting up ERB linting (ACTION WILL NOT PASS)
Oaphi Jul 24, 2025
f9a3dbd
do not even try to run tests if linting fails
Oaphi Jul 24, 2025
c74f0f6
fine, I'll specify permissions now, CodeQL
Oaphi Jul 24, 2025
05c1531
disabled Layout/TrailingEmptyLines for ERB linting (~3K errors)
Oaphi Jul 24, 2025
14134b8
disabled Layout/InitialIndentation due to thousands of false positives
Oaphi Jul 24, 2025
56e2f3e
disabled Lint/UselessAssignment due to hundreds of false positives
Oaphi Jul 24, 2025
267401a
added specific files to ERB lint exclusion list as they cause clobbering
Oaphi Jul 24, 2025
a94cbf1
disabled Layout/LeadingEmptyLine due to false positives
Oaphi Jul 24, 2025
d44dc06
disabled Layout/TrailingWhitespace due to false positives
Oaphi Jul 24, 2025
927f736
applying a couple of trivial fixes
Oaphi Jul 24, 2025
9763d01
removed matrices from linting jobs
Oaphi Jul 24, 2025
6d08217
Merge branch 'develop' into 0valt/1699/erb_lint
Oaphi Jul 29, 2025
181037a
minor linting fixes for the users/edit_profile view
Oaphi Jul 31, 2025
9a46f06
minor linting fixes for the users/vote_summary view
Oaphi Jul 31, 2025
fdd87e9
fixed search button alignment on the users page
Oaphi Jul 31, 2025
5069545
fixed linting issues with the users/index view
Oaphi Jul 31, 2025
e9ccb7b
minor linting fix for the search/_widget partial
Oaphi Jul 31, 2025
9233b4c
fixed linting issues with the users/posts view
Oaphi Jul 31, 2025
535d8df
applied a bunch of easy autocorrections
Oaphi Jul 31, 2025
f5a1101
applied views/pinned_links/_form partial autocorrect
Oaphi Jul 31, 2025
0a56b30
manual linter fixes for the posts/expanded partial
Oaphi Jul 31, 2025
67fe4b0
added a proper partial for post flags lists (also solves a couple of …
Oaphi Jul 31, 2025
97c9dec
and then there were 6, or even more linter fixes for posts/_expanded
Oaphi Jul 31, 2025
16415b6
fixed remaining linter errors for the posts/_expanded partial
Oaphi Jul 31, 2025
f729495
a bunch more linter fixes (down to 370 issues)
Oaphi Jul 31, 2025
7ab02e1
applied views/users/_tabs partial autocorrect
Oaphi Jul 31, 2025
3c51014
Merge branch 'develop' into 0valt/1699/erb_lint
Oaphi Aug 4, 2025
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
3 changes: 3 additions & 0 deletions .better-html.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://github.com/Shopify/better-html#configuration

allow_single_quoted_attributes: false
43 changes: 43 additions & 0 deletions .erb_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# configuration reference: https://github.com/Shopify/erb_lint?tab=readme-ov-file#configuration

EnableDefaultLinters: false

exclude:
- 'config/**/*'
- 'db/**/*'
- 'scripts/**/*'
- 'bin/**/*'
- 'lib/namespaced_env_cache.rb'
- 'vendor/bundle/**/*'
# TODO: fix clobbering (autocorrect conflics) first:
- 'app/views/admin/_error_report.html.erb'
- 'app/views/categories/show.html.erb'
- 'app/views/micro_auth/authentication/initiate.html.erb'
- 'app/views/reactions/_form.html.erb'
- 'app/views/reports/reactions.html.erb'
- 'app/views/suggested_edit/category_index.html.erb'
- 'app/views/questions/_list.html.erb'
- 'app/views/tags/category.html.erb'
- 'app/views/users/_activity_items.html.erb'

glob: '**/*.{html,text,js}{+*,}.erb'

linters:
ErbSafety:
enabled: true
better_html_config: .better-html.yml
Rubocop:
enabled: true
rubocop_config:
inherit_from:
- .rubocop.yml
Layout/LeadingEmptyLines:
Enabled: false # false positives on embedded Ruby indentation in tags
Layout/InitialIndentation:
Enabled: false # false positives on embedded Ruby indentation in tags
Layout/TrailingEmptyLines:
Enabled: false # enable when we are ready to solve ~3K errors
Layout/TrailingWhitespace:
Enabled: false # false positives on embedded Ruby indentation in tags
Lint/UselessAssignment:
Enabled: false # false positives on single-line embedded Ruby assignments
36 changes: 31 additions & 5 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,37 @@ on:

env:
RAILS_ENV: test
RUBY_VERSION: 3.2

permissions:
actions: write
contents: read
issues: read
pull-requests: read

jobs:
erb_lint:
name: ERB checking
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -yqq libmagickwand-dev
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- run: bundle exec erb_lint --lint-all

rubocop:
name: Rubocop checking
runs-on: ubuntu-latest

strategy:
matrix:
ruby_version: [3.1, 3.2]

steps:
- name: Checkout repo
uses: actions/checkout@v3
Expand All @@ -30,7 +51,7 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- run: bundle exec rubocop

Expand All @@ -51,6 +72,10 @@ jobs:
tests:
name: Ruby on Rails tests
runs-on: ubuntu-latest
needs:
- erb_lint
- rubocop
- typescript

strategy:
matrix:
Expand Down Expand Up @@ -118,6 +143,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.actor != 'dependabot[bot]' }}
needs:
- erb_lint
- rubocop
- typescript
- tests
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ gem 'whenever', '~> 1.0', require: false

# Debugging, linting, testing.
gem 'awesome_print', '~> 1.9'
gem 'erb_lint', '~> 0.9.0'
gem 'rubocop', '~> 1'
gem 'rubocop-rails', '~> 2.15'
gem 'rubocop-rake', '~> 0.7.1'
Expand Down
16 changes: 16 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ GEM
base64 (0.3.0)
bcrypt (3.1.20)
benchmark (0.4.1)
better_html (2.1.1)
actionview (>= 6.0)
activesupport (>= 6.0)
ast (~> 2.0)
erubi (~> 1.4)
parser (>= 2.4)
smart_properties
bigdecimal (3.2.2)
bindex (0.8.1)
builder (3.3.0)
Expand Down Expand Up @@ -157,6 +164,13 @@ GEM
e2mmap (0.1.0)
erb (4.0.4)
cgi (>= 0.3.3)
erb_lint (0.9.0)
activesupport
better_html (>= 2.0.1)
parser (>= 2.7.1.4)
rainbow
rubocop (>= 1)
smart_properties
erubi (1.13.1)
execjs (2.10.0)
fastimage (2.4.0)
Expand Down Expand Up @@ -405,6 +419,7 @@ GEM
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
smart_properties (1.17.0)
spring (4.3.0)
sprockets (4.1.1)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -483,6 +498,7 @@ DEPENDENCIES
devise_saml_authenticatable (~> 1.9)
diffy (~> 3.4)
e2mmap (~> 0.1)
erb_lint (~> 0.9.0)
fastimage (~> 2.2)
flamegraph (~> 0.9)
groupdate (~> 6.1)
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/admin_email.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<%= form_with url: send_moderator_email_path do |f| %>
<div class="form-group">
<%= f.label :subject, t('g.subject').capitalize, class: 'form-element' %>
<%= f.text_field :subject, class: 'form-element' %>
<%= f.text_field :subject, class: 'form-element' %>
</div>

<%= render 'shared/body_field', f: f, field_name: :body_markdown, field_label: t('g.body').capitalize, post: nil %>
Expand Down
48 changes: 24 additions & 24 deletions app/views/admin/all_email.html.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<%= render 'posts/markdown_script' %>
<div class="notice is-danger">
<p>
<i class="fas fa-exclamation-triangle"></i> Please be careful, as this tool sends a lot of emails.
</p>
</div>
<h1><%= t 'admin.tools.email_all' %></h1>
<p><%= t 'admin.email_all_blurb' %></p>
<%= form_with url: send_all_email_path do |f| %>
<div class="form-group">
<%= f.label :subject, t('g.subject').capitalize, class: 'form-element' %>
<%= f.text_field :subject, class: 'form-element', required: true %>
</div>
<%= render 'shared/body_field', f: f, field_name: :body_markdown, field_label: t('g.body').capitalize, post: nil %>
<div class="post-preview"></div>
<%= f.submit t('g.send').capitalize, class: 'button is-filled',
onclick: "return confirm('Are you sure you want to send this email to all users?')" %>
<% end %>
<%= render 'posts/markdown_script' %>

<div class="notice is-danger">
<p>
<i class="fas fa-exclamation-triangle"></i> Please be careful, as this tool sends a lot of emails.
</p>
</div>

<h1><%= t 'admin.tools.email_all' %></h1>
<p><%= t 'admin.email_all_blurb' %></p>

<%= form_with url: send_all_email_path do |f| %>
<div class="form-group">
<%= f.label :subject, t('g.subject').capitalize, class: 'form-element' %>
<%= f.text_field :subject, class: 'form-element', required: true %>
</div>

<%= render 'shared/body_field', f: f, field_name: :body_markdown, field_label: t('g.body').capitalize, post: nil %>

<div class="post-preview"></div>

<%= f.submit t('g.send').capitalize, class: 'button is-filled',
onclick: "return confirm('Are you sure you want to send this email to all users?')" %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/admin/create_site.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

<p>Once you are ready, click on the following button:</p>

<a href="//<%= @new_community.host %>/admin/setup" class="button is-filled is-very-large">To new site</a>
<a href="//<%= @new_community.host %>/admin/setup" class="button is-filled is-very-large">To new site</a>
2 changes: 1 addition & 1 deletion app/views/admin/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% content_for :title, t('admin.dashboard.title') %>

<%= link_to moderator_path, class: "has-font-size-small" do %>
<%= link_to moderator_path, class: 'has-font-size-small' do %>
Switch to Moderator Tools
<% end %>

Expand Down
46 changes: 23 additions & 23 deletions app/views/admin/new_site.html.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<h1>Create New Site</h1>
<div class="notice is-danger">
<p><strong>Attention!</strong> You are about to create a new site in this network. You will not be able to undo this later. You'll need access to the server configuration to complete this process.</p>
</div>
<h2>Site Configuration</h2>
<%= form_for @new_community, url: create_site_path do |f| %>
<div class="form-group">
<%= f.label :name, 'Community name', class: 'form-element' %>
<%= f.text_field :name, class: 'form-element' %>
</div>
<div class="form-group">
<%= f.label :host, 'Primary community host', class: 'form-element' %>
<div class="form-caption">This is likely something like X.codidact.com. Without / and https://. You can set up secondary community hosts (redirect) later in the server configuration.</div>
<%= f.text_field :host, class: 'form-element' %>
</div>
<%= f.submit "Create new site", class: 'button is-danger is-filled' %>
<h1>Create New Site</h1>

<div class="notice is-danger">
<p><strong>Attention!</strong> You are about to create a new site in this network. You will not be able to undo this later. You'll need access to the server configuration to complete this process.</p>
</div>

<h2>Site Configuration</h2>

<%= form_for @new_community, url: create_site_path do |f| %>

<div class="form-group">
<%= f.label :name, 'Community name', class: 'form-element' %>
<%= f.text_field :name, class: 'form-element' %>
</div>

<div class="form-group">
<%= f.label :host, 'Primary community host', class: 'form-element' %>
<div class="form-caption">This is likely something like X.codidact.com. Without / and https://. You can set up secondary community hosts (redirect) later in the server configuration.</div>
<%= f.text_field :host, class: 'form-element' %>
</div>

<%= f.submit 'Create new site', class: 'button is-danger is-filled' %>

<% end %>
Loading
Loading