Skip to content

Commit 6382e95

Browse files
committed
Fix some linting errors
1 parent 0ba3458 commit 6382e95

48 files changed

Lines changed: 1033 additions & 1013 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/assets/builds/application.js

Lines changed: 415 additions & 355 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/builds/application.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/channels/application_cable/connection.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ def connect
1111
def find_verified_user
1212
# Try JWT token first (from cookies or params)
1313
token = cookies["jwt_token"] || request.params["token"]
14-
14+
1515
if token.present?
1616
decoded = JsonWebToken.decode(token)
1717
if verified_user = User.find_by(id: decoded["user_id"])
1818
return verified_user
1919
end
2020
end
21-
21+
2222
# Fall back to session-based auth
2323
if verified_user = User.find_by(id: cookies.encrypted[:user_id])
2424
return verified_user
2525
end
26-
26+
2727
reject_unauthorized_connection
2828
rescue JWT::DecodeError
2929
reject_unauthorized_connection

app/controllers/admin/base_controller.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module Admin
2+
# rubocop:disable Rails/ApplicationController
23
class BaseController < ActionController::Base
34
include Pagy::Method
45

@@ -14,7 +15,7 @@ class BaseController < ActionController::Base
1415
before_action :check_maintenance_mode
1516

1617
layout "admin"
17-
18+
1819
helper_method :current_user, :user_signed_in?, :current_admin_user
1920

2021
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
@@ -28,7 +29,7 @@ def authenticate_admin!
2829
redirect_to admin_login_path, alert: "You must be logged in to access this area."
2930
return
3031
end
31-
32+
3233
return if current_user&.admin? || current_user&.editor?
3334

3435
redirect_to admin_login_path, alert: "You must be logged in as an admin or editor to access this area."
@@ -37,11 +38,11 @@ def authenticate_admin!
3738
def current_admin_user
3839
@current_admin_user ||= current_user if current_user&.admin?
3940
end
40-
41+
4142
def current_user
4243
@current_user ||= User.find_by(id: session[:admin_user_id]) if session[:admin_user_id]
4344
end
44-
45+
4546
def user_signed_in?
4647
current_user.present?
4748
end
@@ -78,22 +79,22 @@ def record_invalid(exception)
7879
respond_to do |format|
7980
format.html do
8081
flash[:alert] = "There was an error processing your request: #{exception.message}"
81-
redirect_back(fallback_location: admin_streams_path)
82+
redirect_back_or_to(admin_streams_path)
8283
end
8384
format.turbo_stream do
8485
render turbo_stream: turbo_stream.replace("flash",
8586
partial: "admin/shared/flash",
8687
locals: { alert: "There was an error processing your request." })
8788
end
88-
format.json { render json: { error: exception.message }, status: :unprocessable_entity }
89+
format.json { render json: { error: exception.message }, status: :unprocessable_content }
8990
end
9091
end
9192

9293
def parameter_missing(exception)
9394
respond_to do |format|
9495
format.html do
9596
flash[:alert] = "Required parameter missing: #{exception.param}"
96-
redirect_back(fallback_location: admin_streams_path)
97+
redirect_back_or_to(admin_streams_path)
9798
end
9899
format.turbo_stream do
99100
render turbo_stream: turbo_stream.replace("flash",
@@ -104,4 +105,5 @@ def parameter_missing(exception)
104105
end
105106
end
106107
end
108+
# rubocop:enable Rails/ApplicationController
107109
end
Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
module Admin
22
class IgnoreListsController < BaseController
3-
before_action :set_ignore_list, only: [:edit, :update, :destroy]
3+
before_action :set_ignore_list, only: %i[edit update destroy]
44

55
def index
66
@ignore_lists = IgnoreList.all
77

88
# Filter by list type
9-
if params[:list_type].present?
10-
@ignore_lists = @ignore_lists.where(list_type: params[:list_type])
11-
end
9+
@ignore_lists = @ignore_lists.where(list_type: params[:list_type]) if params[:list_type].present?
1210

1311
# Search functionality
14-
if params[:search].present?
15-
@ignore_lists = @ignore_lists.where('value ILIKE ?', "%#{params[:search]}%")
16-
end
12+
@ignore_lists = @ignore_lists.where("value ILIKE ?", "%#{params[:search]}%") if params[:search].present?
1713

1814
# Sorting
1915
@ignore_lists = @ignore_lists.order(created_at: :desc)
@@ -31,43 +27,42 @@ def new
3127
@ignore_list = IgnoreList.new(list_type: params[:list_type])
3228
end
3329

30+
def edit; end
31+
3432
def create
3533
@ignore_list = IgnoreList.new(ignore_list_params)
3634

3735
if @ignore_list.save
38-
redirect_to admin_ignore_lists_path, notice: 'Ignore list entry was successfully created.'
36+
redirect_to admin_ignore_lists_path, notice: "Ignore list entry was successfully created."
3937
else
40-
render :new, status: :unprocessable_entity
38+
render :new, status: :unprocessable_content
4139
end
4240
end
4341

44-
def edit
45-
end
46-
4742
def update
4843
if @ignore_list.update(ignore_list_params)
49-
redirect_to admin_ignore_lists_path, notice: 'Ignore list entry was successfully updated.'
44+
redirect_to admin_ignore_lists_path, notice: "Ignore list entry was successfully updated."
5045
else
51-
render :edit, status: :unprocessable_entity
46+
render :edit, status: :unprocessable_content
5247
end
5348
end
5449

5550
def destroy
5651
@ignore_list.destroy
57-
redirect_to admin_ignore_lists_path, notice: 'Ignore list entry was successfully deleted.'
52+
redirect_to admin_ignore_lists_path, notice: "Ignore list entry was successfully deleted."
5853
end
5954

6055
# Bulk import action
6156
def bulk_import
62-
if request.post?
63-
results = process_bulk_import(params[:import_data], params[:list_type])
64-
65-
if results[:errors].empty?
66-
redirect_to admin_ignore_lists_path, notice: "Successfully imported #{results[:created].count} entries."
67-
else
68-
redirect_to admin_ignore_lists_path,
69-
alert: "Imported #{results[:created].count} entries. #{results[:errors].count} errors occurred."
70-
end
57+
return unless request.post?
58+
59+
results = process_bulk_import(params[:import_data], params[:list_type])
60+
61+
if results[:errors].empty?
62+
redirect_to admin_ignore_lists_path, notice: "Successfully imported #{results[:created].count} entries."
63+
else
64+
redirect_to admin_ignore_lists_path,
65+
alert: "Imported #{results[:created].count} entries. #{results[:errors].count} errors occurred."
7166
end
7267
end
7368

@@ -78,12 +73,12 @@ def set_ignore_list
7873
end
7974

8075
def ignore_list_params
81-
params.require(:ignore_list).permit(:list_type, :value, :notes)
76+
params.expect(ignore_list: %i[list_type value notes])
8277
end
8378

8479
def process_bulk_import(import_data, list_type)
8580
results = { created: [], errors: [] }
86-
81+
8782
return results if import_data.blank? || list_type.blank?
8883

8984
# Split by newlines and process each line
@@ -92,7 +87,7 @@ def process_bulk_import(import_data, list_type)
9287
next if value.blank?
9388

9489
ignore_list = IgnoreList.new(list_type: list_type, value: value)
95-
90+
9691
if ignore_list.save
9792
results[:created] << ignore_list
9893
else
@@ -103,4 +98,4 @@ def process_bulk_import(import_data, list_type)
10398
results
10499
end
105100
end
106-
end
101+
end

app/controllers/admin/locations_controller.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def index
77
Location.includes(:streams)
88
.order(created_at: :desc)
99
.search_by_name(params[:search]),
10-
limit: 25
10+
limit: 25,
1111
)
1212
end
1313

@@ -19,8 +19,7 @@ def new
1919
@location = Location.new
2020
end
2121

22-
def edit
23-
end
22+
def edit; end
2423

2524
def create
2625
@location = Location.new(location_params)
@@ -30,8 +29,8 @@ def create
3029
format.html { redirect_to admin_location_path(@location), notice: "Location was successfully created." }
3130
format.turbo_stream
3231
else
33-
format.html { render :new, status: :unprocessable_entity }
34-
format.turbo_stream { render :form_update, status: :unprocessable_entity }
32+
format.html { render :new, status: :unprocessable_content }
33+
format.turbo_stream { render :form_update, status: :unprocessable_content }
3534
end
3635
end
3736
end
@@ -42,8 +41,8 @@ def update
4241
format.html { redirect_to admin_location_path(@location), notice: "Location was successfully updated." }
4342
format.turbo_stream
4443
else
45-
format.html { render :edit, status: :unprocessable_entity }
46-
format.turbo_stream { render :form_update, status: :unprocessable_entity }
44+
format.html { render :edit, status: :unprocessable_content }
45+
format.turbo_stream { render :form_update, status: :unprocessable_content }
4746
end
4847
end
4948
end
@@ -64,7 +63,7 @@ def set_location
6463
end
6564

6665
def location_params
67-
params.require(:location).permit(:city, :state_province, :region, :country, :latitude, :longitude, :is_known_city)
66+
params.expect(location: %i[city state_province region country latitude longitude is_known_city])
6867
end
6968
end
70-
end
69+
end

app/controllers/admin/sessions_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Admin
22
class SessionsController < Admin::BaseController
3-
skip_before_action :authenticate_admin!, only: [:new, :create]
4-
skip_before_action :check_maintenance_mode, only: [:new, :create]
3+
skip_before_action :authenticate_admin!, only: %i[new create]
4+
skip_before_action :check_maintenance_mode, only: %i[new create]
55
layout "admin_login"
66

77
def new
@@ -18,7 +18,7 @@ def create
1818
redirect_to admin_streams_path, notice: "Successfully logged in."
1919
else
2020
flash.now[:alert] = "Invalid email or password, or insufficient privileges."
21-
render :new, status: :unprocessable_entity
21+
render :new, status: :unprocessable_content
2222
end
2323
end
2424

@@ -35,4 +35,4 @@ def current_admin_user
3535
@current_admin_user ||= current_user if current_user&.admin?
3636
end
3737
end
38-
end
38+
end

app/controllers/admin/streamers_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def create
3939
end
4040
else
4141
@users = User.order(:email)
42-
format.html { render :new, status: :unprocessable_entity }
43-
format.turbo_stream { render :new, status: :unprocessable_entity }
42+
format.html { render :new, status: :unprocessable_content }
43+
format.turbo_stream { render :new, status: :unprocessable_content }
4444
end
4545
end
4646
end
@@ -59,8 +59,8 @@ def update
5959
end
6060
else
6161
@users = User.order(:email)
62-
format.html { render :edit, status: :unprocessable_entity }
63-
format.turbo_stream { render :edit, status: :unprocessable_entity }
62+
format.html { render :edit, status: :unprocessable_content }
63+
format.turbo_stream { render :edit, status: :unprocessable_content }
6464
end
6565
end
6666
end

0 commit comments

Comments
 (0)