-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove deprecation warnings e refatora o serviço SchoolDayChecker #32
Remove deprecation warnings e refatora o serviço SchoolDayChecker #32
Conversation
while not date_is_school_day?(date) | ||
date = date.next_day | ||
for_each_checker(checker_methods) do |result| | ||
return result unless result.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SchoolDayChecker#school_day? performs a nil-check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pq não: return result if result.present?
classroom_or_classroom_id = nil, | ||
discipline_or_discipline_id = nil | ||
) | ||
raise ArgumentError if school_calendar.nil? && date.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SchoolDayChecker#initialize performs a nil-check
@classroom ||= Classroom.find(@classroom_id) | ||
end | ||
|
||
def grade | ||
return if @grade_id.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SchoolDayChecker#grade performs a nil-check
query.without_course | ||
.without_grade | ||
.without_classroom | ||
.any? | ||
end | ||
|
||
def classroom | ||
return if @classroom_id.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SchoolDayChecker#classroom performs a nil-check
|
||
else | ||
def checker_methods | ||
return CHECKERS_WHEN_CLASSROOM_NIL if @classroom_id.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SchoolDayChecker#checker_methods performs a nil-check
|
||
![0, 6].include? date.wday | ||
def any_discipline_event? | ||
return if @discipline_id.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SchoolDayChecker#any_discipline_event? performs a nil-check
Ebert has finished reviewing this Pull Request and has found:
You can see more details about this review at https://ebertapp.io/github/portabilis/i-diario/pulls/32. |
@discipline_id = discipline_id | ||
@grade_id = fetch_id(grade_or_grade_id) | ||
@classroom_id = fetch_id(classroom_or_classroom_id) | ||
@discipline_id = fetch_id(discipline_or_discipline_id) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qual foi a motivação de fazer o fetch_id?
while not date_is_school_day?(date) | ||
date = date.next_day | ||
for_each_checker(checker_methods) do |result| | ||
return result unless result.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pq não: return result if result.present?
end | ||
|
||
def any_grade_event? | ||
return if @grade_id.present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
não seria bom retornar sempre um boolean?
Refatora o serviço SchoolDayChecker aplicando boas práticas de desenvolvimento e adequa ao style guide da Portabilis, a api publica não é alterada.
Descrição
O serviço foi refatorado para se adequar ao style guide, reduzida a passagem de parâmetros quando variáveis de instância podiam ser usadas, melhorado a legibilidade, melhorado as responsabilidades do métodos e como consequência reduzido a quantidade de linhas de cada um e removido métodos não utilizados.
Contexto e motivação
Durante a refatoração do serviço ExamPoster::NumericalExamPoster foi revelado um deprecation warning nesta classe, analisando mais a fundo um refatoração se fez necessária visto que a classe não seguia em 100% o style guide e algumas boas práticas de desenvolvimento poderiam ser aplicadas.
Resolve esta issue: #30
Tipos de alterações
Checklist: