app/controllers/secretaries_controller.rb
# File name: secretaries_controller.rb# Class name: SecretariesControllerLine is too long. [86/80]# Description: Controller used to communicate with the proprietary view of secretariesSecretariesController assumes too much for instance variable '@secretaries'
SecretariesController assumes too much for instance variable '@secretary'class SecretariesController < ApplicationControllerTab detected.
Use 2 (not 1) spaces for indentation. include SessionsHelper Assignment Branch Condition size for index is too high. [24.37/15]
Method has too many lines. [18/10]
Cyclomatic complexity for index is too high. [5/3]
Method `index` has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
SecretariesController#index has approx 8 statements
Inconsistent indentation detected. def indexSecretariesController tests '( is_principal? )' at least 6 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? )SecretariesController#index calls 'Secretary.all' 3 times @secretaries = Secretary.allSecretariesController#index calls 'params[:search]' 3 times if params[:search] string_to_search = params[:search].strip.upcase!Line is too long. [82/80]
Prefer single-quoted strings when you don't need string interpolation or special symbols. @secretaries = Secretary.search(string_to_search).order("created_at DESC")Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if (@secretaries.empty?)SecretariesController#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?SecretariesController#index calls 'Secretary.all.order('created_at DESC')' 2 times @secretaries = Secretary.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 @secretaries = Secretary.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 Inconsistent indentation detected. def showSpace inside parentheses detected.
Don't use parentheses around the condition of an `if`.
Use `||` instead of `or`. if ( is_principal? or is_secretary? ) @secretary = Secretary.find(params[:id]) elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end Inconsistent indentation detected. def newSpace inside parentheses detected.
Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if ( is_principal? )Tab detected.
Use 2 (not -1) spaces for indentation. @shifts = Shift.allInconsistent indentation detected. @secretary = Secretary.new elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end Inconsistent indentation detected. def editDon't use parentheses around a method call.
Space inside parentheses detected.
Don't use parentheses around the condition of an `if`. if ( is_principal? )Use 2 (not -1) spaces for indentation.
Tab detected. @shifts = Shift.allInconsistent indentation detected. @secretary = Secretary.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. [12/10]
SecretariesController#create has approx 6 statements
Inconsistent indentation detected. def createSpace inside parentheses detected.
Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if ( is_principal? )Tab detected.
Use 2 (not -1) spaces for indentation. @shifts = Shift.allInconsistent indentation detected. @secretary = Secretary.new(secretary_params)Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call.
Inconsistent indentation detected. if (@secretary.save)Prefer single-quoted strings when you don't need string interpolation or special symbols. flash[:success] = "Secretário(a) criado(a) com sucesso" redirect_to @secretary 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. [12/10]
SecretariesController#update has approx 6 statements
Similar blocks of code found in 2 locations. Consider refactoring.
Inconsistent indentation detected. def updateSpace inside parentheses detected.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call. if ( is_principal? )Use 2 (not -1) spaces for indentation.
Tab detected. @shifts = Shift.allInconsistent indentation detected. @secretary = Secretary.find(params[:id])Inconsistent indentation detected. if @secretary.update secretary_paramsPrefer single-quoted strings when you don't need string interpolation or special symbols. flash[:notice] = "Secretário(a) alterado(a) com sucesso" redirect_to @secretary 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 Inconsistent indentation detected. def destroySpace inside parentheses detected.
Don't use parentheses around the condition of an `if`.
Use a guard clause instead of wrapping the code inside a conditional expression.
Don't use parentheses around a method call. if ( is_principal? ) @secretary = Secretary.find(params[:id])Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if (@secretary.destroy)Prefer single-quoted strings when you don't need string interpolation or special symbols. flash[:alert] = "Secretário(a) excluĂdo(a) com sucesso"Tab detected.
Inconsistent indentation detected. redirect_to secretaries_path elseTab detected.
Use 2 (not 1) spaces for indentation.
Prefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end end Keep a blank line before and after `private`. privateMethod has too many lines. [12/10]
Inconsistent indentation detected. def secretary_paramsSpace inside parentheses detected.
Tab detected.
Use 2 (not 1) spaces for indentation. params.require(:secretary).permit( :employee_cpf,Align the parameters of a method call if they span more than one line.
Tab detected. :admission_date,Align the parameters of a method call if they span more than one line.
Tab detected. :shift,Align the parameters of a method call if they span more than one line.
Tab detected. :name,Tab detected.
Align the parameters of a method call if they span more than one line. :address,Tab detected.
Align the parameters of a method call if they span more than one line. :phone,Align the parameters of a method call if they span more than one line.
Tab detected. :gender,Tab detected.
Align the parameters of a method call if they span more than one line. :birth_date,Align the parameters of a method call if they span more than one line.
Tab detected. :permission,Align the parameters of a method call if they span more than one line.
Tab detected. :password,Tab detected.
Align the parameters of a method call if they span more than one line. :registry,Tab detected.
Align the parameters of a method call if they span more than one line. :shift_id) endend