Updated

app/controllers/admin/archived / signatures_controller.rb

D
82 lines of codes
10 methods
7.5 complexity/method
4 churn
75.42 complexity
141 duplications
class Admin::Archived::SignaturesController < Admin::AdminController
  1. Admin::Archived::SignaturesController assumes too much for instance variable '@signature'
  2. Admin::Archived::SignaturesController has no descriptive comment
include BulkVerification before_action :fetch_signature, except: [:index, :bulk_subscribe, :bulk_unsubscribe, :bulk_destroy] before_action :fetch_signatures, only: [:index] helper_method :search_params def index respond_to do |format| format.html end end def bulk_destroy
  1. Similar code found in 3 nodes Locations: 0 1 2
begin ::Archived::Signature.destroy!(selected_ids) redirect_to admin_archived_signatures_url(search_params), notice: :signatures_deleted
  1. Admin::Archived::SignaturesController#bulk_destroy calls 'admin_archived_signatures_url(search_params)' 2 times Locations: 0 1
rescue StandardError => e
  1. Admin::Archived::SignaturesController#bulk_destroy has the variable name 'e'
Appsignal.send_exception e redirect_to admin_archived_signatures_url(search_params), alert: :signatures_not_deleted
  1. Admin::Archived::SignaturesController#bulk_destroy calls 'admin_archived_signatures_url(search_params)' 2 times Locations: 0 1
end end def destroy
  1. Similar code found in 2 nodes Locations: 0 1
if @signature.destroy redirect_to admin_archived_signatures_url(search_params), notice: :signature_deleted
  1. Admin::Archived::SignaturesController#destroy calls 'admin_archived_signatures_url(search_params)' 2 times Locations: 0 1
else redirect_to admin_archived_signatures_url(search_params), alert: :signature_not_deleted
  1. Admin::Archived::SignaturesController#destroy calls 'admin_archived_signatures_url(search_params)' 2 times Locations: 0 1
end end def bulk_subscribe
  1. Similar code found in 3 nodes Locations: 0 1 2
begin ::Archived::Signature.subscribe!(selected_ids) redirect_to admin_archived_signatures_url(search_params), notice: :signatures_subscribed
  1. Admin::Archived::SignaturesController#bulk_subscribe calls 'admin_archived_signatures_url(search_params)' 2 times Locations: 0 1
rescue StandardError => e
  1. Admin::Archived::SignaturesController#bulk_subscribe has the variable name 'e'
Appsignal.send_exception e redirect_to admin_archived_signatures_url(search_params), alert: :signatures_not_subscribed
  1. Admin::Archived::SignaturesController#bulk_subscribe calls 'admin_archived_signatures_url(search_params)' 2 times Locations: 0 1
end end def subscribe
  1. Similar code found in 2 nodes Locations: 0 1
if @signature.update(notify_by_email: true) redirect_to admin_archived_signatures_url(search_params), notice: :signature_subscribed
  1. Admin::Archived::SignaturesController#subscribe calls 'admin_archived_signatures_url(search_params)' 2 times Locations: 0 1
else redirect_to admin_archived_signatures_url(search_params), alert: :signature_not_subscribed
  1. Admin::Archived::SignaturesController#subscribe calls 'admin_archived_signatures_url(search_params)' 2 times Locations: 0 1
end end def bulk_unsubscribe
  1. Similar code found in 3 nodes Locations: 0 1 2
begin ::Archived::Signature.unsubscribe!(selected_ids) redirect_to admin_archived_signatures_url(search_params), notice: :signatures_unsubscribed
  1. Admin::Archived::SignaturesController#bulk_unsubscribe calls 'admin_archived_signatures_url(search_params)' 2 times Locations: 0 1
rescue StandardError => e
  1. Admin::Archived::SignaturesController#bulk_unsubscribe has the variable name 'e'
Appsignal.send_exception e redirect_to admin_archived_signatures_url(search_params), alert: :signatures_not_unsubscribed
  1. Admin::Archived::SignaturesController#bulk_unsubscribe calls 'admin_archived_signatures_url(search_params)' 2 times Locations: 0 1
end end def unsubscribe
  1. Similar code found in 2 nodes Locations: 0 1
if @signature.update(notify_by_email: false) redirect_to admin_archived_signatures_url(search_params), notice: :signature_unsubscribed
  1. Admin::Archived::SignaturesController#unsubscribe calls 'admin_archived_signatures_url(search_params)' 2 times Locations: 0 1
else redirect_to admin_archived_signatures_url(search_params), alert: :signature_not_unsubscribed
  1. Admin::Archived::SignaturesController#unsubscribe calls 'admin_archived_signatures_url(search_params)' 2 times Locations: 0 1
end end private def fetch_signatures @signatures = ::Archived::Signature.search(params[:q], search_params) end def fetch_signature @signature = ::Archived::Signature.find(params[:id]) end def search_params params.slice(:q, :page, :state, :window) end end