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

Make sure deleted object's entries are removed from object_types #1284

Merged
merged 2 commits into from
Oct 30, 2019

Conversation

tomoasleep
Copy link
Contributor

Description

Previously, YARD::RegistryStore#delete removes an object entry from @store but does not remove its entry from @object_types.
Therefore, some elements of YARD::Registry.all may be nil after an object deletion such as the following code.

$ pry
[1] pry(main)> require 'yard'
=> true
[2] pry(main)> YARD::Registry.register(foo = YARD::CodeObjects::ModuleObject.new(nil, :Foo))
=> #<yardoc module Foo>
[3] pry(main)> YARD::Registry.register(bar = YARD::CodeObjects::ModuleObject.new(nil, :Bar))
=> #<yardoc module Bar>
[4] pry(main)> YARD::Registry.all(:module)
=> [#<yardoc module Foo>, #<yardoc module Bar>]
[5] pry(main)> YARD::Registry.delete(foo)
=> #<yardoc module Foo>
[6] pry(main)> YARD::Registry.all(:module)
=> [nil, #<yardoc module Bar>]

This PR makes sure that YARD::RegistryStore#delete remove the deleted object's entry from @object_types to fix this behavior.

Completed Tasks

  • I have read the Contributing Guide.
  • The pull request is complete (implemented / written).
  • Git commits have been cleaned up (squash WIP / revert commits).
  • I wrote tests and ran bundle exec rake locally (if code is attached to PR).

@coveralls
Copy link

coveralls commented Oct 30, 2019

Coverage Status

Coverage decreased (-0.07%) to 93.699% when pulling 3a4c122 on tomoasleep:fix-registry-store-delete into 890d4ad on lsegal:master.

@lsegal lsegal merged commit 4b5c875 into lsegal:master Oct 30, 2019
@lsegal
Copy link
Owner

lsegal commented Oct 30, 2019

Thanks for this PR!

@tomoasleep tomoasleep deleted the fix-registry-store-delete branch November 2, 2019 12:26
lsegal added a commit that referenced this pull request Dec 31, 2019
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

Successfully merging this pull request may close these issues.

3 participants