rubocop: fix various style issues.
This commit is contained in:
@@ -16,14 +16,14 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
rescue_from Exception, :with => :rescue_exception
|
||||
|
||||
protected
|
||||
|
||||
def self.rescue_with(*klasses, status: 500)
|
||||
rescue_from *klasses do |exception|
|
||||
rescue_from(*klasses) do |exception|
|
||||
render_error_page(status, exception)
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def enable_cors
|
||||
response.headers["Access-Control-Allow-Origin"] = "*"
|
||||
end
|
||||
@@ -61,7 +61,7 @@ class ApplicationController < ActionController::Base
|
||||
when ActionController::RoutingError
|
||||
render_error_page(405, exception)
|
||||
when ActionController::UnknownFormat, ActionView::MissingTemplate
|
||||
render_error_page(406, exception, message: "#{request.format.to_s} is not a supported format for this page")
|
||||
render_error_page(406, exception, message: "#{request.format} is not a supported format for this page")
|
||||
when PaginationExtension::PaginationError
|
||||
render_error_page(410, exception, template: "static/pagination_error", message: "You cannot go beyond page #{Danbooru.config.max_numbered_pages}.")
|
||||
when Post::SearchError
|
||||
@@ -80,7 +80,7 @@ class ApplicationController < ActionController::Base
|
||||
def render_error_page(status, exception, message: exception.message, template: "static/error", format: request.format.symbol)
|
||||
@exception = exception
|
||||
@expected = status < 500
|
||||
@message = message.encode("utf-8", { invalid: :replace, undef: :replace })
|
||||
@message = message.encode("utf-8", invalid: :replace, undef: :replace)
|
||||
@backtrace = Rails.backtrace_cleaner.clean(@exception.backtrace)
|
||||
format = :html unless format.in?(%i[html json xml js atom])
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class ArtistCommentariesController < ApplicationController
|
||||
@artist_commentary.revert_to!(@version)
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def commentary_params
|
||||
params.fetch(:artist_commentary, {}).except(:post_id).permit(%i[
|
||||
|
||||
@@ -5,7 +5,7 @@ class ArtistUrlsController < ApplicationController
|
||||
def index
|
||||
@artist_urls = ArtistUrl.includes(:artist).paginated_search(params)
|
||||
respond_with(@artist_urls) do |format|
|
||||
format.json { render json: @artist_urls.to_json(include: "artist",) }
|
||||
format.json { render json: @artist_urls.to_json(include: "artist") }
|
||||
format.xml { render xml: @artist_urls.to_xml(include: "artist", root: "artist-urls") }
|
||||
end
|
||||
end
|
||||
@@ -16,7 +16,7 @@ class ArtistUrlsController < ApplicationController
|
||||
respond_with(@artist_url)
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def artist_url_params
|
||||
permitted_params = %i[is_active]
|
||||
|
||||
@@ -85,7 +85,7 @@ class ArtistsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def load_artist
|
||||
@artist = Artist.find(params[:id])
|
||||
|
||||
@@ -72,7 +72,8 @@ class CommentsController < ApplicationController
|
||||
respond_with(@comment)
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def index_for_post
|
||||
@post = Post.find(params[:post_id])
|
||||
@comments = @post.comments
|
||||
|
||||
@@ -3,8 +3,8 @@ class CountsController < ApplicationController
|
||||
|
||||
def posts
|
||||
@count = Post.fast_count(
|
||||
params[:tags],
|
||||
timeout: CurrentUser.statement_timeout,
|
||||
params[:tags],
|
||||
timeout: CurrentUser.statement_timeout,
|
||||
raise_on_timeout: true,
|
||||
skip_cache: params[:skip_cache]
|
||||
)
|
||||
|
||||
@@ -60,7 +60,7 @@ class DmailsController < ApplicationController
|
||||
@dmail.update_column(:is_spam, false)
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def check_privilege(dmail)
|
||||
if !dmail.visible_to?(CurrentUser.user, params[:key])
|
||||
|
||||
@@ -28,7 +28,8 @@ module Explore
|
||||
render :layout => "blank"
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def set_date
|
||||
@date = params[:date] ? Date.parse(params[:date]) : Date.today
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ class ForumPostVotesController < ApplicationController
|
||||
respond_with(@forum_post_vote)
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def forum_post_vote_params
|
||||
params.fetch(:forum_post_vote, {}).permit(:score)
|
||||
|
||||
@@ -4,10 +4,10 @@ class ForumPostsController < ApplicationController
|
||||
before_action :load_post, :only => [:edit, :show, :update, :destroy, :undelete]
|
||||
before_action :check_min_level, :only => [:edit, :show, :update, :destroy, :undelete]
|
||||
skip_before_action :api_check
|
||||
|
||||
|
||||
def new
|
||||
if params[:topic_id]
|
||||
@forum_topic = ForumTopic.find(params[:topic_id])
|
||||
@forum_topic = ForumTopic.find(params[:topic_id])
|
||||
raise User::PrivilegeError.new unless @forum_topic.visible?(CurrentUser.user)
|
||||
end
|
||||
if params[:post_id]
|
||||
@@ -66,7 +66,8 @@ class ForumPostsController < ApplicationController
|
||||
respond_with(@forum_post)
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def load_post
|
||||
@forum_post = ForumPost.find(params[:id])
|
||||
@forum_topic = @forum_post.topic
|
||||
|
||||
@@ -93,13 +93,12 @@ class ForumTopicsController < ApplicationController
|
||||
|
||||
def unsubscribe
|
||||
subscription = ForumSubscription.where(:forum_topic_id => @forum_topic.id, :user_id => CurrentUser.user.id).first
|
||||
if subscription
|
||||
subscription.destroy
|
||||
end
|
||||
subscription&.destroy
|
||||
respond_with(@forum_topic)
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def normalize_search
|
||||
if params[:title_matches]
|
||||
params[:search] ||= {}
|
||||
|
||||
@@ -5,13 +5,12 @@ class IpAddressesController < ApplicationController
|
||||
def index
|
||||
if search_params[:group_by] == "ip_addr"
|
||||
@ip_addresses = IpAddress.search(search_params).group_by_ip_addr(search_params[:ipv4_masklen], search_params[:ipv6_masklen]).paginate(params[:page], limit: params[:limit] || 1000)
|
||||
respond_with(@ip_addresses)
|
||||
elsif search_params[:group_by] == "user"
|
||||
@ip_addresses = IpAddress.includes(:user).search(search_params).group_by_user.paginate(params[:page], limit: params[:limit] || 1000)
|
||||
respond_with(@ip_addresses)
|
||||
else
|
||||
@ip_addresses = IpAddress.includes(:user, :model).paginated_search(params)
|
||||
respond_with(@ip_addresses)
|
||||
end
|
||||
|
||||
respond_with(@ip_addresses)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,7 +33,8 @@ class LegacyController < ApplicationController
|
||||
render :plain => "this resource is no longer available", :status => 410
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def tag_query
|
||||
params[:tags] || (params[:post] && params[:post][:tags])
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module Maintenance
|
||||
module User
|
||||
class EmailNotificationsController < ApplicationController
|
||||
class VerificationError < Exception ; end
|
||||
class VerificationError < Exception; end
|
||||
|
||||
before_action :validate_sig, :only => [:destroy]
|
||||
rescue_from VerificationError, :with => :render_403
|
||||
@@ -15,7 +15,7 @@ module Maintenance
|
||||
@user.save
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def render_403
|
||||
render plain: "", :status => 403
|
||||
|
||||
@@ -2,7 +2,7 @@ module Moderator
|
||||
module Post
|
||||
class QueuesController < ApplicationController
|
||||
RANDOM_COUNT = 12
|
||||
|
||||
|
||||
respond_to :html, :json
|
||||
before_action :approver_only
|
||||
skip_before_action :api_check
|
||||
@@ -38,7 +38,7 @@ module Moderator
|
||||
respond_with(@posts)
|
||||
end
|
||||
|
||||
protected
|
||||
protected
|
||||
|
||||
def per_page
|
||||
cookies["mq_per_page"] || search_params[:per_page] || 25
|
||||
|
||||
@@ -27,7 +27,8 @@ class PoolElementsController < ApplicationController
|
||||
@pools
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def append_pool_to_session(pool)
|
||||
recent_pool_ids = session[:recent_pool_ids].to_s.scan(/\d+/)
|
||||
recent_pool_ids << pool.id.to_s
|
||||
|
||||
@@ -22,7 +22,7 @@ class PoolVersionsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def set_timeout
|
||||
PoolArchive.connection.execute("SET statement_timeout = #{CurrentUser.user.statement_timeout}")
|
||||
|
||||
@@ -23,13 +23,14 @@ class PostReplacementsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
params[:search][:post_id] = params.delete(:post_id) if params.has_key?(:post_id)
|
||||
params[:search][:post_id] = params.delete(:post_id) if params.key?(:post_id)
|
||||
@post_replacements = PostReplacement.paginated_search(params)
|
||||
|
||||
respond_with(@post_replacements)
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def create_params
|
||||
params.require(:post_replacement).permit(:replacement_url, :replacement_file, :final_source, :tags)
|
||||
end
|
||||
|
||||
@@ -58,7 +58,7 @@ class PostsController < ApplicationController
|
||||
if @post.visible?
|
||||
@post.revert_to!(@version)
|
||||
end
|
||||
|
||||
|
||||
respond_with(@post) do |format|
|
||||
format.js
|
||||
end
|
||||
@@ -68,7 +68,7 @@ class PostsController < ApplicationController
|
||||
@post = Post.find(params[:id])
|
||||
@other_post = Post.find(params[:other_post_id].to_i)
|
||||
@post.copy_notes_to(@other_post)
|
||||
|
||||
|
||||
if @post.errors.any?
|
||||
@error_message = @post.errors.full_messages.join("; ")
|
||||
render :json => {:success => false, :reason => @error_message}.to_json, :status => 400
|
||||
@@ -91,7 +91,7 @@ class PostsController < ApplicationController
|
||||
respond_with_post_after_update(@post)
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def tag_query
|
||||
params[:tags] || (params[:post] && params[:post][:tags])
|
||||
@@ -109,7 +109,7 @@ private
|
||||
render :template => "static/error", :status => 500
|
||||
else
|
||||
response_params = {:q => params[:tags_query], :pool_id => params[:pool_id], :favgroup_id => params[:favgroup_id]}
|
||||
response_params.reject!{|key, value| value.blank?}
|
||||
response_params.reject! {|key, value| value.blank?}
|
||||
redirect_to post_path(post, response_params)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,6 +28,6 @@ class SessionsController < ApplicationController
|
||||
end
|
||||
|
||||
def sign_out
|
||||
destroy()
|
||||
destroy
|
||||
end
|
||||
end
|
||||
|
||||
@@ -40,7 +40,7 @@ class TagAliasesController < ApplicationController
|
||||
respond_with(@tag_alias, :location => tag_alias_path(@tag_alias))
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def tag_alias_params
|
||||
params.require(:tag_alias).permit(%i[antecedent_name consequent_name forum_topic_id skip_secondary_validations])
|
||||
|
||||
@@ -40,7 +40,7 @@ class TagImplicationsController < ApplicationController
|
||||
respond_with(@tag_implication, :location => tag_implication_path(@tag_implication))
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def tag_implication_params
|
||||
params.require(:tag_implication).permit(%i[antecedent_name consequent_name forum_topic_id skip_secondary_validations])
|
||||
|
||||
@@ -37,7 +37,8 @@ class TagsController < ApplicationController
|
||||
respond_with(@tag)
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def check_privilege(tag)
|
||||
raise User::PrivilegeError unless tag.editable_by?(CurrentUser.user)
|
||||
end
|
||||
|
||||
@@ -99,7 +99,7 @@ class UsersController < ApplicationController
|
||||
private
|
||||
|
||||
def check_privilege(user)
|
||||
raise User::PrivilegeError unless (user.id == CurrentUser.id || CurrentUser.is_admin?)
|
||||
raise User::PrivilegeError unless user.id == CurrentUser.id || CurrentUser.is_admin?
|
||||
end
|
||||
|
||||
def user_params(context)
|
||||
|
||||
@@ -10,7 +10,7 @@ class WikiPagesController < ApplicationController
|
||||
end
|
||||
|
||||
def edit
|
||||
@wiki_page, _ = WikiPage.find_by_id_or_title(params[:id])
|
||||
@wiki_page, _found_by = WikiPage.find_by_id_or_title(params[:id])
|
||||
respond_with(@wiki_page)
|
||||
end
|
||||
|
||||
@@ -49,7 +49,7 @@ class WikiPagesController < ApplicationController
|
||||
end
|
||||
|
||||
def update
|
||||
@wiki_page, _ = WikiPage.find_by_id_or_title(params[:id])
|
||||
@wiki_page, _found_by = WikiPage.find_by_id_or_title(params[:id])
|
||||
@wiki_page.update(wiki_page_params(:update))
|
||||
flash[:notice] = @wiki_page.warnings.full_messages.join(".\n \n") if @wiki_page.warnings.any?
|
||||
|
||||
@@ -57,13 +57,13 @@ class WikiPagesController < ApplicationController
|
||||
end
|
||||
|
||||
def destroy
|
||||
@wiki_page, _ = WikiPage.find_by_id_or_title(params[:id])
|
||||
@wiki_page, _found_by = WikiPage.find_by_id_or_title(params[:id])
|
||||
@wiki_page.update(is_deleted: true)
|
||||
respond_with(@wiki_page)
|
||||
end
|
||||
|
||||
def revert
|
||||
@wiki_page, _ = WikiPage.find_by_id_or_title(params[:id])
|
||||
@wiki_page, _found_by = WikiPage.find_by_id_or_title(params[:id])
|
||||
@version = @wiki_page.versions.find(params[:version_id])
|
||||
@wiki_page.revert_to!(@version)
|
||||
flash[:notice] = "Page was reverted"
|
||||
|
||||
Reference in New Issue
Block a user