Do not call return inside of an initialize method.

It does NOT do what you think it does. It does NOT prevent an object
from coming back. All it does is have an uninitialized (or partially
initialized) object come back, which isn't helpful.

Signed-off-by: Ryan Davis <zenspider@chef.io>
This commit is contained in:
Ryan Davis 2019-07-18 14:42:47 -07:00
parent 18c1b8d39c
commit cd5f58f8eb

View file

@ -86,12 +86,7 @@ module Inspec
@__backend_runner__ = backend @__backend_runner__ = backend
@__resource_name__ = name @__resource_name__ = name
# check resource supports check_supports unless @supports.nil? # this has side effects
supported = true
supported = check_supports unless @supports.nil?
test_backend = defined?(Train::Transports::Mock::Connection) && backend.backend.class == Train::Transports::Mock::Connection
# do not return if we are supported, or for tests
return unless supported || test_backend
# call the resource initializer # call the resource initializer
begin begin
@ -103,6 +98,7 @@ module Inspec
rescue NoMethodError => e rescue NoMethodError => e
# The new platform resources have methods generated on the fly # The new platform resources have methods generated on the fly
# for inspec check to work we need to skip these train errors # for inspec check to work we need to skip these train errors
test_backend = defined?(Train::Transports::Mock::Connection) && backend.backend.class == Train::Transports::Mock::Connection
raise unless test_backend && e.receiver.class == Train::Transports::Mock::Connection raise unless test_backend && e.receiver.class == Train::Transports::Mock::Connection
skip_resource(e.message) skip_resource(e.message)