Skip to content
New issue

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

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

Already on GitHub? # to your account

Error: undefined method `any?' for nil:NilClass when generating documentation #287

Closed
hajee opened this issue Jul 30, 2021 · 0 comments · Fixed by #289
Closed

Error: undefined method `any?' for nil:NilClass when generating documentation #287

hajee opened this issue Jul 30, 2021 · 0 comments · Fixed by #289

Comments

@hajee
Copy link
Contributor

hajee commented Jul 30, 2021

Describe the bug

When given the command: puppet strings generate --format markdown an error is thrown

Error: undefined method `any?' for nil:NilClass
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-strings-2.6.0/lib/puppet-strings/yard/code_objects/type.rb:156:in `parameters'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-strings-2.6.0/lib/puppet-strings/yard/code_objects/type.rb:188:in `to_hash'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-strings-2.6.0/lib/puppet-strings/markdown/resource_types.rb:10:in `map!'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-strings-2.6.0/lib/puppet-strings/markdown/resource_types.rb:10:in `in_rtypes'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-strings-2.6.0/lib/puppet-strings/markdown/resource_types.rb:32:in `toc_info'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-strings-2.6.0/lib/puppet-strings/markdown/table_of_contents.rb:15:in `block in render'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-strings-2.6.0/lib/puppet-strings/markdown/table_of_contents.rb:14:in `each'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-strings-2.6.0/lib/puppet-strings/markdown/table_of_contents.rb:14:in `render'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-strings-2.6.0/lib/puppet-strings/markdown.rb:21:in `generate'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-strings-2.6.0/lib/puppet-strings/markdown.rb:40:in `block in render'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-strings-2.6.0/lib/puppet-strings/markdown.rb:40:in `open'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-strings-2.6.0/lib/puppet-strings/markdown.rb:40:in `render'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-strings-2.6.0/lib/puppet-strings.rb:83:in `render_markdown'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-strings-2.6.0/lib/puppet-strings.rb:64:in `generate'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-strings-2.6.0/lib/puppet/face/strings.rb:35:in `block (3 levels) in <top (required)>'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-7.1.0-universal-darwin/lib/puppet/interface/action.rb+eval[wrapper]:261:in `generate'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-7.1.0-universal-darwin/lib/puppet/application/face_base.rb:254:in `main'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-7.1.0-universal-darwin/lib/puppet/application.rb:437:in `run_command'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-7.1.0-universal-darwin/lib/puppet/application.rb:421:in `block in run'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-7.1.0-universal-darwin/lib/puppet/util.rb:735:in `exit_on_fail'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-7.1.0-universal-darwin/lib/puppet/application.rb:421:in `run'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-7.1.0-universal-darwin/lib/puppet/util/command_line.rb:143:in `run'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-7.1.0-universal-darwin/lib/puppet/util/command_line.rb:77:in `execute'
/Users/hajee/.rvm/gems/ruby-2.6.6/gems/puppet-7.1.0-universal-darwin/bin/puppet:5:in `<top (required)>'
/Users/hajee/.rvm/gems/ruby-2.6.6/bin/puppet:23:in `load'
/Users/hajee/.rvm/gems/ruby-2.6.6/bin/puppet:23:in `<main>'
/Users/hajee/.rvm/gems/ruby-2.6.6/bin/ruby_executable_hooks:24:in `eval'
/Users/hajee/.rvm/gems/ruby-2.6.6/bin/ruby_executable_hooks:24:in `<main>'
Error: Try 'puppet help strings generate' for usage

No output is written

Expected Behavior

strings should not error. It should at least generate the documentation for the correct puppet code.

Steps to Reproduce

Have a non valid (or not finished) puppet type and provider available:

Puppet::Type.newtype(:any_error) do
end

and a provider:

Puppet::Type.type(:any_error).provide(:simple) do
  mk_resource_methods
end

Now run puppet strings:

puppet strings generate --format markdown

Environment

All

hajee added a commit to enterprisemodules/puppet-strings that referenced this issue Jul 30, 2021
…labs#287

In some rare cases where no parameter is (yet) defined in the type, an error is thrown

```
Error: undefined method `any?' for nil:NilClass
```
@da-ar da-ar closed this as completed in #289 Aug 2, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
1 participant