fga-gpp-mds/2017.1-Escola-X

View on GitHub
app/controllers/grades_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage

Showing 32 of 32 total issues

Assignment Branch Condition size for post_grades is too high. [20.49/15]
Open

def post_grades
if is_secretary?
@classroom = Classroom.find(params[:id])
@subject = Subject.find(params[:subject_id])
@alumn = Alumn.find(params[:alumn_id])

Method has too many lines. [12/10]
Open

def post_grades
if is_secretary?
@classroom = Classroom.find(params[:id])
@subject = Subject.find(params[:subject_id])
@alumn = Alumn.find(params[:alumn_id])

GradesController has at least 5 instance variables
Open

class GradesController < ApplicationController
Severity: Minor
Found in app/controllers/grades_controller.rb by reek

GradesController#post_grades has approx 7 statements
Open

def post_grades
Severity: Minor
Found in app/controllers/grades_controller.rb by reek

GradesController assumes too much for instance variable '@subject'
Open

class GradesController < ApplicationController
Severity: Minor
Found in app/controllers/grades_controller.rb by reek

GradesController assumes too much for instance variable '@current_user'
Open

class GradesController < ApplicationController
Severity: Minor
Found in app/controllers/grades_controller.rb by reek

GradesController assumes too much for instance variable '@alumn'
Open

class GradesController < ApplicationController
Severity: Minor
Found in app/controllers/grades_controller.rb by reek

GradesController assumes too much for instance variable '@classroom'
Open

class GradesController < ApplicationController
Severity: Minor
Found in app/controllers/grades_controller.rb by reek

GradesController assumes too much for instance variable '@grade'
Open

class GradesController < ApplicationController
Severity: Minor
Found in app/controllers/grades_controller.rb by reek

GradesController#self.create calls 'subject.id' 2 times
Open

if !(Grade.where(alumn_id:alumn.id).where(subject_id: subject.id).exists?)
@grade = Grade.new(alumn_id: alumn.id, subject_id: subject.id,
Severity: Minor
Found in app/controllers/grades_controller.rb by reek

GradesController#self.create calls 'alumn.id' 2 times
Open

if !(Grade.where(alumn_id:alumn.id).where(subject_id: subject.id).exists?)
@grade = Grade.new(alumn_id: alumn.id, subject_id: subject.id,
Severity: Minor
Found in app/controllers/grades_controller.rb by reek

Line is too long. [85/80]
Open

@grades = Grade.where(classroom_id:@classroom.id).where(subject_id:@subject.id)

Align the elements of a hash literal if they span more than one line.
Open

classroom_id: alumn.classroom_id)

Use a guard clause instead of wrapping the code inside a conditional expression.
Open

if is_secretary?

Space missing after colon.
Open

@grades = Grade.where(classroom_id:@classroom.id).where(subject_id:@subject.id)

Space missing after comma.
Open

GradeHistoriesController.create(@grade,@current_user)

Indent access modifiers like private.
Open

private

Do not put a space between a method name and the opening parenthesis.
Open

def self.update_alumn (alumn)

Keep a blank line before and after private.
Open

private

Space missing after colon.
Open

if !(Grade.where(alumn_id:alumn.id).where(subject_id: subject.id).exists?)

Space missing after colon.
Open

if !Grade.where(alumn_id:alumn.id).where(subject_id: subject.id).exists?

Do not put a space between a method name and the opening parenthesis.
Open

def self.create (alumn)

Don't use parentheses around the condition of an if.
Open

if (is_secretary? or is_principal?)

Don't use parentheses around a method call.
Open

if !(Grade.where(alumn_id:alumn.id).where(subject_id: subject.id).exists?)

Use || instead of or.
Open

if (is_secretary? or is_principal?)

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

render "grades/index"

Space missing after colon.
Open

@grades = Grade.where(classroom_id:@classroom.id).where(subject_id:@subject.id)

Favor unless over if for negative conditions.
Open

if !Grade.where(alumn_id:alumn.id).where(subject_id: subject.id).exists?
GradesController.create(alumn)
end

Favor unless over if for negative conditions.
Open

if !(Grade.where(alumn_id:alumn.id).where(subject_id: subject.id).exists?)
@grade = Grade.new(alumn_id: alumn.id, subject_id: subject.id,
classroom_id: alumn.classroom_id)
@grade.save
end

Use next to skip iteration.
Open

if !(Grade.where(alumn_id:alumn.id).where(subject_id: subject.id).exists?)

Line is too long. [108/80]
Open

@grade = Grade.find_by_classroom_id_and_subject_id_and_alumn_id(@classroom.id, @subject.id, @alumn.id)

Use a guard clause instead of wrapping the code inside a conditional expression.
Open

if (is_secretary? or is_principal?)
Category
Status