Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bundle exec yard stats --list-undoc fails with exception #792

Closed
bpziegler opened this issue Jul 29, 2014 · 3 comments
Closed

bundle exec yard stats --list-undoc fails with exception #792

bpziegler opened this issue Jul 29, 2014 · 3 comments

Comments

@bpziegler
Copy link

bundle exec yard stats --list-undoc

is generating the exception below for me. I made a small patch that fixes this:

~/.rvm/gems/ruby-1.9.3-p547/gems/yard-0.8.7.4/lib/yard/cli/stats.rb
79- objects = @undoc_list.sort_by {|o| o.file }
79- objects = @undoc_list.sort_by {|o| o.file || "" }

/Users/benziegler/.rvm/gems/ruby-1.9.3-p547/gems/yard-0.8.7.4/lib/yard/cli/stats.rb:79:in sort_by': comparison of String with nil failed (ArgumentError) from /Users/benziegler/.rvm/gems/ruby-1.9.3-p547/gems/yard-0.8.7.4/lib/yard/cli/stats.rb:79:inprint_undocumented_objects'
from /Users/benziegler/.rvm/gems/ruby-1.9.3-p547/gems/yard-0.8.7.4/lib/yard/cli/stats.rb:44:in run' from /Users/benziegler/.rvm/gems/ruby-1.9.3-p547/gems/yard-0.8.7.4/lib/yard/cli/command.rb:13:inrun'
from /Users/benziegler/.rvm/gems/ruby-1.9.3-p547/gems/yard-0.8.7.4/lib/yard/cli/command_parser.rb:71:in run' from /Users/benziegler/.rvm/gems/ruby-1.9.3-p547/gems/yard-0.8.7.4/lib/yard/cli/command_parser.rb:53:inrun'
from /Users/benziegler/.rvm/gems/ruby-1.9.3-p547/gems/yard-0.8.7.4/bin/yard:12:in <top (required)>' from /Users/benziegler/.rvm/gems/ruby-1.9.3-p547/bin/yard:23:inload'
from /Users/benziegler/.rvm/gems/ruby-1.9.3-p547/bin/yard:23:in <main>' from /Users/benziegler/.rvm/gems/ruby-1.9.3-p547/bin/ruby_executable_hooks:15:ineval'
from /Users/benziegler/.rvm/gems/ruby-1.9.3-p547/bin/ruby_executable_hooks:15:in `

'

@nielsm
Copy link

nielsm commented Jul 29, 2014

The actual error appears to be caused on line 133 of stats.rb @undoc_list |= undoc if @undoc_list

Changing it to @undoc_list ||= undoc if @undoc_list resolves the issue. Not sure what |= is meant to do

@lsegal
Copy link
Owner

lsegal commented Jul 31, 2014

The | operator is a set union operator on lists. Doing list |= [value] returns the union of list and [value], which is another way to ensure uniqueness of the list.

Switching to ||= would not "resolve" the issue since they don't mean the same thing, it would just mask the bug (by also introducing new bugs).

o.file.to_s would be a better way to resolve this.

@nielsm
Copy link

nielsm commented Jul 31, 2014

Makes sense. It's an unusual operator, so I incorrectly assumed it was a typo.

@lsegal lsegal closed this as completed in 76c7525 Aug 1, 2014
lsegal added a commit that referenced this issue Oct 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants