Making sure that the nvm stored attributes are ordered by endpoint#1686
Making sure that the nvm stored attributes are ordered by endpoint#1686brdandu wants to merge 1 commit intoproject-chip:masterfrom
Conversation
Summary of ChangesHello @brdandu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses the need for consistent and predictable ordering of NVM stored attributes, particularly when generating token headers. By implementing deterministic Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces ordering to SQL queries for NVM stored attributes to ensure a deterministic output, which is a solid improvement for consistency. The changes are well-supported by new unit and integration tests that verify the new ordering logic. I have one suggestion to improve the readability of one of the new tests, but overall the changes are good.
| const prev = perEndpoint[i - 1] | ||
| const curr = perEndpoint[i] | ||
| const cmpClusterMfg = | ||
| (prev.clusterMfgCode ?? 0) - (curr.clusterMfgCode ?? 0) | ||
| if (cmpClusterMfg !== 0) { | ||
| expect(cmpClusterMfg).toBeLessThanOrEqual(0) | ||
| continue | ||
| } | ||
| const cmpMfg = (prev.mfgCode ?? 0) - (curr.mfgCode ?? 0) | ||
| if (cmpMfg !== 0) { | ||
| expect(cmpMfg).toBeLessThanOrEqual(0) | ||
| continue | ||
| } | ||
| const cmpName = (prev.clusterName || '').localeCompare( | ||
| curr.clusterName || '' | ||
| ) | ||
| expect(cmpName).toBeLessThanOrEqual(0) | ||
| if (prev.clusterName !== curr.clusterName) continue | ||
| expect(prev.code ?? 0).toBeLessThanOrEqual(curr.code ?? 0) |
There was a problem hiding this comment.
The logic to check the sorting is correct, but it can be simplified for better readability and maintainability. The current implementation uses a pattern of expect().toBeLessThanOrEqual(0) followed by a check for inequality, which is a bit convoluted. A more direct approach would be to check for inequality and then assert that the order is strictly "less than". This makes the intent of the test clearer.
const prev = perEndpoint[i - 1]
const curr = perEndpoint[i]
const cmpClusterMfg =
(prev.clusterMfgCode ?? 0) - (curr.clusterMfgCode ?? 0)
if (cmpClusterMfg !== 0) {
expect(cmpClusterMfg).toBeLessThan(0)
continue
}
const cmpMfg = (prev.mfgCode ?? 0) - (curr.mfgCode ?? 0)
if (cmpMfg !== 0) {
expect(cmpMfg).toBeLessThan(0)
continue
}
const cmpName = (prev.clusterName || '').localeCompare(
curr.clusterName || ''
)
if (cmpName !== 0) {
expect(cmpName).toBeLessThan(0)
continue
}
expect(prev.code ?? 0).toBeLessThanOrEqual(curr.code ?? 0)
JIRA: ZAPP-1690