bito-code-review[bot] commented on code in PR #44201:
URL: https://github.com/apache/superset/pull/44201#discussion_r4166929316


##########
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:
   <!-- Bito Reply -->
   The suggestion to unify the return type of `parseRuleId` is correct. 
Currently, `parseRuleId` returns an object when a rule is matched but a string 
on fallback paths, which causes issues when the result is destructured as an 
object. 
   
   To resolve this, both fallback paths should return `{ parsed: 'unknown', 
pluginId: 'unknown' }` (or the appropriate fallback values). You can then 
update the `parseOxlintResult` test to assert that `unknown` is returned for 
unparseable codes, ensuring consistency with the new object-based return 
structure.
   
   **superset-frontend/scripts/internal/oxlint-metrics-uploader.js**
   ```
   function parseRuleId(code) {
     if (!code) {
       return { parsed: 'unknown', pluginId: 'unknown' };
     }
   
     const match = code.match(/^([a-z0-9-]+)/([a-z0-9-]+)$/);
     if (!match) {
       return { parsed: code, pluginId: 'unknown' };
     }
   
     const [, namespace, rule] = match;
     if (namespace === 'eslint') {
       return { parsed: rule, pluginId: namespace };
     }
   
     const plugin = namespace.replace(/^eslint-plugin-/, '');
     return { parsed: `${plugin}/${rule}`, pluginId: plugin };
   }
   ```



-- 
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]

Reply via email to