fga-gpp-mds/2017.1-Escola-X

View on GitHub
app/controllers/employees_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
# File name: employees_controller.rb
# Class name: EmployeesController
# Description: Controller used to communicate with the views of emplyoees
 
EmployeesController assumes too much for instance variable '@user'
EmployeesController assumes too much for instance variable '@employee'
Missing top-level class documentation comment.
class EmployeesController < UsersController
Tab detected.
Use 2 (not 1) spaces for indentation.
include SessionsHelper
 
Tab detected.
def index
Don't use parentheses around a method call.
Use 2 (not 4) spaces for indentation.
Space inside parentheses detected.
Tab detected.
Don't use parentheses around the condition of an `if`.
if ( is_employee? )
Tab detected.
Use 2 (not 3) spaces for indentation.
@employees = Employee.all
Tab detected.
Align `else` with `if`.
else
Use 2 (not 1) spaces for indentation.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
Tab detected.
redirect_to "/errors/error_500"
Tab detected.
end
`end` at 14, 3 is not aligned with `def` at 8, 1.
Tab detected.
end
 
Extra blank line detected.
 
Tab detected.
Use empty lines between method definitions.
def edit_password_employee
EmployeesController tests '( is_principal? )' at least 7 times
Don't use parentheses around a method call.
Tab detected.
Space inside parentheses detected.
Don't use parentheses around the condition of an `if`.
Use 2 (not 1) spaces for indentation.
if ( is_principal? )
Tab detected.
Use 2 (not 1) spaces for indentation.
@user = Employee.find(params[:id])
Unnecessary spacing detected.
Tab detected.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
render action: "../users/edit_password"
Tab detected.
else
Use 2 (not 6) spaces for indentation.
Tab detected.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
redirect_to "/errors/error_500"
Tab detected.
end
Tab detected.
end
 
Tab detected.
def update_password_employee
Don't use parentheses around a method call.
Don't use parentheses around the condition of an `if`.
Space inside parentheses detected.
Use 2 (not 1) spaces for indentation.
Tab detected.
if ( is_principal? )
Use 2 (not 1) spaces for indentation.
Tab detected.
@user = Employee.find(params[:id])
Tab detected.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call.
if (@user.update!(employee_params))
Use 2 (not 1) spaces for indentation.
Tab detected.
redirect_to @user
Tab detected.
else
Tab detected.
Use 2 (not 1) spaces for indentation.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
render action: "../users/edit_password"
Tab detected.
end
Tab detected.
else
Prefer single-quoted strings when you don't need string interpolation or special symbols.
Tab detected.
Use 2 (not 6) spaces for indentation.
redirect_to "/errors/error_500"
Tab detected.
end
Tab detected.
end
 
Inconsistent indentation detected.
def show
Space inside parentheses detected.
Don't use parentheses around a method call.
Use a guard clause instead of wrapping the code inside a conditional expression.
Don't use parentheses around the condition of an `if`.
Favor modifier `if` usage when having a single-line body. Another good alternative is the usage of control flow `&&`/`||`.
if ( is_employee? )
@employee = Employee.find(params[:id])
end
end
 
Inconsistent indentation detected.
def new
Use a guard clause instead of wrapping the code inside a conditional expression.
Don'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.all
Inconsistent indentation detected.
@employee = Employee.new
end
end
 
Inconsistent indentation detected.
def edit
Space inside parentheses detected.
Don't use parentheses around a method call.
Use a guard clause instead of wrapping the code inside a conditional expression.
Don't use parentheses around the condition of an `if`.
if ( is_principal? )
Tab detected.
Use 2 (not -1) spaces for indentation.
@shifts = Shift.all
Inconsistent indentation detected.
@employee = Employee.find(params[:id])
end
end
 
Inconsistent indentation detected.
def create
Don't use parentheses around the condition of an `if`.
Space inside parentheses detected.
Use a guard clause instead of wrapping the code inside a conditional expression.
Don't use parentheses around a method call.
if ( is_principal? )
Tab detected.
Use 2 (not -1) spaces for indentation.
@shifts = Shift.all
Inconsistent indentation detected.
@employee = Employee.new(employee_params)
 
Don't use parentheses around the condition of an `if`.
Inconsistent indentation detected.
Don't use parentheses around a method call.
Favor modifier `if` usage when having a single-line body. Another good alternative is the usage of control flow `&&`/`||`.
if (@employee.save)
redirect_to users_path
end
end
end
 
Inconsistent indentation detected.
def update
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call.
Space inside parentheses detected.
Use a guard clause instead of wrapping the code inside a conditional expression.
if ( is_principal? )
Use 2 (not -1) spaces for indentation.
Tab detected.
@shifts = Shift.all
Inconsistent indentation detected.
@employee = Employee.find(params[:id])
Space inside parentheses detected.
Don't use parentheses around the condition of an `if`.
Inconsistent indentation detected.
Don't use parentheses around a method call.
if ( @employee.update(employee_params) )
redirect_to @employee
else
render 'edit'
end
end
end
 
Inconsistent indentation detected.
def destroy
Space 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? )
@employee = Employee.find(params[:id])
@employee.destroy
 
redirect_to users_path
end
end
 
Keep a blank line before and after `private`.
Indent access modifiers like `private`.
private
Method has too many lines. [11/10]
Inconsistent indentation detected.
def employee_params
Space inside parentheses detected.
params.require(:employee).permit( :registry,
Align the parameters of a method call if they span more than one line.
Tab detected.
:admission_date,
Tab detected.
Align the parameters of a method call if they span more than one line.
:employee_cpf,
Tab detected.
Align the parameters of a method call if they span more than one line.
:shift,
Tab detected.
Align the parameters of a method call if they span more than one line.
:password,
Align the parameters of a method call if they span more than one line.
Tab detected.
:name,
Align the parameters of a method call if they span more than one line.
Tab detected.
:address,
Align the parameters of a method call if they span more than one line.
Tab detected.
: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.
:shift_id)
Extra empty line detected at method body end.
 
Tab detected.
`end` at 105, 3 is not aligned with `def` at 92, 2.
end
end