Repository navigation
Conversation
Replace inline magic numbers flagged by Auto-QA in the drilldown views with named constants: - compliance score colour cut-offs (80/60) -> COMPLIANCE_SCORE_GOOD_PERCENT / COMPLIANCE_SCORE_WARN_PERCENT, applied via a new tested complianceScoreColor() helper - cluster resource tree "+N more" limits (nodes 20, namespaces 15, pod issues 10, PVCs 10, services 15) -> TREE_MAX_VISIBLE_* constants, so each slice() and its "+N more" counter share one value - pod labels collapse limit (10) -> COLLAPSED_LABEL_COUNT No behaviour change. The other entries in the issue were already named constants. Closes kubestellar#24734 Hive-Run: kubestellar#24734 Hive-Plan: auto-qa-magic-numbers Hive-Spec: auto-qa-operator-usefulness#magic-numbers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HRH6kjr5Jt2DhFJcve1Lzi Signed-off-by: Karibhou <157208370+Karibhou@users.noreply.github.com>
✅ Deploy Preview for kubestellarconsole ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Read the diff against the tree at head — this looks correct to me.
- Every extracted constant preserves the exact prior value:
TREE_MAX_VISIBLE_NODES=20,TREE_MAX_VISIBLE_NAMESPACES=15,TREE_MAX_VISIBLE_POD_ISSUES=10,TREE_MAX_VISIBLE_PVCS=10,TREE_MAX_VISIBLE_SERVICES=15(cluster-drilldown/types.ts:44-52),COMPLIANCE_SCORE_GOOD_PERCENT=80/WARN=60(compliance-drilldown/types.ts:26-29),COLLAPSED_LABEL_COUNT=10(LabelsSection.tsx:9), and eachslice()/> N/- Ntriple now reads the same constant, so the list and its "+N more" row can't drift. complianceScoreColor()(compliance-drilldown/helpers.tsx:39-43) reproduces the inline ternary fromComplianceFooter.parts.tsx:123exactly (>= 80green,>= 60yellow, else red), it's re-exported through the package index the same way the other helpers are, and the new boundary tests cover 80/79/60/59/100/0.- The PR body's claim that the remaining issue entries were already named constants checks out for the files touched here.
One pre-existing quirk the diff makes easier to see (not introduced here, no action needed): in ClusterResourceTree.tsx the namespaces branch slices filteredNamespaceStats but counts the "+N more" row from filteredNamespaces — same mismatch before and after this PR.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
|
Ready for a human merge: verdict approved @26d651b, 37/37 checks green, DCO yes, soak 30m0s elapsed. Blocked only by The hive never approves on your behalf: |
📌 Fixes
Closes #24734
📝 Summary of Changes
Replaces the inline magic numbers flagged by Auto-QA in the drilldown views with named constants. Behaviour does not change.
Most entries in the issue (
PERCENT_MULTIPLIER,MAX_LOG_SNIPPET_LENGTH,PAGE_SIZE,MAX_INSTANCES,REFRESH_SPINNER_MS, …) were already named constants, so they comply with the "no magic numbers" rule as they are. The ones still inline were:ComplianceFooter.parts.tsxcScore >= 80 ? … : cScore >= 60 ? …complianceScoreColor(cScore)usingCOMPLIANCE_SCORE_GOOD_PERCENT/COMPLIANCE_SCORE_WARN_PERCENTClusterResourceTree.tsxslice(0, 20)/> 20/- 20,15for namespacesTREE_MAX_VISIBLE_NODES,TREE_MAX_VISIBLE_NAMESPACESClusterResourceTreeBranches.tsx10(pod issues),10(PVCs),15(services)TREE_MAX_VISIBLE_POD_ISSUES,TREE_MAX_VISIBLE_PVCS,TREE_MAX_VISIBLE_SERVICESpod-drilldown/LabelsSection.tsxslice(0, 10)/> 10COLLAPSED_LABEL_COUNTEach tree limit was written two or three times (the
slice(), the+N morecheck and the counter). Now each one has a single constant, so the visible list and the "+N more" row can't drift apart.Changes Made
cluster-drilldown/types.ts,compliance-drilldown/types.ts,LabelsSection.tsx)complianceScoreColor()helper (exported fromcompliance-drilldown)complianceScoreColorboundary values (compliance-drilldown/helpers.test.tsx)Checklist
web/node_modules. Per AGENTS.md, build/lint are validated by CI.git commit -s)👀 Reviewer Notes
ClusterResourceTree.tsxstill checksfilteredNamespaces.lengthfor the "+N more" row while it slicesfilteredNamespaceStats. I kept that unchanged so behaviour stays the same.🤖 Generated with Claude Code
https://claude.ai/code/session_01HRH6kjr5Jt2DhFJcve1Lzi
— hive: backend=claude model=claude-opus-5-5