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

fix(ibm-api-symmetry): handle dictionaries and top-level schemas #715

Merged
merged 2 commits into from
Jan 24, 2025

Conversation

dpopp07
Copy link
Member

@dpopp07 dpopp07 commented Jan 22, 2025

This rule was subject to both false positives, as it flagged any schema with a
dictionary property (even when inappropriate), and false negatives, as it did
not check top-level schemas, only schema properties. This fix resolves both
issues and cleans up the rule logic on the whole.

Additionally, changes are made to the rule's logging. The code
to determine if one schema is a graph fragment of the other
uses a depth-first algorithm that prints a log, if it determines the
schema to violate the graph fragment pattern, with the reason behind
the violation. Due to the depth-first nature of the algorithm, the
logs are currently printed in depth first order, which is not as
coherent for the user to read.

This change introduces a stack to collect the logs during processing
and print them in reverse order afterwards to give the user a
better sense of what happened during the processing.

Resolves #699

@dpopp07 dpopp07 requested a review from padamstx January 22, 2025 21:34
@dpopp07 dpopp07 force-pushed the dp/fix-api-symmetry branch from 6f73524 to 61703bb Compare January 22, 2025 21:37
Copy link
Member

@padamstx padamstx left a comment

Choose a reason for hiding this comment

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

LGTM

This rule was subject to both false positives, as it flagged any schema with a
dictionary property (even when inappropriate), and false negatives, as it did
not check top-level schemas, only schema properties. This fix resolves both
issues and cleans up the rule logic on the whole.

Signed-off-by: Dustin Popp <[email protected]>
The code to determine if one schema is a graph fragment of the other
uses a depth-first algorithm that prints a log, if it determines the
schema to violate the graph fragment pattern, with the reason behind
the violation. Due to the depth-first nature of the algorithm, the
logs are currently printed in depth first order, which is not as
coherent for the user to read.

This change introduces a stack to collect the logs during processing
and print them in reverse order afterwards, to give the user a better
sense of what happened during the processing.

Signed-off-by: Dustin Popp <[email protected]>
@dpopp07 dpopp07 force-pushed the dp/fix-api-symmetry branch from 61703bb to 2a68a5e Compare January 24, 2025 16:40
@dpopp07 dpopp07 merged commit b341441 into main Jan 24, 2025
7 checks passed
@dpopp07 dpopp07 deleted the dp/fix-api-symmetry branch January 24, 2025 16:58
@ibm-devx-sdk
Copy link

🎉 This PR is included in version 1.28.2 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

@ibm-devx-sdk
Copy link

🎉 This PR is included in version 1.32.2 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

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.

Unexpected ibm-api-symmetry warning with dictionary
3 participants