-
-
Notifications
You must be signed in to change notification settings - Fork 400
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
Unpredictable load order for Ruby files causing randomness in undocumented reports. #1134
Comments
I believe this might be fixed by #1123 |
Hello @isegal, yes indeed this would fix that (or at least minimise the impact as a real fix would be a custom sorting option). Is there a chance for a release with this change? |
@mensfeld the PR is still in review. It looks like it's blocked on PR updates. If you want to pick them up and run with it, feel free! |
Somewhat unrelated, but in the PR I mentioned some commits to RubyGems re unstable sort. I did one of them (PR), and I think both were related to Linux vs Windows differences. You've got differences between MacOS/OSX and Windows/Linux. Upon checking, RubyGems is not tested against MacOS/OSX, just Linux and Windows. EDIT: RubyCI.org does have MacOS/OSX testing. Another reason to never expect a stable sort... |
This should be fixed and released in 0.9.10. Thanks for reporting and thanks @MSP-Greg for the fix! |
@lsegal thank you. |
@lsegal it's weird but I still observe this behavior :/ is there a way to impose custom order to sort for example by name? |
@lsegal re-pinging you in case you have an answer to my question :) |
Unpredictable load order for Ruby files causing randomness with undocumented reports.
This problem is really tricky to reproduce due to the fact, that it requires different OS to be involved, so let me draw the context here.
I use
yard stats --list-undoc
to track undocumented objects within the code base. This is really really helpful for refactoring and documenting bigger systems. I have several parsers and tools wrapping raw yard output, so I can format it nicer. However what I've noticed, is that due to the fact that the code that I'm working on is developed both on Mac and Linux, the system reports same undocumented results for different files if undocumented object occurs in both of them when being executed exactly the same way on different OSes (or sometimes with the same OS, when changes were applied on the other one).This happens due to the fact, that the behavior or Dir.glob can not be relied upon to be the same across different OSs. Not sure if this is by design, but rather an artifact of the file-systems.
On Windows and Linux the results are sorted by hierarchy, and then alphabetically; On Mac OS X the results are sorted alphabetically.
It seems to be related to this area of the code (not the particular line though):
https://github.com/lsegal/yard/blob/master/lib/yard/cli/yardoc.rb#L406
Steps to reproduce
Note: due to the fact, that Dir.glob is more or less unpredictable, it can be hard to replicate that issue without a bit of experimenting in between OSes, however the
Dir.glob
problem is widely known. This can be simulated on one OS by changing the file hierarchy in between executions and this is how the replication here goes.This is the minimal reproduction for the issue. I've done my best to remove
all extraneous code and unique environment state on my machine before providing
these steps:
yard stats --list-undoc --debug
b
withina
a move there yourtest.rb
file, so the structure looks like this:yard stats --list-undoc --debug
Actual Output
When the execution results are diffed:
Expected Output
I would expect it to always report the first occurence in the alphabetical order.
Environment details:
ruby -v
): ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]yard -v
): yard 0.9.9Recommended way of fixing this issue
The
Dir.glob
output should be sorted. That's all that is required. Then it will be predictable across OSes.Ideal way of fixing this issue
The ideal would be a possibility to inject own order into yard somehow. This would allow people like me to prioritize files by their creation date (oldest first), so I would get pretty stable results despite adding new files to the structure that could provide additional noise.
I have read the Contributing Guide.
The text was updated successfully, but these errors were encountered: