Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(yaml): move duplicate and duplicateIndex #5836

Merged
merged 6 commits into from
Aug 29, 2024

Conversation

timreichen
Copy link
Contributor

@timreichen timreichen commented Aug 27, 2024

Changes
This PR moves duplicate and duplicateIndex code inside isObject() block, to avoid double check.

Note One line (tag !== null && tag !== "?") is not covered. Seems like tag is always null if the value is an object.

@timreichen timreichen requested a review from kt3k as a code owner August 27, 2024 06:13
@github-actions github-actions bot added the yaml label Aug 27, 2024
Copy link

codecov bot commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 95.55556% with 2 lines in your changes missing coverage. Please review.

Project coverage is 96.25%. Comparing base (0a71a4d) to head (24f610b).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
yaml/_dumper_state.ts 95.55% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5836      +/-   ##
==========================================
- Coverage   96.26%   96.25%   -0.01%     
==========================================
  Files         479      479              
  Lines       38705    38698       -7     
  Branches     5617     5617              
==========================================
- Hits        37258    37250       -8     
  Misses       1404     1404              
- Partials       43       44       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

}
if (duplicate) {
if (this.usedDuplicates.has(value)) return `*ref_${duplicateIndex}`;
this.usedDuplicates.add(value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to pertain to the main objective of this PR.

Copy link
Contributor Author

@timreichen timreichen Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (duplicate) {...} would be checked twice otherwise, no?

Comment on lines +792 to +798
if (
(tag !== null && tag !== "?") ||
duplicate ||
(this.indent !== 2 && level > 0)
) {
compact = false;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this moved?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because compact only needs to be evaluated after if (this.usedDuplicates.has(value)) return ``*ref_${duplicateIndex}``; doesn't return early.

Copy link
Contributor

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@iuioiua iuioiua merged commit fab118b into denoland:main Aug 29, 2024
16 checks passed
@timreichen timreichen deleted the yaml-simplify-duplicate branch August 29, 2024 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants