diff --git a/.rubocop.yml b/.rubocop.yml index 73506c13e2dd7f9562738fefee43d88a25318ba3..d84c1b13de0b20cbece3b73fb78804121a5ac7b8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -27,7 +27,7 @@ Lint/StructNewOverride: Enabled: true Metrics/AbcSize: - Max: 50 + Enabled: false Metrics/BlockLength: Max: 30 Metrics/ClassLength: diff --git a/app/controllers/advertisement_controller.rb b/app/controllers/advertisement_controller.rb index 579f9aaf3241492f88ec66353641469cf87c6437..8477c2b483863daaa8b40406a381064101e1fcfe 100644 --- a/app/controllers/advertisement_controller.rb +++ b/app/controllers/advertisement_controller.rb @@ -3,7 +3,6 @@ require 'rmagick' # Neccessary due to rmagick # rubocop:disable Metrics/ClassLength # rubocop:disable Metrics/MethodLength -# rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/BlockLength class AdvertisementController < ApplicationController include Magick @@ -359,5 +358,5 @@ class AdvertisementController < ApplicationController end # rubocop:enable Metrics/MethodLength # rubocop:enable Metrics/ClassLength -# rubocop:enable Metrics/AbcSize + # rubocop:enable Metrics/BlockLength diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 908e23793bc3b2535fa6f84618753a7e0cdcb781..27cadcfd68c92b33c7c73b7adc3eb3f8b6651a49 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -49,7 +49,6 @@ class UsersController < ApplicationController end end - # rubocop:disable Metrics/AbcSize def activity @posts = Post.undeleted.where(user: @user).count @comments = Comment.undeleted.where(user: @user).where(post: Post.undeleted).count @@ -118,7 +117,6 @@ class UsersController < ApplicationController render layout: 'without_sidebar' end - # rubocop:enable Metrics/AbcSize def destroy if @user.votes.count > 100 diff --git a/app/controllers/votes_controller.rb b/app/controllers/votes_controller.rb index a751c84a53e942676017defcc86c194eaf4fa21b..5b82097176753705952306ebc61da1ca6fdf8be7 100644 --- a/app/controllers/votes_controller.rb +++ b/app/controllers/votes_controller.rb @@ -13,16 +13,18 @@ class VotesController < ApplicationController recent_votes = Vote.where(created_at: 24.hours.ago..Time.now, user: current_user).count max_votes_per_day = SiteSetting['FreeVotes'] + (@current_user.reputation - SiteSetting['NewUserInitialRep']) - if recent_votes >= max_votes_per_day - vote_limit_msg = 'You have used your daily vote limit of ' + recent_votes.to_s + 'votes. Gain more reputation' \ - ' or come back tomorrow to continue voting.' + unless post.parent&.user_id == current_user.id + if recent_votes >= max_votes_per_day + vote_limit_msg = 'You have used your daily vote limit of ' + recent_votes.to_s + 'votes. Gain more reputation' \ + ' or come back tomorrow to continue voting.' - if max_votes_per_day <= 0 - vote_limit_msg = 'You need to gain some reputation on this site before you can start voting.' - end + if max_votes_per_day <= 0 + vote_limit_msg = 'You need to gain some reputation on this site before you can start voting.' + end - render json: { status: 'failed', message: vote_limit_msg }, status: 403 - return + render json: { status: 'failed', message: vote_limit_msg }, status: 403 + return + end end destroyed = post.votes.where(user: current_user).destroy_all