Add link requirement and unknown category isolation
MR adds two new validation checks to the features.yml file:
- Unknown category isolation: ensure that the
unknowncategory is not used with other categories. - Require a link for all features unless category is
unknown. Also fixes 19 violations.
Related to Product#14293 (closed)
Duo summary
Features Checker (lib/features/features_yml_checker.rb)
New Functionality Added:
-
Unknown Category Isolation Validation
- Added
check_unknown_category_isolationmethod - Prevents mixing "unknown" with other categories
- Error message:
"category 'unknown' cannot be combined with other categories: [list]"
- Added
-
Stricter Link Requirement Logic
- Updated
category_is_unknown?method to only returntruewhen category is exactly['unknown'] - Previously: returned
trueif "unknown" was anywhere in the categories array - Now: returns
trueonly if the entire categories array is['unknown']
- Updated
Performance Optimizations:
-
Single Category Extraction
- Added
extract_categoriesmethod using Ruby'sArray()pattern (consistent with existing codebase) - Categories now extracted once per feature instead of 3 times
- All validation methods updated to accept
categoriesas parameter
- Added
-
Method Signature Updates:
-
check_category_validity- now takescategoriesparameter -
check_link_requirement- now takescategoriesparameter -
check_unknown_category_isolation- now takescategoriesparameter -
category_is_unknown?- now takescategoriesparameter instead offeature_data
-
Integration:
-
Updated Validation Pipeline
- Added
check_unknown_category_isolationto the validation sequence - All methods now receive pre-extracted categories
- Added
Test File (spec/features/features_yml_checker_spec.rb)
Test Coverage Improvements:
-
Removed Redundant Tests (earlier in conversation):
- Removed duplicate positive validation tests
- Removed redundant link validation tests
- Streamlined from ~15 tests to 11 focused tests
-
Added New Test Cases:
-
'fails when unknown is mixed with valid categories'- expects 2 errors (isolation + link requirement) -
'fails when unknown is mixed with invalid categories'- expects 3 errors (invalid category + isolation + link requirement) -
'passes when multiple valid categories are used'- validates array categories work correctly - Kept existing
'passes when link is missing but category is unknown'test
-
Test Expectations Updated:
-
Accurate Error Counts
- Tests now expect correct number of validation errors
- Account for cascading effects of stricter
category_is_unknown?logic
Real Data Impact (data/features.yml)
Validation Results:
-
Before changes: 19 validation errors (missing
linkfields) -
After changes: 0 validation errors
✅ - Errors fixed: 19 errors resolved
The real data/features.yml file now passes validation completely, indicating:
- No features currently mix "unknown" with other categories
- All features that were missing links have been fixed
- The new validation rules don't break existing valid data
Overall Impact:
-
✅ Functionality: Enhanced validation with semantic correctness for "unknown" categories -
✅ Performance: ~67% reduction in category extraction operations -
✅ Quality: Comprehensive test coverage with no redundancy -
✅ Compatibility: All existing valid data continues to pass validation -
✅ Standards: Code follows project conventions and passes rubocop
The implementation successfully adds new validation rules while maintaining backward compatibility and improving performance.
Edited by Cynthia "Arty" Ng