app/controllers/alumns_controller.rb
# File name: alumns_controller.rb# Class name: AlumnsControllerIncorrect indentation detected (column 0 instead of 1).
Line is too long. [81/80]# Description: Controller used to communicate with the proprietary view of alumnsClass has too many lines. [140/100]
AlumnsController has at least 7 instance variables
AlumnsController assumes too much for instance variable '@alumn'
AlumnsController assumes too much for instance variable '@user'
AlumnsController assumes too much for instance variable '@current_user'
AlumnsController assumes too much for instance variable '@alumns'
Indentation of first line in file detected. class AlumnsController < ApplicationControllerUse 2 (not 1) spaces for indentation. include SessionsHelper Assignment Branch Condition size for index is too high. [32.02/15]
Method has too many lines. [25/10]
Cyclomatic complexity for index is too high. [6/3]
Perceived complexity for index is too high. [9/7]
Method `index` has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
AlumnsController#index has approx 14 statements def indexSpace inside parentheses detected.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call. if ( is_parent? ) @alumns = @current_user.alumnsSpace inside parentheses detected.
Don't use parentheses around the condition of an `elsif`.
Don't use parentheses around a method call. elsif ( is_employee? )AlumnsController#index calls 'Alumn.all' 3 times @alumns = Alumn.allUse array literal `[]` instead of `Array.new`. @grades = Array.new @subjects = Subject.all respond_to do |format|Use 2 (not 0) spaces for indentation. format.htmlMissing space after `#`. format.xls #{ send_data @alumns.to_csv (col_sep: "\t")}Extra empty line detected at block body end. endAlumnsController#index calls 'params[:search]' 3 times if params[:search] string_to_search = params[:search]Line is too long. [87/80]
Prefer single-quoted strings when you don't need string interpolation or special symbols. @alumns = Alumn.search(string_to_search.strip.upcase!).order("created_at DESC")Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if (@alumns.empty?)AlumnsController#index calls 'flash.now' 2 times
Use 2 (not 3) spaces for indentation.
Prefer single-quoted strings when you don't need string interpolation or special symbols. flash.now[:feedback] = "Nenhum(a) aluno(a) encontrado!"Don't use parentheses around a method call.
Don't use parentheses around the condition of an `elsif`. elsif (params[:search].blank?)AlumnsController#index calls 'Alumn.all.order('created_at DESC')' 2 times
Use 2 (not 3) spaces for indentation. @alumns = Alumn.all.order('created_at DESC')Inconsistent indentation detected.
Prefer single-quoted strings when you don't need string interpolation or special symbols. flash.now[:feedback_warning] = "Digite algo para pesquisar!" end else @alumns = Alumn.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] Space inside parentheses detected.
Use `||` instead of `or`.
Don't use parentheses around the condition of an `if`. if ( is_employee? or is_son?(id) or verify_alumn(id) ) @alumn = Alumn.find(id) Alumn.current = @alumn elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end def newAlumnsController tests '( is_principal? )' at least 7 times
Space inside parentheses detected.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call. if ( is_principal? ) @shifts = Shift.all @alumn = Alumn.newAlumnsController declares the class variable '@@parent'
Replace class var @@parent with a class instance var. @@parent = Parent.find(params[:parent_id]) @classrooms = Classroom.all.order('name_classroom') 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? ) @shifts = Shift.all @alumn = Alumn.find(params[:id]) @classrooms = Classroom.all.order('name_classroom') 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. [15/10]
AlumnsController#create has approx 9 statements 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? ) @shifts = Shift.all @alumn = Alumn.new(alumn_params) @alumn.parent_id = @@parent.id @classrooms = Classroom.all.order('name_classroom')Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if (@alumn.save) GradesController.create(@alumn)Prefer single-quoted strings when you don't need string interpolation or special symbols. flash[:success] = "Aluno(a) criado(a) com sucesso" redirect_to @alumn 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. [14/10]
AlumnsController#update has approx 8 statements 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? ) @shifts = Shift.all @alumn = Alumn.find(params[:id]) @classrooms = Classroom.all.order('name_classroom') if @alumn.update alumn_params GradesController.update_alumn(@alumn)Prefer single-quoted strings when you don't need string interpolation or special symbols. flash[:notice] = "Aluno(a) alterado(a) com sucesso" redirect_to @alumn 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 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? ) @alumn = Alumn.find(params[:id]) @alumn.destroyPrefer single-quoted strings when you don't need string interpolation or special symbols. flash[:alert] = "Aluno(a) excluÃdo(a) com sucesso" redirect_to users_path end end def edit_password_alumnSpace inside parentheses detected.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call. if ( is_principal? ) @user = Alumn.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_alumnSpace 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 = Alumn.find(params[:id])Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if (@user.update!(alumn_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 Cyclomatic complexity for report is too high. [4/3] def reportUse 2 (not 4) spaces for indentation. @alumn = Alumn.find(params[:id])Line is too long. [86/80]
Use `||` instead of `or`.
Space inside parentheses detected.
Use a guard clause instead of wrapping the code inside a conditional expression.
Favor `unless` over `if` for negative conditions.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around an unary operation. if ( !(is_parent_related_to_alumn?(@alumn) or is_me?(@alumn) or is_principal?) ) redirect_to @current_user end end Indent access modifiers like `private`.
Keep a blank line before and after `private`. privateMethod has too many lines. [14/10] def alumn_params params.require(:alumn).permit(:registry, :shift, :name, :address, :phone, :gender, :image, :birth_date, :password, :parent_id, :classroom_id, :photo, :bar_code, :shift_id) end`end` at 158, 0 is not aligned with `class` at 4, 1.end