ManageIQ / manageiq-providers-vmware

ManageIQ plugin for the VMware vSphere and vCloud providers.
Apache License 2.0
22 stars 70 forks source link

remove return from supports blocks #915

Closed kbrock closed 2 months ago

kbrock commented 2 months ago

Part of https://github.com/ManageIQ/manageiq/pull/22898 (as a followup) Introduced by https://github.com/ManageIQ/manageiq-providers-vmware/pull/901

Return from a block behaves in strange ways. What we wanted is to return that value from the block (aka, acted like it is a proc)

Solution is to change the order of the if block so we can avoid supports? and avoid setting a variable. (and obviously, avoiding the bad return)

Error

ERROR -- evm: [LocalJumpError]: unexpected return  Method:[block (2 levels) in <class:LogProxy>]
ERROR -- evm:
manageiq-providers-vmware/app/models/manageiq/providers/vmware/infra_manager/vm/operations/guest.rb:20:
  in `block (2 levels) in <module:Guest>'
manageiq/app/models/mixins/supports_feature_mixin.rb:113:in `instance_eval'
manageiq/app/models/mixins/supports_feature_mixin.rb:113:in `check_supports'
manageiq/app/models/mixins/supports_feature_mixin.rb:71:in `supports?'
miq-bot commented 2 months ago

Checked commit https://github.com/kbrock/manageiq-providers-vmware/commit/2855abb7bbe8a504439b28f70d1f395e08d7a18a with ruby 3.1.5, rubocop 1.56.3, haml-lint 0.51.0, and yamllint 1 file checked, 0 offenses detected Everything looks fine. :star: