swaggest / json-diff

JSON diff/rearrange/patch/pointer library for PHP
MIT License
220 stars 30 forks source link

Fix and improve rearrange #44

Closed vearutop closed 3 years ago

vearutop commented 3 years ago

Resolves #43. Fixes #38.

This PR removes unnecessary keys stripping as suggested in https://github.com/swaggest/json-diff/issues/43#issue-1004330514.

Also it adds rearrangement criteria for non-scalar properties (only objects) using XOR hash.

Also it fixes XOR hash collision when having pairs of properties with similarities in name, e.g. hash of {"aX":1,"bX":1} was equal to hash of {"aY":1,"bY":1}.

github-actions[bot] commented 3 years ago

Lines Of Code

Language Files Lines Code Comments Blanks Complexity Bytes
JSON 11 (+2) 3439 (+1230) 3421 (+1230) 0 18 0 83.1K (+50.9K)
Markdown 2 369 (+10) 261 (+7) 0 108 (+3) 0 11.2K (+323B)
PHP 34 3634 (+118) 2848 (+87) 270 (-1) 516 (+32) 200 (+1) 93.2K (+4.2K)
codecov[bot] commented 3 years ago

Codecov Report

Merging #44 (9c3e873) into master (d223be0) will decrease coverage by 0.15%. The diff coverage is 93.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #44      +/-   ##
==========================================
- Coverage   96.79%   96.63%   -0.16%     
==========================================
  Files          10       10              
  Lines         530      535       +5     
==========================================
+ Hits          513      517       +4     
- Misses         17       18       +1     
Impacted Files Coverage Δ
src/JsonDiff.php 96.20% <93.33%> (-0.40%) :arrow_down:
src/JsonHash.php 94.59% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d223be0...9c3e873. Read the comment docs.