rubocop: fix various style issues.

This commit is contained in:
evazion
2019-12-22 16:21:58 -06:00
parent 09f6a84660
commit 309821bf73
288 changed files with 912 additions and 962 deletions

View File

@@ -2,8 +2,8 @@ require 'digest/sha1'
require 'danbooru/has_bit_flags'
class User < ApplicationRecord
class Error < Exception ; end
class PrivilegeError < Exception ; end
class Error < Exception; end
class PrivilegeError < Exception; end
module Levels
ANONYMOUS = 0
@@ -20,7 +20,7 @@ class User < ApplicationRecord
:banned,
:approver,
:voter,
:super_voter,
:super_voter
]
# candidates for removal:
@@ -199,7 +199,7 @@ class User < ApplicationRecord
end
def reset_password_and_deliver_notice
new_password = reset_password()
new_password = reset_password
Maintenance::User::PasswordResetMailer.confirmation(self, new_password).deliver_now
end
end
@@ -296,7 +296,7 @@ class User < ApplicationRecord
when Levels::ADMIN
"Admin"
else
""
end
@@ -570,23 +570,23 @@ class User < ApplicationRecord
module ApiMethods
def api_attributes
attributes = [
:id, :created_at, :name, :inviter_id, :level, :base_upload_limit,
:post_upload_count, :post_update_count, :note_update_count, :is_banned,
:can_approve_posts, :can_upload_free, :is_super_voter, :level_string,
attributes = %i[
id created_at name inviter_id level base_upload_limit
post_upload_count post_update_count note_update_count is_banned
can_approve_posts can_upload_free is_super_voter level_string
]
if id == CurrentUser.user.id
attributes += BOOLEAN_ATTRIBUTES
attributes += [
:updated_at, :email, :last_logged_in_at, :last_forum_read_at,
:comment_threshold, :default_image_size,
:favorite_tags, :blacklisted_tags, :time_zone, :per_page,
:custom_style, :favorite_count, :api_regen_multiplier,
:api_burst_limit, :remaining_api_limit, :statement_timeout,
:favorite_group_limit, :favorite_limit, :tag_query_limit,
:can_comment_vote?, :can_remove_from_pools?, :is_comment_limited?,
:can_comment?, :can_upload?, :max_saved_searches, :theme
attributes += %i[
updated_at email last_logged_in_at last_forum_read_at
comment_threshold default_image_size
favorite_tags blacklisted_tags time_zone per_page
custom_style favorite_count api_regen_multiplier
api_burst_limit remaining_api_limit statement_timeout
favorite_group_limit favorite_limit tag_query_limit
can_comment_vote? can_remove_from_pools? is_comment_limited?
can_comment? can_upload? max_saved_searches theme
]
end
@@ -595,13 +595,13 @@ class User < ApplicationRecord
# extra attributes returned for /users/:id.json but not for /users.json.
def full_attributes
[
:wiki_page_version_count, :artist_version_count,
:artist_commentary_version_count, :pool_version_count,
:forum_post_count, :comment_count, :favorite_group_count,
:appeal_count, :flag_count, :positive_feedback_count,
:neutral_feedback_count, :negative_feedback_count, :upload_limit,
:max_upload_limit
%i[
wiki_page_version_count artist_version_count
artist_commentary_version_count pool_version_count
forum_post_count comment_count favorite_group_count
appeal_count flag_count positive_feedback_count
neutral_feedback_count negative_feedback_count upload_limit
max_upload_limit
]
end
@@ -731,10 +731,10 @@ class User < ApplicationRecord
if params[x].present?
attr_idx = BOOLEAN_ATTRIBUTES.index(x.to_s)
if params[x].to_s.truthy?
bitprefs_include ||= "0"*bitprefs_length
bitprefs_include ||= "0" * bitprefs_length
bitprefs_include[attr_idx] = '1'
elsif params[x].to_s.falsy?
bitprefs_exclude ||= "0"*bitprefs_length
bitprefs_exclude ||= "0" * bitprefs_length
bitprefs_exclude[attr_idx] = '1'
end
end
@@ -743,13 +743,13 @@ class User < ApplicationRecord
if bitprefs_include
bitprefs_include.reverse!
q = q.where("bit_prefs::bit(:len) & :bits::bit(:len) = :bits::bit(:len)",
{:len => bitprefs_length, :bits => bitprefs_include})
:len => bitprefs_length, :bits => bitprefs_include)
end
if bitprefs_exclude
bitprefs_exclude.reverse!
q = q.where("bit_prefs::bit(:len) & :bits::bit(:len) = 0::bit(:len)",
{:len => bitprefs_length, :bits => bitprefs_exclude})
:len => bitprefs_length, :bits => bitprefs_exclude)
end
if params[:current_user_first].to_s.truthy? && !CurrentUser.is_anonymous?