Sort the gathered controller helper includes in dsl/compilers/action_controller_helpers.rb #2202
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
We run
tapioca dsl
as part of our CI process. We noticed that when we made a change to one Rails controller, we would sometimes get different include orderings being generated in completely unrelated controllers. The only thing that would change is the ordering of the helperinclude
's.Tapioca should sort the gathered
include
's so that the output is deterministic here.I'm not sure about the initial motivation of doing the
reverse
here, is there any risk to making this change? Like, is there a reason the includes were ordered in this fashion to begin with? I believe the ordering is completely arbitrary; for our project, after making this change, there were a TON of RBI file updates, butsrb tc
still passed fine. So it seems like the ordering is arbitrary for our project, at least.Implementation
Call
.sort
on the array of qualified names at the end ofdef gather_includes(mod)
.Tests
I have included a new test which sorts
Bravo/Alpha/Charlie
helpers to =>Alpha/Bravo/Charlie
.Note: I'm using IntelliJ, and so I've also included a change to
.gitignore
to omit my editor's files. Please let me know if you need that to go into its own separate PR instead!