Copilot commented on code in PR #33960:
URL: https://github.com/apache/superset/pull/33960#discussion_r2176247832


##########
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/utils.ts:
##########
@@ -49,6 +50,39 @@ export const hasCircularDependency = (
   return false;
 };
 
+/**
+ * Helper function to find dependency validation errors in form fields.
+ * This function improves code maintainability by centralizing the logic
+ * for detecting cyclic dependency errors and extracting the problematic 
filter ID.
+ *
+ * @param fields - Array of form field error objects from Ant Design Form
+ * @returns Object containing error status and filter ID, or null if no 
dependency errors
+ */
+export const findDependencyError = (fields: any[]) => {

Review Comment:
   Using `any[]` for form fields reduces type safety. Consider importing and 
using Ant Design’s `FormFieldData[]` (or the correct type) to improve 
maintainability and catch issues at compile time.



##########
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/utils.ts:
##########
@@ -49,6 +50,39 @@ export const hasCircularDependency = (
   return false;
 };
 
+/**
+ * Helper function to find dependency validation errors in form fields.
+ * This function improves code maintainability by centralizing the logic
+ * for detecting cyclic dependency errors and extracting the problematic 
filter ID.
+ *
+ * @param fields - Array of form field error objects from Ant Design Form
+ * @returns Object containing error status and filter ID, or null if no 
dependency errors
+ */
+export const findDependencyError = (fields: any[]) => {
+  // Form field structure constants for better readability
+  const FORM_FIELD_FILTERS_INDEX = 0;

Review Comment:
   [nitpick] These numeric indices (`0`, `1`, `2`) are somewhat opaque. 
Consider destructuring the `field.name` array (e.g., `[section, filterId, 
prop]`) for readability instead of relying on magic constants.



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