rubocop: fix various Rubocop warnings.

This commit is contained in:
evazion
2021-06-16 18:24:42 -05:00
parent cfe471e0b5
commit 07e23204b6
99 changed files with 412 additions and 374 deletions

View File

@@ -24,7 +24,7 @@ class ApiKeyPolicy < ApplicationPolicy
end
def permitted_attributes
[:name, :permitted_ip_addresses, permissions: []]
[:name, :permitted_ip_addresses, { permissions: [] }]
end
def api_attributes

View File

@@ -69,7 +69,7 @@ class ApplicationPolicy
# The list of attributes that are permitted to be returned by the API.
def api_attributes
# XXX allow inet
record.class.attribute_types.reject { |name, attr| attr.type.in?([:inet, :tsvector]) }.keys.map(&:to_sym)
record.class.attribute_types.reject { |_name, attr| attr.type.in?([:inet, :tsvector]) }.keys.map(&:to_sym)
end
# The list of attributes that are permitted to be used as data-* attributes

View File

@@ -16,6 +16,6 @@ class FavoriteGroupPolicy < ApplicationPolicy
end
def permitted_attributes
[:name, :post_ids_string, :is_public, :post_ids, post_ids: []]
[:name, :post_ids_string, :is_public, :post_ids, { post_ids: [] }]
end
end

View File

@@ -34,7 +34,7 @@ class ForumTopicPolicy < ApplicationPolicy
def permitted_attributes
[
:title, :category_id, { original_post_attributes: [:id, :body] },
([:is_sticky, :is_locked, :min_level] if moderate?)
([:is_sticky, :is_locked, :min_level] if moderate?),
].compact.flatten
end

View File

@@ -20,7 +20,7 @@ class PoolPolicy < ApplicationPolicy
end
def permitted_attributes
[:name, :description, :category, :post_ids, :post_ids_string, post_ids: []]
[:name, :description, :category, :post_ids, :post_ids_string, { post_ids: [] }]
end
def api_attributes

View File

@@ -8,12 +8,14 @@ class PostReplacementPolicy < ApplicationPolicy
end
def permitted_attributes_for_create
[:replacement_url, :replacement_file, :final_source, :tags]
%i[replacement_url replacement_file final_source tags]
end
def permitted_attributes_for_update
[:old_file_ext, :old_file_size, :old_image_width, :old_image_height,
:old_md5, :file_ext, :file_size, :image_width, :image_height, :md5,
:original_url, :replacement_url]
%i[
old_file_ext old_file_size old_image_width old_image_height old_md5
file_ext file_size image_width image_height md5 original_url
replacement_url
]
end
end

View File

@@ -36,15 +36,15 @@ class UserPolicy < ApplicationPolicy
end
def permitted_attributes_for_update
[
:comment_threshold, :default_image_size, :favorite_tags,
:blacklisted_tags, :time_zone, :per_page, :custom_style, :theme,
:receive_email_notifications, :always_resize_images,
:new_post_navigation_layout, :enable_private_favorites,
:hide_deleted_posts, :style_usernames, :show_deleted_children,
:disable_categorized_saved_searches, :disable_tagged_filenames,
:disable_cropped_thumbnails, :disable_mobile_gestures, :enable_safe_mode,
:enable_desktop_mode, :disable_post_tooltips,
%i[
comment_threshold default_image_size favorite_tags
blacklisted_tags time_zone per_page custom_style theme
receive_email_notifications always_resize_images
new_post_navigation_layout enable_private_favorites
hide_deleted_posts style_usernames show_deleted_children
disable_categorized_saved_searches disable_tagged_filenames
disable_cropped_thumbnails disable_mobile_gestures enable_safe_mode
enable_desktop_mode disable_post_tooltips
].compact
end