app/controllers/parents_controller.rb
# File name: parents_controller.rb# Class name: ParentsController# Description: Controller used to communicate with the view highways/showClass has too many lines. [110/100]
ParentsController assumes too much for instance variable '@parent'
ParentsController assumes too much for instance variable '@user'
ParentsController assumes too much for instance variable '@parents'class ParentsController < ApplicationController include SessionsHelper Assignment Branch Condition size for index is too high. [26.27/15]
Method has too many lines. [20/10]
Cyclomatic complexity for index is too high. [5/3]
Method `index` has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
ParentsController#index has approx 10 statements def indexSpace inside parentheses detected.
Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if ( is_employee? )ParentsController#index calls 'Parent.all' 3 times @parents = Parent.allParentsController#index calls 'params[:search]' 3 times if params[:search] string_to_search = params[:search].strip.upcase!Prefer single-quoted strings when you don't need string interpolation or special symbols. puts "AQUI TEM O PARENT" puts string_to_searchPrefer single-quoted strings when you don't need string interpolation or special symbols. @parents = Parent.search(string_to_search).order("created_at DESC")Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call. if (@parents.empty?)ParentsController#index calls 'flash.now' 2 times
Prefer single-quoted strings when you don't need string interpolation or special symbols. flash.now[:feedback] = "Nenhum secretário(a) encontrado!" end if params[:search].blank?ParentsController#index calls 'Parent.all.order('created_at DESC')' 2 times @parents = Parent.all.order('created_at DESC')Prefer single-quoted strings when you don't need string interpolation or special symbols. flash.now[:feedback_warning] = "Digite algo para pesquisar!" end else @parents = Parent.all.order('created_at DESC') end elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end Cyclomatic complexity for show is too high. [4/3] def show id = params[:id] Don't use parentheses around the condition of an `if`.
Space inside parentheses detected.
Use `||` instead of `or`. if ( is_employee? or verify_parent(id) or is_related?(id) ) @parent = Parent.find(id) elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end def newParentsController tests '( is_principal? )' at least 7 times
Space inside parentheses detected.
Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if ( is_principal? ) @parent = Parent.new elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end def editSpace inside parentheses detected.
Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if ( is_principal? ) @parent = Parent.find(params[:id]) elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end Method has too many lines. [11/10] def createSpace inside parentheses detected.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call. if ( is_principal? ) @parent = Parent.new(parent_params) Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if (@parent.save)Prefer single-quoted strings when you don't need string interpolation or special symbols. flash[:success] = "Responsável criado(a) com sucesso" redirect_to new_parent_alumn_path(@parent) else render 'new' end elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end Method has too many lines. [11/10] def updateSpace inside parentheses detected.
Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if ( is_principal? ) @parent = Parent.find(params[:id])Space inside parentheses detected.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call. if ( @parent.update(parent_params) )Prefer single-quoted strings when you don't need string interpolation or special symbols. flash[:notice] = "Responsável alterado(a) com sucesso" redirect_to @parent else render 'edit' end elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end def destroyDon't use parentheses around the condition of an `if`.
Space inside parentheses detected.
Don't use parentheses around a method call. if ( is_principal? ) @parent = Parent.find(params[:id]) @parent.destroyPrefer single-quoted strings when you don't need string interpolation or special symbols. flash[:alert] = "Responsável excluĂdo(a) com sucesso" redirect_to users_path elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end def edit_password_parentDon't use parentheses around a method call.
Space inside parentheses detected.
Don't use parentheses around the condition of an `if`. if ( is_principal? ) @user = Parent.find(params[:id])Prefer single-quoted strings when you don't need string interpolation or special symbols. render action: "../users/edit_password" elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end def update_password_parentSpace inside parentheses detected.
Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if ( is_principal? ) @user = Parent.find(params[:id])Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call. if (@user.update!(parent_params)) redirect_to @user elsePrefer single-quoted strings when you don't need string interpolation or special symbols. render action: "../users/edit_password" end elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end Keep a blank line before and after `private`. private def parent_params params.require(:parent).permit(:parent_cpf, :name, :address, :phone, :gender, :birth_date) endend