Updated

app/controllers/api/v1/accounts / deals_controller.rb

B
48 lines of codes
5 methods
9.8 complexity/method
20 churn
49.2 complexity
69 duplications
class Api::V1::Accounts::DealsController < Api::V1::InternalController
  1. Api::V1::Accounts::DealsController assumes too much for instance variable '@deal'
  2. Api::V1::Accounts::DealsController has no descriptive comment
include DealConcern def show @deal = Deal.find(params['id']) if @deal render json: @deal, include: %i[contact stage pipeline deal_assignees deal_products], status: :ok else render json: { errors: 'Not found' }, status: :not_found end end def create @deal = DealBuilder.new(current_user, deal_params).perform if Deal::CreateOrUpdate.new(@deal, deal_params).call
  1. Similar code found in 3 nodes Locations: 0 1 2
  2. Api::V1::Accounts::DealsController tests 'Deal::CreateOrUpdate.new(@deal, deal_params).call' at least 3 times Locations: 0 1 2
render json: @deal, status: :created else render json: { errors: @deal.errors.full_messages }, status: :unprocessable_entity end end def upsert @deal = Deal.where( contact_id: params['contact_id'] ).first_or_initialize if Deal::CreateOrUpdate.new(@deal, deal_params).call
  1. Similar code found in 3 nodes Locations: 0 1 2
  2. Api::V1::Accounts::DealsController tests 'Deal::CreateOrUpdate.new(@deal, deal_params).call' at least 3 times Locations: 0 1 2
render json: @deal, status: :ok else render json: { errors: @deal.errors.full_messages }, status: :unprocessable_entity end end def update @deal = Deal.find(params['id']) if Deal::CreateOrUpdate.new(@deal, deal_params).call
  1. Similar code found in 3 nodes Locations: 0 1 2
  2. Api::V1::Accounts::DealsController tests 'Deal::CreateOrUpdate.new(@deal, deal_params).call' at least 3 times Locations: 0 1 2
render json: @deal, status: :ok else render json: { errors: @deal.errors.full_messages }, status: :unprocessable_entity end end def deal_params params.permit(*permitted_deal_params) end end