bito-code-review[bot] commented on code in PR #44201:
URL: https://github.com/apache/superset/pull/44201#discussion_r4148896790
##########
superset-frontend/scripts/internal/oxlint-metrics-uploader.js:
##########
@@ -64,12 +65,50 @@ function parseRuleId(code) {
const [, namespace, rule] = match;
if (namespace === 'eslint') {
- return rule;
+ return { parsed: rule, pluginId: namespace };
}
// `eslint-plugin-unicorn(...)` is the same rule as `unicorn/...`
const plugin = namespace.replace(/^eslint-plugin-/, '');
- return `${plugin}/${rule}`;
+ return { parsed: `${plugin}/${rule}`, pluginId: plugin };
+}
+
+function parseOxlintResult(results, ruleIdPrefixes) {
+ // Process OXC JSON output
+ const metricsByRule = {};
+ const occurrencesData = [];
+
+ // OXC JSON format has diagnostics array
+ if (results.diagnostics && Array.isArray(results.diagnostics)) {
+ results.diagnostics.forEach(diagnostic => {
+ const { parsed: ruleId, pluginId } = parseRuleId(diagnostic.code);
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Inconsistent return type</b></div>
<div id="fix">
`parseRuleId` now returns an object on matched paths (lines 68/73) but still
returns strings on fallback paths (line 58 `'unknown'`, line 63 raw `code`).
Line 84 destructures the result as an object, so an unparseable/missing
`diagnostic.code` yields `ruleId === undefined`; on the main path (line 181, no
prefixes) such diagnostics collapse into a single `metricsByRule['undefined']`
bucket with `rule: undefined`, breaking the 'passed through rather than
dropped' guarantee the tests at lines 73-75 still assert.
</div>
</div>
<small><i>Code Review Run #882fe6</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]