Skip to content
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

Conversation

rafaelmoraes
Copy link

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

  • ✅ Melhoria

Checklist:

  • ✅ Eu li o documento CONTRIBUTING. [REQUIRED]
  • ✅ Meu código segue o style guide. [REQUIRED]
  • ✅ Todos os testes novos e existentes estão passando. [REQUIRED]

while not date_is_school_day?(date)
date = date.next_day
for_each_checker(checker_methods) do |result|
return result unless result.nil?

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

Read more about it here.

Copy link
Contributor

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?

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

Read more about it here.

@classroom ||= Classroom.find(@classroom_id)
end

def grade
return if @grade_id.nil?

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

Read more about it here.

query.without_course
.without_grade
.without_classroom
.any?
end

def classroom
return if @classroom_id.nil?

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

Read more about it here.


else
def checker_methods
return CHECKERS_WHEN_CLASSROOM_NIL if @classroom_id.nil?

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

Read more about it here.


![0, 6].include? date.wday
def any_discipline_event?
return if @discipline_id.nil?

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

Read more about it here.

@sourcelevel-bot
Copy link

Ebert has finished reviewing this Pull Request and has found:

  • 7 possible new issues (including those that may have been commented here).
  • 15 fixed issues! 🎉

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
Copy link
Contributor

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?
Copy link
Contributor

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?
Copy link
Contributor

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?

@edersoares edersoares closed this Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants