Summary
excluded_files only recognizes the space-separated --exclude pattern form. If .yardopts or the command line contains --exclude=vendor (equals-sign syntax), the argument string "--exclude=vendor" does not == "--exclude", so the exclusion pattern is silently ignored. No files are excluded and examples from those files are run unexpectedly.
Location
lib/yard/cli/test_examples.rb — excluded_files
def excluded_files
excluded = []
args = YARD::Config.with_yardopts { YARD::Config.arguments.dup }
args.each_with_index do |arg, i|
next unless arg == '--exclude'
next if args[i + 1].nil?
excluded << args[i + 1]
end
excluded
end
Concrete example
.yardopts:
--plugin yard_example_test
--exclude=vendor
Current behavior: excluded_files returns [] — vendor/ files are parsed and their examples are run.
Expected behavior: excluded_files returns ["vendor"].
Proposed solution
Handle both forms by checking for the = prefix as well:
def excluded_files
excluded = []
args = YARD::Config.with_yardopts { YARD::Config.arguments.dup }
args.each_with_index do |arg, i|
if arg == '--exclude'
excluded << args[i + 1] unless args[i + 1].nil?
elsif arg.start_with?('--exclude=')
excluded << arg.delete_prefix('--exclude=')
end
end
excluded
end
Alternatively, use OptionParser or a regex like /\A--exclude(?:=(.+))?\z/ to handle both forms in one pass.
Acceptance criteria
Summary
excluded_filesonly recognizes the space-separated--exclude patternform. If.yardoptsor the command line contains--exclude=vendor(equals-sign syntax), the argument string"--exclude=vendor"does not=="--exclude", so the exclusion pattern is silently ignored. No files are excluded and examples from those files are run unexpectedly.Location
lib/yard/cli/test_examples.rb—excluded_filesConcrete example
.yardopts:Current behavior:
excluded_filesreturns[]—vendor/files are parsed and their examples are run.Expected behavior:
excluded_filesreturns["vendor"].Proposed solution
Handle both forms by checking for the
=prefix as well:Alternatively, use
OptionParseror a regex like/\A--exclude(?:=(.+))?\z/to handle both forms in one pass.Acceptance criteria
--exclude=patternin.yardoptsexcludes matching files--exclude pattern(space-separated) continues to work