From fdc281d19c70b6f262e881dc3793273a1074c32a Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Sat, 28 Dec 2019 14:48:32 -0800 Subject: [PATCH] Clean up the end of our custom require. There are only 2 options. Shortcutting one of them with a `require` just makes it messy. Use `if`. It's really basic. Basic is good. Maybe we should try to push towards basic and good. It would be work but make us happier in the long run. Signed-off-by: Ryan Davis --- lib/inspec/dsl_shared.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/inspec/dsl_shared.rb b/lib/inspec/dsl_shared.rb index 331df2970..2a610e463 100644 --- a/lib/inspec/dsl_shared.rb +++ b/lib/inspec/dsl_shared.rb @@ -23,9 +23,11 @@ module Inspec # context that provides the correct plane to evaluate all required files to. # It will ensure that embedded calls to `require` still call this # method and get loaded from their correct paths. - return __inspec_binding.eval(content, path, line) if defined?(__inspec_binding) - - eval(content, TOPLEVEL_BINDING, path, line) # rubocop:disable Security/Eval + if defined?(__inspec_binding) + __inspec_binding.eval(content, path, line) + else + eval(content, TOPLEVEL_BINDING, path, line) # rubocop:disable Security/Eval + end end end end