diff --git a/app/models/artist_commentary.rb b/app/models/artist_commentary.rb index 74d3c29eb..7742b9ffd 100644 --- a/app/models/artist_commentary.rb +++ b/app/models/artist_commentary.rb @@ -5,7 +5,7 @@ class ArtistCommentary < ApplicationRecord attr_accessor :add_commentary_tag, :add_commentary_request_tag, :add_commentary_check_tag, :add_partial_commentary_tag before_validation :trim_whitespace validates_uniqueness_of :post_id - belongs_to :post, required: true + belongs_to :post has_many :versions, -> {order("artist_commentary_versions.id ASC")}, :class_name => "ArtistCommentaryVersion", :dependent => :destroy, :foreign_key => :post_id, :primary_key => :post_id has_one :previous_version, -> {order(id: :desc)}, :class_name => "ArtistCommentaryVersion", :foreign_key => :post_id, :primary_key => :post_id after_save :create_version diff --git a/app/models/bulk_update_request.rb b/app/models/bulk_update_request.rb index 1f6c94c1a..a3315361a 100644 --- a/app/models/bulk_update_request.rb +++ b/app/models/bulk_update_request.rb @@ -141,10 +141,8 @@ class BulkUpdateRequest < ApplicationRecord module ValidationMethods def script_formatted_correctly AliasAndImplicationImporter.tokenize(script) - return true rescue StandardError => e errors[:base] << e.message - return false end def forum_topic_id_not_invalid @@ -157,11 +155,8 @@ class BulkUpdateRequest < ApplicationRecord begin AliasAndImplicationImporter.new(script, forum_topic_id, "1", skip_secondary_validations).validate! rescue RuntimeError => e - self.errors[:base] << e.message - return false + errors[:base] << e.message end - - errors.empty? end end diff --git a/app/models/comment.rb b/app/models/comment.rb index ee538b90d..4b604ef14 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -139,12 +139,8 @@ class Comment < ApplicationRecord def validate_creator_is_not_limited if creator.is_comment_limited? && !do_not_bump_post? errors.add(:base, "You can only post #{Danbooru.config.member_comment_limit} comments per hour") - false - elsif creator.can_comment? - true - else + elsif !creator.can_comment? errors.add(:base, "You can not post comments within 1 week of sign up") - false end end @@ -153,7 +149,6 @@ class Comment < ApplicationRecord if Comment.where("post_id = ?", post_id).count <= Danbooru.config.comment_threshold && !do_not_bump_post? Post.where(:id => post_id).update_all(:last_comment_bumped_at => created_at) end - true end def update_last_commented_at_on_destroy @@ -170,8 +165,6 @@ class Comment < ApplicationRecord else Post.where(:id => post_id).update_all(:last_comment_bumped_at => other_comments.first.created_at) end - - true end def below_threshold?(user = CurrentUser.user) diff --git a/app/models/comment_vote.rb b/app/models/comment_vote.rb index fa08641af..bda9a2db2 100644 --- a/app/models/comment_vote.rb +++ b/app/models/comment_vote.rb @@ -28,18 +28,12 @@ class CommentVote < ApplicationRecord def validate_user_can_vote if !user.can_comment_vote? errors.add :base, "You cannot vote on more than 10 comments per hour" - false - else - true end end def validate_comment_can_be_down_voted if is_positive? && comment.creator == CurrentUser.user errors.add :base, "You cannot upvote your own comments" - false - else - true end end diff --git a/app/models/dmail.rb b/app/models/dmail.rb index 971e3098e..2439a2370 100644 --- a/app/models/dmail.rb +++ b/app/models/dmail.rb @@ -214,9 +214,6 @@ class Dmail < ApplicationRecord def validate_sender_is_not_banned if from.try(:is_banned?) errors[:base] << "Sender is banned and cannot send messages" - return false - else - return true end end diff --git a/app/models/favorite_group.rb b/app/models/favorite_group.rb index 5f44e3b4e..93c35ca43 100644 --- a/app/models/favorite_group.rb +++ b/app/models/favorite_group.rb @@ -88,18 +88,12 @@ class FavoriteGroup < ApplicationRecord error += " Upgrade your account to create more." end self.errors.add(:base, error) - return false - else - return true end end def validate_number_of_posts if post_id_array.size > 10_000 self.errors.add(:base, "Favorite groups can have up to 10,000 posts each") - return false - else - return true end end diff --git a/app/models/forum_post.rb b/app/models/forum_post.rb index 6b101d1d4..c157c0285 100644 --- a/app/models/forum_post.rb +++ b/app/models/forum_post.rb @@ -146,7 +146,6 @@ class ForumPost < ApplicationRecord def topic_is_not_restricted if topic && !topic.visible?(creator) errors[:topic] << "is restricted" - return false end end @@ -238,8 +237,6 @@ class ForumPost < ApplicationRecord if is_deleted? && is_original_post? topic.update_attribute(:is_deleted, true) end - - true end def build_response diff --git a/app/models/note.rb b/app/models/note.rb index 7789695b3..d54dedb01 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -70,7 +70,6 @@ class Note < ApplicationRecord def post_must_not_be_note_locked if is_locked? errors.add :post, "is note locked" - return false end end @@ -78,7 +77,6 @@ class Note < ApplicationRecord return false unless post.present? if x < 0 || y < 0 || (x > post.image_width) || (y > post.image_height) || width < 0 || height < 0 || (x + width > post.image_width) || (y + height > post.image_height) self.errors.add(:note, "must be inside the image") - return false end end diff --git a/app/models/post_appeal.rb b/app/models/post_appeal.rb index 84027cca4..fbc3797d5 100644 --- a/app/models/post_appeal.rb +++ b/app/models/post_appeal.rb @@ -75,18 +75,12 @@ class PostAppeal < ApplicationRecord def validate_creator_is_not_limited if appeal_count_for_creator >= Danbooru.config.max_appeals_per_day errors[:creator] << "can appeal at most #{Danbooru.config.max_appeals_per_day} post a day" - false - else - true end end def validate_post_is_inactive if resolved? errors[:post] << "is active" - false - else - true end end diff --git a/app/models/post_disapproval.rb b/app/models/post_disapproval.rb index d0060cb2f..fd2e26676 100644 --- a/app/models/post_disapproval.rb +++ b/app/models/post_disapproval.rb @@ -1,7 +1,7 @@ class PostDisapproval < ApplicationRecord DELETION_THRESHOLD = 1.month - belongs_to :post, required: true + belongs_to :post belongs_to :user after_initialize :initialize_attributes, if: :new_record? validates_uniqueness_of :post_id, :scope => [:user_id], :message => "have already hidden this post" diff --git a/app/models/upload.rb b/app/models/upload.rb index 62997c802..49e99578c 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -255,10 +255,7 @@ class Upload < ApplicationRecord def uploader_is_not_limited if !uploader.can_upload? - self.errors.add(:uploader, uploader.upload_limited_reason) - return false - else - return true + errors.add(:uploader, uploader.upload_limited_reason) end end diff --git a/app/models/user.rb b/app/models/user.rb index 71e40959c..aeaaab861 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -117,8 +117,7 @@ class User < ApplicationRecord module BanMethods def validate_ip_addr_is_not_banned if IpBan.is_banned?(CurrentUser.ip_addr) - self.errors[:base] << "IP address is banned" - return false + errors[:base] << "IP address is banned" end end @@ -407,8 +406,6 @@ class User < ApplicationRecord if per_page.nil? || !is_gold? self.per_page = Danbooru.config.posts_per_page end - - return true end def level_class diff --git a/app/models/user_feedback.rb b/app/models/user_feedback.rb index 67d1843f0..1f8009783 100644 --- a/app/models/user_feedback.rb +++ b/app/models/user_feedback.rb @@ -100,21 +100,14 @@ class UserFeedback < ApplicationRecord def creator_is_gold if !creator.is_gold? errors[:creator] << "must be gold" - return false elsif creator.no_feedback? errors[:creator] << "cannot submit feedback" - return false - else - return true end end def user_is_not_creator if user_id == creator_id errors[:creator] << "cannot submit feedback for yourself" - return false - else - return true end end diff --git a/app/models/user_name_change_request.rb b/app/models/user_name_change_request.rb index 798ca73fc..46d9dd0b6 100644 --- a/app/models/user_name_change_request.rb +++ b/app/models/user_name_change_request.rb @@ -64,9 +64,6 @@ class UserNameChangeRequest < ApplicationRecord def not_limited if UserNameChangeRequest.where("user_id = ? and created_at >= ?", CurrentUser.user.id, 1.week.ago).exists? errors.add(:base, "You can only submit one name change request per week") - return false - else - return true end end diff --git a/app/models/user_password_reset_nonce.rb b/app/models/user_password_reset_nonce.rb index d1324969a..faf1c9d0c 100644 --- a/app/models/user_password_reset_nonce.rb +++ b/app/models/user_password_reset_nonce.rb @@ -15,7 +15,6 @@ class UserPasswordResetNonce < ApplicationRecord def validate_existence_of_email if !User.with_email(email).exists? errors[:email] << "is invalid" - return false end end diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index b1bff5770..8ab02896e 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -114,7 +114,6 @@ class WikiPage < ApplicationRecord def validate_not_locked if is_locked? && !CurrentUser.is_builder? errors.add(:is_locked, "and cannot be updated") - return false end end