Updated

app/controllers/accounts/settings / webhooks_controller.rb

D
51 lines of codes
8 methods
7.3 complexity/method
9 churn
58.32 complexity
54 duplications
class Accounts::Settings::WebhooksController < InternalController
  1. Accounts::Settings::WebhooksController assumes too much for instance variable '@webhook'
  2. Accounts::Settings::WebhooksController assumes too much for instance variable '@webhooks'
  3. Accounts::Settings::WebhooksController has no descriptive comment
before_action :set_webhook, only: %i[edit update destroy] def index @webhooks = current_user.account.webhooks @pagy, @webhooks = pagy(@webhooks) end def new @webhook = Webhook.new end def create
  1. Similar code found in 3 nodes Locations: 0 1 2
@webhook = current_user.account.webhooks.new(webhook_params)
  1. Accounts::Settings::WebhooksController#create calls 'current_user.account' 2 times Locations: 0 1
if @webhook.save redirect_to account_webhooks_path(current_user.account),
  1. Accounts::Settings::WebhooksController#create calls 'current_user.account' 2 times Locations: 0 1
notice: t('flash_messages.created', model: Webhook.model_name.human) else render :new, status: :unprocessable_entity end end def edit; end def update
  1. Similar code found in 3 nodes Locations: 0 1 2
if @webhook.update(webhook_params) redirect_to edit_account_webhook_path(current_user.account, @webhook), notice: t('flash_messages.updated', model: Webhook.model_name.human) else render :edit, status: :unprocessable_entity end end def destroy if @webhook.destroy flash[:notice] = t('flash_messages.deleted', model: Webhook.model_name.human) else render :index, status: :unprocessable_entity end end private def set_webhook @webhook = current_user.account.webhooks.find(params[:id]) end def webhook_params params.require(:webhook).permit(:url, :status) end end