Consolidate diff output filtering#311
Merged
rs545837 merged 1 commit intoJun 4, 2026
Merged
Conversation
This was referenced Jun 2, 2026
There was a problem hiding this comment.
inspect review
Triage: 106 entities analyzed | 0 critical, 0 high, 48 medium, 58 low
Verdict: standard_review
Findings (7)
- [low] In
recalculate_diff_summary, compound changes (Moved/Renamed/Reordered with content changes) are double-counted inmodified_count. The logic incrementsmodified_countfor both the change type bucket AND whenhas_content_change()is true, but these should be mutually exclusive counts. - [low] In
retain_non_cosmetic_changes, the filter logic allows Moved/Renamed/Reordered changes to pass through even whenstructural_change == Some(false), but the comment says 'Drop purely cosmetic changes'. This creates inconsistency where cosmetic compound changes are retained while cosmetic modifications are dropped. - [low] In
orphan_structural_change, the function returnsSome(bool)but callsplugin.structural_hash_content()which also returnsOption<String>. If the plugin returnsNonefor either before or after content, the function returnsNone, meaning orphan changes will havestructural_change: Noneinstead of a definitive true/false, breaking the assumption that orphans always have structural_change set. - [low] In
diff_commandfor file comparison mode, whencontent_aorcontent_bisNone(binary), the code creates a FileChange but setsbefore_contentandafter_contentto the Option values directly. This means binary files will haveNonecontent, but the status is alwaysFileStatus::Modifiedeven if one side doesn't exist (should be Added/Deleted). - [low] In
parse_unified_diff, the code setshas_binary_content = truewhenread_file_compare_contentreturnsOk(None), but this flag is only used in the final checkif !has_binary_content && before_content.is_none() && after_content.is_none(). If only the after_content is binary (before is text), the warning will still print becausebefore_content.is_none()is false, even though we detected binary content. - [low] In
retain_non_cosmetic_changes, the filter logic allows cosmetic Moved/Renamed/Reordered changes to pass through, but the comment says 'Drop purely cosmetic changes'. This creates inconsistency where cosmetic modifications are dropped but cosmetic moves/renames/reorders are kept, which may not be the intended behavior. - [low] In
orphan_structural_change, the function callsplugin.structural_hash_content()withbefore_content.unwrap_or_default()andafter_content.unwrap_or_default(). If both areNone, this will compare empty strings and returnSome(false), incorrectly marking a deletion or addition as non-structural when it should be structural.
Reviewed by inspect | Entity-level triage found 0 high-risk changes
f16a0df to
507e0be
Compare
There was a problem hiding this comment.
inspect review
Triage: 106 entities analyzed | 0 critical, 0 high, 48 medium, 58 low
Verdict: standard_review
Findings (7)
- [low] In
recalculate_diff_summary, compound changes (Moved/Renamed/Reordered with content changes) are double-counted inmodified_count. The logic adds 1 to both the change-type bucket (moved_count/renamed_count/reordered_count) AND modified_count, but the summary total calculation doesn't account for this double-counting, leading to inflated totals. - [low] In
retain_non_cosmetic_changes, the logic now preserves Moved/Renamed/Reordered changes even whenstructural_change == Some(false), but this contradicts the intent to drop purely cosmetic changes. A cosmetic move/rename/reorder should still be dropped if it has no structural impact. - [low] In
diff_commandfor file comparison mode, whencontent_aorcontent_bisNone(binary), the code creates a FileChange withstatus: FileStatus::Modifiedunconditionally. However, if one side doesn't exist (e.g., comparing /dev/null to a binary file), this should beAddedorDeleted, notModified. - [low] In
orphan_structural_change, the function callsplugin.structural_hash_content()withbefore_content.unwrap_or_default()andafter_content.unwrap_or_default(). If both are None (binary files), this will hash empty strings and returnSome(false), incorrectly marking binary changes as non-structural. - [low] In
read_file_compare_content, the function returnsOk(None)for binary files but returns anErrfor UTF-8 conversion errors. The caller indiff_commandtreats both cases differently:Ok(None)setshas_binary_content = true, butErr(_)is silently ignored with an empty match arm, potentially causing the file to be skipped entirely instead of being reported as binary. - [low] In
file_compare_changescall site, when content_a or content_b is None (binary), the code creates a FileChange with both before_content and after_content potentially None, but then passes(vec![change], false). However, the tuple's second element (language_mismatch boolean) is hardcoded tofalseeven though no language comparison was performed. This could mask actual language mismatches in mixed text/binary scenarios. - [low] In
orphan_structural_change, the function returnsSome(bool)but callsplugin.structural_hash_content()which also returnsOption<String>. If the plugin returns None for either before or after hash, the function returns None, meaning structural_change will be None. However, the testorphan_code_change_is_structuralexpectsSome(true), suggesting the code should handle None hashes differently (e.g., treat missing hash as structural change).
Reviewed by inspect | Entity-level triage found 0 high-risk changes
This was referenced Jun 4, 2026
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
Supersedes #237, #290, #294.
Closes #181.
Closes #273.
Fixes #272.
Test plan