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

Fix "annotate models" functionality for models in subdirectories #38762

Merged
merged 4 commits into from
Jan 28, 2021

Conversation

Hamms
Copy link
Contributor

@Hamms Hamms commented Jan 27, 2021

Follow-up to #37175

Since upgrading the annotate gem as part of the Rails upgrade work, we've been getting warnings indicating that the gem is unable to annotate any of our models contained in subdirectories of the models dir:

Unable to annotate app/models/sections/section.rb: no implicit conversion of Pathname into String

I discovered that this is an open bug in annotate (ctran/annotate_models#758) and in fact some other users had already done the investigation to figure out exactly what change needed to be made. I opened a PR to implement their fix (ctran/annotate_models#848), but while we wait for it to get accepted and released I figured we might as well implement a workaround.

The simple workaround is to make sure that the configuration variable containing the paths to look in for files consists of just strings and no Pathnames.

Testing story

Ran bundle exec annotate --models; confirmed that not only does it run without generating warnings but it also successfully updates the annotations for the models it was previously warning about. I've included those updates in this PR.

Reviewer Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

# We have a PR opened with a fix at https://github.com/ctran/annotate_models/pull/848;
# once a version of the gem is released which includes that change, we can get rid of
# this line.
config.autoload_paths.map!(&:to_s)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great find, @Hamms !

@Hamms Hamms merged commit 991f5b5 into staging Jan 28, 2021
@Hamms Hamms deleted the fix-annotate-paths branch January 28, 2021 02:21
@bencodeorg
Copy link
Contributor

@Hamms I think we lost an annotation that was recently added to dashboard/app/models/featured_project.rb in this PR?

@Hamms
Copy link
Contributor Author

Hamms commented Jan 29, 2021

oh, it's very possible that I was missing I migration when I did this. I do see that rerunning annotate now does produce an annotation on that model file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants