app/controllers/subjects_controller.rb
# File name: subjects_controller.rb# Class name: SubjectsControllerLine is too long. [83/80]# Description: Controller used to communicate with the proprietary view of subjectsClass has too many lines. [120/100]
SubjectsController has at least 6 instance variables
SubjectsController assumes too much for instance variable '@subject'
SubjectsController assumes too much for instance variable '@teacher'
SubjectsController assumes too much for instance variable '@classroom_subject'
SubjectsController assumes too much for instance variable '@classroom'class SubjectsController < ApplicationControllerUse 2 (not 1) spaces for indentation.
Tab detected. include SessionsHelper Inconsistent indentation detected. def indexSpace inside parentheses detected.
Use 2 (not 1) spaces for indentation.
Tab detected.
Don't use parentheses around the condition of an `if`.
Use `||` instead of `or`. if ( is_principal? or is_teacher? )Tab detected.
Use 2 (not 1) spaces for indentation. @subjects = Subject.allAlign `else` with `if`. elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500"Tab detected. end end Tab detected. def classroom_subjectsUse 2 (not 1) spaces for indentation.
Tab detected. @classroom = Classroom.find(params[:id])Tab detected. @subjects = @classroom.subjectsTab detected. end Inconsistent indentation detected. def newSubjectsController tests '( is_principal? )' at least 8 times
Tab detected.
Space inside parentheses detected.
Use 2 (not 1) spaces for indentation.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call. if ( is_principal? )Use 2 (not 0) spaces for indentation.
Tab detected. @classroom_grades = ClassroomGrade.allInconsistent indentation detected.
Tab detected. @subject = Subject.newAlign `else` with `if`. elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500"Tab detected. end end Inconsistent indentation detected. def editSpace inside parentheses detected.
Tab detected.
Use 2 (not 1) spaces for indentation.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call. if ( is_principal? )Tab detected.
Use 2 (not 0) spaces for indentation. @classroom_grades = ClassroomGrade.allInconsistent indentation detected.
Tab detected. @subject = Subject.find(params[:id])Align `else` with `if`. elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500"`end` at 35, 4 is not aligned with `if` at 30, 3. end end Inconsistent indentation detected. def showTab detected.
Space inside parentheses detected.
Use 2 (not 1) spaces for indentation.
Space after keyword `if` is missing. if( is_principal? )Use 2 (not 1) spaces for indentation.
Tab detected. @subject = Subject.find(params[:id])Align `else` with `if`. elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500"Tab detected. end end Method has too many lines. [19/10]
Assignment Branch Condition size for create is too high. [17.03/15]
Cyclomatic complexity for create is too high. [4/3]
Method `create` has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
SubjectsController#create has approx 10 statements
Inconsistent indentation detected. def createSpace inside parentheses detected.
Tab detected.
Use 2 (not 1) spaces for indentation.
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 0) spaces for indentation. @classroom_grades = ClassroomGrade.allTab detected. @subject = Subject.new(subject_params)Tab detected. @teacher = Teacher.find_by_registry(params[:teacher_registry])SubjectsController#create performs a nil-check
Space inside parentheses detected.
Tab detected.
Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if ( @teacher.nil? )SubjectsController#create calls '@subject.save' 2 times
Tab detected.
Use 2 (not 1) spaces for indentation. @subject.saveSubjectsController#create calls 'render 'new'' 2 times
Tab detected. render 'new'Tab detected. elseTab detected.
Use 2 (not 1) spaces for indentation. @subject.teacher_id = @teacher.idSpace inside parentheses detected.
Inconsistent indentation detected.
Tab detected.
Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if ( @subject.save )Tab detected.
Use 2 (not 0) spaces for indentation.
Prefer single-quoted strings when you don't need string interpolation or special symbols. flash[:success] = "Matéria criada com sucesso"Inconsistent indentation detected.
Tab detected. redirect_to @subjectAlign `else` with `if`.
Tab detected. elseTab detected.
Use 2 (not 1) spaces for indentation. render 'new'Tab detected.
`end` at 61, 6 is not aligned with `if` at 56, 5. endTab detected.
`end` at 62, 5 is not aligned with `if` at 51, 3. endAlign `else` with `if`. elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500"Tab detected.
`end` at 65, 2 is not aligned with `if` at 47, 3. end end Inconsistent indentation detected. def destroyUse 2 (not 1) spaces for indentation.
Space inside parentheses detected.
Tab 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. @subject = Subject.find(params[:id])Tab detected. @subject.destroyInconsistent indentation detected.
Tab detected.
Prefer single-quoted strings when you don't need string interpolation or special symbols. flash[:alert] = "Matéria excluÃda com sucesso"Tab detected. redirect_to subjects_pathAlign `else` with `if`. elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500"Tab detected. end end Method has too many lines. [19/10]
Assignment Branch Condition size for update is too high. [19.87/15]
Cyclomatic complexity for update is too high. [4/3]
Method `update` has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
SubjectsController#update has approx 10 statements
Inconsistent indentation detected. def updateUse 2 (not 1) spaces for indentation.
Tab detected.
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? )Use 2 (not 0) spaces for indentation.
Tab detected. @classroom_grades = ClassroomGrade.allTab detected. @subject = Subject.find(params[:id])Tab detected. @teacher = Teacher.find_by_registry(params[:teacher_registry])SubjectsController#update performs a nil-check
Tab detected.
Space inside parentheses detected.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call. if ( @teacher.nil? )SubjectsController#update calls '@subject.update(subject_params)' 2 times
Tab detected.
Use 2 (not 1) spaces for indentation. @subject.update(subject_params)SubjectsController#update calls 'render 'edit'' 2 times
Tab detected. render 'edit'Tab detected. elseTab detected.
Use 2 (not 1) spaces for indentation. @subject.teacher_id = @teacher.idTab detected.
Space inside parentheses detected.
Inconsistent indentation detected.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call. if ( @subject.update(subject_params) )Use 2 (not 0) spaces for indentation.
Tab detected.
Prefer single-quoted strings when you don't need string interpolation or special symbols. flash[:notice] = "Matéria alterada com sucesso"Inconsistent indentation detected.
Tab detected. redirect_to @subjectTab detected.
Align `else` with `if`. elseTab detected.
Use 2 (not 1) spaces for indentation. render 'edit'Tab detected.
`end` at 94, 6 is not aligned with `if` at 89, 5. endTab detected.
`end` at 95, 5 is not aligned with `if` at 84, 3. endAlign `else` with `if`. elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500"Tab detected.
`end` at 98, 2 is not aligned with `if` at 80, 3. end end Inconsistent indentation detected. def add_classroomsSpace 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? ) @classroom = Classroom.find(params[:id]) @subjects = Subject.all end end Assignment Branch Condition size for add_classroom is too high. [24.23/15]
Method has too many lines. [16/10]
Cyclomatic complexity for add_classroom is too high. [4/3]
SubjectsController#add_classroom has approx 9 statements
Method `add_classroom` has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Inconsistent indentation detected. def add_classroomSpace inside parentheses detected.
Use a guard clause instead of wrapping the code inside a conditional expression.
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]) @subject = Subject.find(params[:subject_id])SubjectsController#add_classroom calls '@subject.id' 2 times
SubjectsController#add_classroom calls '@classroom.id' 2 times
Tab detected.
Inconsistent indentation detected.
Don't use parentheses around a method call.
Line is too long. [101/80] if !((ClassroomSubject.where(classroom_id: @classroom.id).where(subject_id: @subject.id)).exists?)Use 2 (not 1) spaces for indentation.
Tab detected. @classroom_subject = ClassroomSubject.newTab detected. @classroom_subject.subject_id = @subject.idTab detected. @classroom_subject.classroom_id = @classroom.idTab detected. if @classroom_subject.saveUse 2 (not 1) spaces for indentation.
Tab detected.
Prefer single-quoted strings when you don't need string interpolation or special symbols. flash[:success] = "Matéria adicionada com sucesso"SubjectsController#add_classroom calls 'redirect_to add_classrooms_path(@classroom)' 2 times
SubjectsController#add_classroom calls 'add_classrooms_path(@classroom)' 2 times
Tab detected. redirect_to add_classrooms_path(@classroom)Tab detected. endTab detected. elseUse 2 (not 1) spaces for indentation.
Tab detected.
Prefer single-quoted strings when you don't need string interpolation or special symbols. flash[:alert] = "Matéria não pode ser adicionada ou já existe na turma"Tab detected. redirect_to add_classrooms_path(@classroom)Tab detected. end end end Inconsistent indentation detected. def show_subjects @classroom = Classroom.find(params[:id]) @subjects = @classroom.subject end Keep a blank line before and after `private`. privateInconsistent indentation detected. def subject_paramsUse 2 (not 1) spaces for indentation.
Tab detected. params.require(:subject).permit(:name_subject,Align the parameters of a method call if they span more than one line.
Space missing after comma.
Tab detected. :class_level,:teacher_id,:classroom_id,:subject_id, :classroom_grade_id) endend