From 7dca12cc53532ad1308113b2b09d51815897851f Mon Sep 17 00:00:00 2001 From: James Couball Date: Mon, 3 Jan 2022 07:57:58 -0800 Subject: [PATCH] Only call Object#taint when it is supported Signed-off-by: James Couball --- lib/yard/cli/stats.rb | 3 ++- lib/yard/cli/yardoc.rb | 3 ++- lib/yard/templates/template.rb | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/yard/cli/stats.rb b/lib/yard/cli/stats.rb index b9145ffe6..11e187951 100644 --- a/lib/yard/cli/stats.rb +++ b/lib/yard/cli/stats.rb @@ -225,7 +225,8 @@ def general_options(opts) end opts.on('--query QUERY', "Only includes objects that match a specific query") do |query| - options[:verifier].add_expressions(query.taint) + query.taint if query.respond_to?(:taint) + options[:verifier].add_expressions(query) end end end diff --git a/lib/yard/cli/yardoc.rb b/lib/yard/cli/yardoc.rb index 9308ac169..7325644f5 100644 --- a/lib/yard/cli/yardoc.rb +++ b/lib/yard/cli/yardoc.rb @@ -650,7 +650,8 @@ def output_options(opts) opts.on('--query QUERY', "Only show objects that match a specific query") do |query| next if YARD::Config.options[:safe_mode] - options.verifier.add_expressions(query.taint) + query.taint if query.respond_to?(:taint) + options.verifier.add_expressions(query) end opts.on('--title TITLE', 'Add a specific title to HTML documents') do |title| diff --git a/lib/yard/templates/template.rb b/lib/yard/templates/template.rb index 975be87c5..6450bcb50 100644 --- a/lib/yard/templates/template.rb +++ b/lib/yard/templates/template.rb @@ -176,7 +176,9 @@ def include_inherited(full_paths) def load_setup_rb setup_file = File.join(full_path, 'setup.rb') if File.file? setup_file - module_eval(File.read(setup_file).taint, setup_file, 1) + setup_code = File.read(setup_file) + setup_code.taint if setup_code.respond_to?(:taint) + module_eval(setup_code, setup_file, 1) end end end