Use deep recursion when changing snake to camel case in Diffs
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
This would affect all of the places in the codebase that rely on the Diffs store. This is most obviously the MR diffs views, but could touch other places.
Spawned from maintainer review comment
Improvements
We convert the top-level keys in objects being placed in the Diffs store to camelcase, but the default is to stop at that top level, which is not really in line with the intent (consistent naming on the frontend), and results in some amount of jumping through hoops later.
By using {deep:true}
we can consistently expect "properly" named camelcase properties on all diffs objects in the store.
Risks
There are quite a few places that rely on diff objects. Most notably the MR changes tab uses the diffs very heavily.
The only way to avoid breaking these features is to carefully trace Vuex state diffFiles
as they're passed throughout the system of components. Fortunately, the changes aren't very intrusive, so once {deep:true}
is enabled for setting data into the store, the changes throughout the rest of the codebase will essentially be converting _(\w)
to $1.toUpperCase()
. This is non-trivial, but also not complex.
Involved components
The safest assumption is that every file in app/assets/javascripts/diffs
will need to be updated, but it's unlikely that every single file will directly access data stored in the Vuex store. More likely, higher-level components will ingest the data and then distribute smaller chunks to lower-level components. If that's the case, the vast majority of the updates will need to happen in a large handful of top-level components.
Of course the store (and actions, mutations, getters) will need to be heavily updated.
Optional: Intended side effects
Not only will this change get the Diffs code closer to having truly consistent property names, it will also reduce the number of workarounds for snake case properties that sometimes need to be used.