Sort fingerprints when writing .sobelow-skips#185
Open
palm86 wants to merge 1 commit into
Open
Conversation
`Fingerprint.new_skips/0` returns `MapSet.to_list/1`, whose order is implementation-defined. The previous write path joined the list as-is, so re-running `--mark-skip-all` over the same set of findings could produce different line orderings, churning the file in version control. Sorting at the write boundary makes the on-disk output stable.
Contributor
|
Hey @palm86 - thank you so much for the contribution! If you could, would you mind opening this as a PR on the new Sobelow repo? This PR belongs to the unmaintained version and it will no longer be receiving updates. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Sobelow.mark_skip_all/1writes the deduplicated set of findingfingerprints to
.sobelow-skips. The list comes fromFingerprint.new_skips/0, which returnsMapSet.to_list/1— andMapSetiteration order is implementation-defined, not stable.Today the writer joins that list as-is:
So running
mix sobelow --mark-skip-alltwice over the same set offindings can produce different line orderings in
.sobelow-skips,which is noisy in code review and in git history when the file is
committed.
This change sorts the fingerprints before joining, making the on-disk
output deterministic for a given set of skipped findings:
Note on tests
There is no existing coverage for the
.sobelow-skipswrite path. Iconsidered adding one but the function is
defpand exercising itend-to-end via the Mix task felt disproportionate to the size of this
fix. Happy to add coverage if you'd like to weigh in on the preferred
shape.