Skip to content

Commit acdf076

Browse files
committed
Make CI lint checks block on errors
Fix existing rubocop and eslint violations so that lint steps in the GitHub Actions workflow can run without continue-on-error. Lint failures now fail the PR check instead of being silently downgraded to warnings. REDMINE-21261
1 parent a23d6d8 commit acdf076

37 files changed

Lines changed: 125 additions & 167 deletions

File tree

.github/workflows/lint.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,10 @@ jobs:
6262
# Lint
6363

6464
- name: Run RuboCop
65-
shell: bash
66-
continue-on-error: true
67-
run: |
68-
bundle exec rubocop --format github | sed 's/::error/::warning/g'
65+
run: bundle exec rubocop
6966

7067
- name: Run ESLint in pageflow package
71-
shell: bash
72-
continue-on-error: true
73-
run: |
74-
yarn --cwd package lint . --format @jamesacarr/github-actions
68+
run: yarn --cwd package lint .
7569

7670
- name: Run ESLint in pageflow-scrolled
77-
shell: bash
78-
continue-on-error: true
79-
run: |
80-
yarn --cwd entry_types/scrolled/package lint . --format @jamesacarr/github-actions
71+
run: yarn --cwd entry_types/scrolled/package lint .

admins/pageflow/accounts.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ module Pageflow
2121
account.memberships.size if authorized?(:read, account)
2222
end
2323
account_memberships = current_user.memberships.on_accounts
24-
account_roles = account_memberships.each_with_object({}) do |membership, roles|
25-
roles[membership.entity_id] = membership.role
24+
account_roles = account_memberships.to_h do |membership|
25+
[membership.entity_id, membership.role]
2626
end
2727
if authorized?(:see_own_role_on, :accounts)
2828
column :own_role do |account|
@@ -43,16 +43,16 @@ module Pageflow
4343
searchable_select_options(text_attribute: :name,
4444
scope: lambda do
4545
Account
46-
.accessible_by(current_ability, :read)
47-
.order(:name)
46+
.accessible_by(current_ability, :read)
47+
.order(:name)
4848
end)
4949

5050
searchable_select_options(name: :member_addable,
5151
text_attribute: :name,
5252
scope: lambda do
5353
AccountPolicy::Scope.new(current_user, Account)
54-
.member_addable
55-
.order(:name)
54+
.member_addable
55+
.order(:name)
5656
end)
5757

5858
form partial: 'form'

admins/pageflow/entry.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,18 @@ module Pageflow
101101
text_attribute: :name,
102102
scope: lambda do
103103
AccountPolicy::Scope
104-
.new(current_user, Account)
105-
.entry_movable
106-
.order(:name)
104+
.new(current_user, Account)
105+
.entry_movable
106+
.order(:name)
107107
end)
108108

109109
searchable_select_options(name: :eligible_sites,
110110
text_attribute: :name_with_account_prefix,
111111
scope: lambda do |params|
112112
account = Account.find(params[:account_id])
113113
SitePolicy::Scope
114-
.new(current_user, Site)
115-
.sites_allowed_for(account)
114+
.new(current_user, Site)
115+
.sites_allowed_for(account)
116116
end,
117117
filter: lambda do |term, scope|
118118
scope.ransack(account_name_cont: term).result
@@ -318,7 +318,7 @@ def site_policy_scope
318318
end
319319

320320
# rubocop:todo Metrics/PerceivedComplexity
321-
def permitted_attributes # rubocop:todo Metrics/AbcSize
321+
def permitted_attributes # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity
322322
result = [:title, :type_name, {permalink_attributes: [:slug, :directory_id]}]
323323
target = if !params[:id] && current_user.admin?
324324
Account.first
@@ -331,7 +331,7 @@ def permitted_attributes # rubocop:todo Metrics/AbcSize
331331
result += permitted_account_attributes
332332

333333
result << :folder_id if create_or_new_action? ||
334-
(params[:id] && authorized?(:configure_folder_for, resource))
334+
(params[:id] && authorized?(:configure_folder_for, resource))
335335

336336
accounts = if params[:id]
337337
resource.account

admins/pageflow/membership.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ module Pageflow
1212
user = User.find(params[:parent_id])
1313

1414
PotentialMemberships
15-
.creatable_by(current_user)
16-
.accounts_for_user(user)
17-
.order(:name)
15+
.creatable_by(current_user)
16+
.accounts_for_user(user)
17+
.order(:name)
1818
end)
1919

