Updated

app/controllers/accounts / apps_controller.rb

C
65 lines of codes
8 methods
8.7 complexity/method
4 churn
69.23 complexity
76 duplications
class Accounts::AppsController < InternalController
  1. Accounts::AppsController assumes too much for instance variable '@apps'
  2. Accounts::AppsController assumes too much for instance variable '@contact'
  3. Accounts::AppsController has no descriptive comment
before_action :set_contact, only: %i[show edit update destroy] # GET /contacts or /contacts.json def index @apps = current_user.account.apps @pagy, @apps = pagy(@apps) end # GET /contacts/new def new @contact = Contact.new end # GET /contacts/1/edit def edit; end # POST /contacts or /contacts.json def create
  1. Similar code found in 2 nodes Locations: 0 1
@contact = current_user.account.contacts.new(contact_params)
  1. Accounts::AppsController#create calls 'current_user.account' 2 times Locations: 0 1
if @contact.save redirect_to account_contact_path(current_user.account, @contact),
  1. Accounts::AppsController#create calls 'current_user.account' 2 times Locations: 0 1
notice: t('flash_messages.created', model: Contact.model_name.human) else render :new, status: :unprocessable_entity end end # PATCH/PUT /contacts/1 or /contacts/1.json def update
  1. Accounts::AppsController#update has approx 6 statements
respond_to do |format| if @contact.update(contact_params) redirect_to account_contact_path(current_user.account, @contact), notice: t('flash_messages.updated', model: Contact.model_name.human) else format.html { render :edit, status: :unprocessable_entity }
  1. Similar code found in 2 nodes Locations: 0 1
format.json { render json: @contact.errors, status: :unprocessable_entity } end end end # DELETE /contacts/1 or /contacts/1.json def destroy
  1. Similar code found in 2 nodes Locations: 0 1
  2. Accounts::AppsController#destroy has approx 6 statements
@contact.destroy respond_to do |format| format.html do redirect_to contacts_url, notice: t('flash_messages.deleted', model: Contact.model_name.human) end format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_contact @contact = Contact.find(params[:id]) end # Only allow a list of trusted parameters through. def contact_params params.require(:contact).permit(:full_name, :phone, :email, custom_attributes: {}) end end