Updated

app/controllers/admin / rate_limits_controller.rb

A
41 lines of codes
5 methods
4.1 complexity/method
11 churn
20.41 complexity
24 duplications
class Admin::RateLimitsController < Admin::AdminController
  1. Admin::RateLimitsController assumes too much for instance variable '@rate_limit'
  2. Admin::RateLimitsController has no descriptive comment
before_action :require_sysadmin before_action :find_rate_limit def edit respond_to do |format| format.html end end def update
  1. Similar code found in 2 nodes Locations: 0 1
if @rate_limit.update(rate_limit_params) redirect_to edit_admin_rate_limits_url(tab: params[:tab]), notice: :rate_limits_updated else respond_to do |format| format.html { render :edit } end end end private def rate_limit_params params.require(:rate_limit).permit(*rate_limit_attributes) end def rate_limit_attributes %i[ burst_rate burst_period sustained_rate sustained_period allowed_domains allowed_ips blocked_domains blocked_ips geoblocking_enabled countries country_rate_limits_enabled country_burst_rate country_sustained_rate trending_items_notification_url threshold_for_logging_trending_items threshold_for_notifying_trending_items enable_logging_of_trending_items ignored_domains threshold_for_form_entry ] end def find_rate_limit @rate_limit = RateLimit.first_or_create! end end