2020
searchable_select_options(name: :potential_entries_for_user,
@@ -24,8 +24,8 @@ module Pageflow
2424
scope: lambda do |params|
2525
user = User.find(params[:parent_id])
2626
entries = PotentialMemberships
27-
.creatable_by(current_user)
28-
.entries_for_user(user)
27+
.creatable_by(current_user)
28+
.entries_for_user(user)
2929

3030
if can?(:see, :accounts)
3131
entries.include_account_name.order('account_name', :title)
@@ -42,9 +42,9 @@ module Pageflow
4242
scope: lambda do |params|
4343
account = Account.find(params[:parent_id])
4444
PotentialMemberships
45-
.creatable_by(current_user)
46-
.users_for_account(account)
47-
.order(:last_name, :first_name)
45+
.creatable_by(current_user)
46+
.users_for_account(account)
47+
.order(:last_name, :first_name)
4848
end,
4949
filter: lambda do |term, scope|
5050
UserNameQuery::Scope.new(term, scope).resolve
@@ -55,9 +55,9 @@ module Pageflow
5555
scope: lambda do |params|
5656
entry = Entry.find(params[:parent_id])
5757
PotentialMemberships
58-
.creatable_by(current_user)
59-
.users_for_entry(entry)
60-
.order(:last_name, :first_name)
58+
.creatable_by(current_user)
59+
.users_for_entry(entry)
60+
.order(:last_name, :first_name)
6161
end,
6262
filter: lambda do |term, scope|
6363
UserNameQuery::Scope.new(term, scope).resolve

admins/pageflow/translations.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ module Pageflow
1414
display_text: lambda do |entry|
1515
if entry.translation_group
1616
entry.translation_group
17-
.entries
18-
.order('title ASC')
19-
.map(&:title)
20-
.join(' / ')
21-
.presence
17+
.entries
18+
.order('title ASC')
19+
.map(&:title)
20+
.join(' / ')
21+
.presence
2222
else
2323
entry.title
2424
end

app/helpers/pageflow/admin/widgets_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ def admin_widgets_fields(form, config)
99
end
1010

1111
def admin_widget_types_collection_for_role(config, role)
12-
config.widget_types.find_all_by_role(role).each_with_object({}) do |widget_type, result|
13-
result[I18n.t(widget_type.translation_key)] = widget_type.name
12+
config.widget_types.find_all_by_role(role).to_h do |widget_type|
13+
[I18n.t(widget_type.translation_key), widget_type.name]
1414
end
1515
end
1616
end

app/helpers/pageflow/common_entry_seed_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def initialize(config)
2626
end
2727

2828
def as_json
29-
config.page_types.each_with_object({}) do |page_type, result|
30-
result[page_type.name.to_sym] = page_type_seed(page_type)
29+
config.page_types.to_h do |page_type|
30+
[page_type.name.to_sym, page_type_seed(page_type)]
3131
end
3232
end
3333

app/helpers/pageflow/entry_json_seed_helper.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ def entry_widgets_seed(entry)
5151
end
5252

5353
def entry_file_ids_seed(entry)
54-
Pageflow.config.file_types.with_thumbnail_support.each_with_object({}) do |file_type, result|
55-
result[file_type.collection_name] = entry.find_files(file_type.model).map(&:perma_id)
54+
Pageflow.config.file_types.with_thumbnail_support.to_h do |file_type|
55+
[file_type.collection_name, entry.find_files(file_type.model).map(&:perma_id)]
5656
end
5757
end
5858

5959
def entry_audio_files_json_seed(entry)
60-
seed = entry.find_files(AudioFile).each_with_object({}) do |audio_file, result|
61-
result[audio_file.perma_id] = audio_file_sources(audio_file)
60+
seed = entry.find_files(AudioFile).to_h do |audio_file|
61+
[audio_file.perma_id, audio_file_sources(audio_file)]
6262
end
6363

6464
sanitize_json(seed.to_json).html_safe

app/helpers/pageflow/public_i18n_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def public_i18n_translations(entry)
1414
{
1515
pageflow: {
1616
public: I18n.t('pageflow.public', locale: I18n.default_locale)
17-
.dup
17+
.dup
1818
.deep_merge(I18n.t('pageflow.public', locale: entry.locale),
1919
&merge_ignoring_nil)
2020
}

app/helpers/pageflow/themes_helper.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ module ThemesHelper # rubocop:todo Style/Documentation
33
include RenderJsonHelper
44

55
def themes_options_json_seed(config = Pageflow.config)
6-
config.themes.each_with_object({}) { |theme, options|
7-
options[theme.name] = theme.options
8-
}.to_json.html_safe
6+
config.themes.to_h { |theme| [theme.name, theme.options] }.to_json.html_safe
97
end
108

119
def theme_json_seeds(config)

0 commit comments

Comments
 (0)