Follow-up from "Fix authoritative source of truth for diff files when loading batched diffs"
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Work on this issue](https://contributors.gitlab.com/manage-issue?action=work&projectId=278964&issueIid=205191) - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=205191) </details> <!--IssueSummary end--> The following discussion from !23274 should be addressed: - [ ] @pslaughter started a [discussion](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/23274#note_286550250): (+1 comment) > **suggestion (non-blocking):** This part is a bit awkward because our main motivation for calling `prepareDiffData` in this context is to initialize our `diff` object (not necessarily combine or dedupe anything). This is a smell that our `prepareDiffData` is not cohesive and is doing too much (i.e. merging with previous files **and** setting up the object given to it). > > IMHO, we could simplify things a bit if we split up `prepareDiffData` into > > ```javascript > import { flow } from 'lodash'; > > export const prepareDiffFile = flow([ > ensureBasicDiffFileLines, > prepareDiffFileLines, > finalizeDiffFile, > ]); > > export function prepareDiffData(files = []) { > return files.map(prepareDiffFile); > } > > export function mergeDiffFiles(newFiles, priorFiles = []) { > return deduplicateFilesList([...priorFiles, ...newFiles]); > } > ``` > > If you think something like this is helpful, can we handle it here or in a follow-up?
issue