Skip to content

Add adaptive max_depth and max_items handling in diff_objects#36

Open
top-sigrid wants to merge 8 commits intomarcoroth:mainfrom
top-sigrid:fix/adaptive-max-depth-and-max-items
Open

Add adaptive max_depth and max_items handling in diff_objects#36
top-sigrid wants to merge 8 commits intomarcoroth:mainfrom
top-sigrid:fix/adaptive-max-depth-and-max-items

Conversation

@top-sigrid
Copy link

Fixes #35.

When comparing deeply nested structures or large arrays, diff_objects could return misleading "No changes. output because PrettyPlease truncates content beyond the passed max_depth & max_items limits. If both objects are truncated identically, no diff is shown even though the actual objects differ.

See also the issue in minitest-difftastic for details.

I concluded - based on our exchange in the minitest-difftastic issue, that this is best fixed here and minitest-difftastic actually doesn't need any adjustments.

This PR makes max_depth and max_items handling adaptive in diff_objects, increasing these, up until exceeding newly defined cap values, until either:

  • A diff is found (strings differ after prettification) with higher max values
  • Both caps are reached → returns "[Diff unavailable: exceeded depth/size display limits]"

Also more of these configurations are exposed in Difftastic::Differ.initialize for libraries and gems building upon this to customize this behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

diff_objects shows "No changes" for deeply nested structures

1 participant

Comments