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

Refactor AE Content Task Finished method and add spec #589

Merged

Conversation

GregP
Copy link
Contributor

@GregP GregP commented Oct 18, 2019

State Machine task finished method refactoring.

This PR is based on the issue below:
ManageIQ/manageiq#12038

@miq-bot add_label refactoring

@GregP GregP changed the title Refactor AE Content Task Finished method and add spec [WIP] Refactor AE Content Task Finished method and add spec Oct 18, 2019
@miq-bot miq-bot added the wip label Oct 18, 2019
@coveralls
Copy link

coveralls commented Oct 18, 2019

Pull Request Test Coverage Report for Build 3809

  • 27 of 27 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 96.839%

Totals Coverage Status
Change from base Build 3807: 0.04%
Covered Lines: 2788
Relevant Lines: 2879

💛 - Coveralls

@GregP GregP force-pushed the state_machine_task_finished-refactoring branch from d5aea24 to 31de2a3 Compare October 23, 2019 18:31
@GregP GregP force-pushed the state_machine_task_finished-refactoring branch from 31de2a3 to 9ba87f8 Compare October 31, 2019 02:37
@GregP GregP changed the title [WIP] Refactor AE Content Task Finished method and add spec Refactor AE Content Task Finished method and add spec Oct 31, 2019
@miq-bot miq-bot removed the wip label Oct 31, 2019
@tinaafitz
Copy link
Member

Hi @GregP Can you address the rubocop issue?

@GregP GregP force-pushed the state_machine_task_finished-refactoring branch from 9ba87f8 to 16d02c8 Compare October 31, 2019 22:44
@handle.create_notification(:type => :automate_service_provisioned, :subject => task.destination) if task.miq_request_task.nil?
when 'miq_provision'
final_message += "VM [#{task.get_option(:vm_target_name)}] "
final_message += "IP [#{task.vm.ipaddresses.first}] " if task.vm && !task.vm.ipaddresses.blank?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GregP Rubocop called out this line which @tinaafitz was referencing in her comment. Along the the rubocop recommendation to use present? the condition can be simplified to:

if task.vm&.ipaddresses.present?

@GregP GregP force-pushed the state_machine_task_finished-refactoring branch 2 times, most recently from 4d730e1 to 3ff16a0 Compare November 1, 2019 21:44
@handle.create_notification(:type => :automate_service_provisioned, :subject => task.destination) if task.miq_request_task.nil?
when 'miq_provision'
final_message += "VM [#{task.get_option(:vm_target_name)}] "
final_message += "IP [#{task.vm.ipaddresses.first}] " if task.vm.ipaddresses.present?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GregP Thanks for updating this but you missed the & mentioned in my original comment #589 (comment) which adds safe navigation to the condition in place of the multi-part AND condition: if @task.vm && [email protected]?

See http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby

This should really be: if task.vm&.ipaddresses.present?

@GregP GregP force-pushed the state_machine_task_finished-refactoring branch from 3ff16a0 to d5d7b7b Compare November 4, 2019 21:09
@miq-bot
Copy link
Member

miq-bot commented Nov 4, 2019

Checked commit GregP@d5d7b7b with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. ⭐

@tinaafitz tinaafitz merged commit e1690ea into ManageIQ:master Nov 4, 2019
@tinaafitz tinaafitz added this to the Sprint 124 Ending Nov 11, 2019 milestone Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants