app/controllers/classrooms_controller.rb
# File name: classrooms_controller.rb# Class name: ClassroomsControllerLine is too long. [85/80]# Description: Controller used to communicate with the proprietary view of classroomsClass has too many lines. [118/100]
ClassroomsController has at least 8 instance variables
ClassroomsController assumes too much for instance variable '@alumn'
ClassroomsController assumes too much for instance variable '@classroom'
ClassroomsController assumes too much for instance variable '@classrooms'class ClassroomsController < ApplicationController include SessionsHelper Assignment Branch Condition size for index is too high. [21.47/15]
Method has too many lines. [14/10]
Cyclomatic complexity for index is too high. [6/3]
Method `index` has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. def indexSpace inside parentheses detected.
Use `||` instead of `or`.
Don't use parentheses around the condition of an `if`. if ( is_principal? or is_secretary? ) @classrooms = Classroom.all.order('name_classroom')ClassroomsController#index calls 'params[:classroom_grade_id]' 2 times unless params[:classroom_grade_id].blank?Line is too long. [87/80] @classrooms &= Classroom.where(classroom_grade_id: params[:classroom_grade_id]) endClassroomsController#index calls 'params[:shift_id]' 2 times unless params[:shift_id].blank? @classrooms &= Classroom.where(shift_id: params[:shift_id]) endFavor modifier `if` usage when having a single-line body. Another good alternative is the usage of control flow `&&`/`||`.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call. if (@classrooms.empty?)Prefer single-quoted strings when you don't need string interpolation or special symbols. flash.now[:notice] = "Nenhuma Turma encontrada!" end elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end def newClassroomsController 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? ) @classroom = Classroom.new @classroom_grades = ClassroomGrade.all @shifts = Shift.all elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end def showUse `||` instead of `or`.
Don't use parentheses around the condition of an `if`.
Space inside parentheses detected. if ( is_principal? or is_secretary?) @classroom = Classroom.find(params[:id]) @shift = Shift.find_by_id(@classroom.shift_id)Line is too long. [81/80] @classroom_grade = ClassroomGrade.find_by_id(@classroom.classroom_grade_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. [13/10]
ClassroomsController#create has approx 7 statements def createDon't use parentheses around a method call.
Don't use parentheses around the condition of an `if`.
Space inside parentheses detected. if ( is_principal? ) @classroom = Classroom.create(classroom_params) @classroom_grades = ClassroomGrade.all @shifts = Shift.allDon't use parentheses around the condition of an `if`.
Space inside parentheses detected.
Don't use parentheses around a method call. if ( @classroom.save )Prefer single-quoted strings when you don't need string interpolation or special symbols. flash[:success] = "Turma criada com sucesso" redirect_to classroom_path(@classroom) else render 'classrooms/new' end elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end def destroyUse 2 (not 0) spaces for indentation.
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? ) @classroom = Classroom.find(params[:id]) @classroom.destroyPrefer single-quoted strings when you don't need string interpolation or special symbols. flash[:alert] = "Turma excluÃda com sucesso" redirect_to users_path elseUse 2 (not 4) spaces for indentation.
Prefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end`end` at 69, 0 is not aligned with `def` at 60, 2.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? ) @classroom = Classroom.find(params[:id]) @classroom_grades = ClassroomGrade.all @shifts = Shift.all elsePrefer single-quoted strings when you don't need string interpolation or special symbols.
Use 2 (not 4) spaces for indentation. redirect_to "/errors/error_500" endend Method has too many lines. [13/10]
ClassroomsController#update has approx 7 statements
Inconsistent indentation detected.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? ) @classroom = Classroom.find(params[:id]) @classroom_grades = ClassroomGrade.all @shifts = Shift.all if @classroom.update(classroom_params)Prefer single-quoted strings when you don't need string interpolation or special symbols. flash[:notice] = "Turma alterada com sucesso" redirect_to classroom_path(@classroom) elsePrefer single-quoted strings when you don't need string interpolation or special symbols. render "classrooms/edit" end elseUse 2 (not 4) spaces for indentation.
Prefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" endend Inconsistent indentation detected.def add_alumnsDon't use parentheses around a method call.
Don't use parentheses around the condition of an `if`.
Space inside parentheses detected. if ( is_principal? ) @classroom = Classroom.find(params[:id]) @alumns = @classroom.alumns.order('name') elseUse 2 (not 4) spaces for indentation.
Prefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" endend Method has too many lines. [18/10]
Assignment Branch Condition size for add_alumn is too high. [17.72/15]
Cyclomatic complexity for add_alumn is too high. [4/3]
Method `add_alumn` has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
ClassroomsController#add_alumn has approx 9 statements
Inconsistent indentation detected.def add_alumnDon't use parentheses around a method call.
Don't use parentheses around the condition of an `if`.
Space inside parentheses detected. if ( is_principal? ) @classroom = Classroom.find(params[:id]) @alumns = @classroom.alumns @alumn = Alumn.find_by_registry(params[:registry])ClassroomsController#add_alumn performs a nil-check
Space inside parentheses detected.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call.
Don't use parentheses around a variable. if ( (@alumn).nil? ) redirect_to add_alumns_path(@classroom) else @alumn.classroom_id = @classroom.id if @alumn.save GradesController.update_alumn(@alumn)ClassroomsController#add_alumn calls 'render "classrooms/add_alumns"' 2 times
Move `render "classrooms/add_alumns"` out of the conditional.
Prefer single-quoted strings when you don't need string interpolation or special symbols. render "classrooms/add_alumns" elseMove `render "classrooms/add_alumns"` out of the conditional.
Prefer single-quoted strings when you don't need string interpolation or special symbols. render "classrooms/add_alumns" end end elseUse 2 (not 4) spaces for indentation.
Prefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" endend Keep a blank line before and after `private`.
Indent access modifiers like `private`.private def classroom_params params.require(:classroom).permit(:name_classroom, :shift_id, :classroom_grade_id) endend