-
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Overview
This is a sub-task of #119 - Refactor: Address Law of Demeter violations for better encapsulation
Priority: Medium
Pattern: result["metadata"]["settings"]["key"] (3+ levels deep)
Violations Found
20+ instances across test files:
tests/test_schema_parser.py: Lines 362, 368, 371, 374, 388, 396tests/unit/safety_system/test_safety.py: Lines 141-142, 453, 460tests/unit/safety_system/test_filesystem_path_sanitization.py: Lines 152-153tests/unit/fuzz_engine/strategy/test_schema_parser.py: Lines 361, 367tests/integration/test_reports_integration.py: Lines 107, 163-166, 196-198
Refactoring Suggestion
def safe_get_nested(data: dict, *keys, default=None):
result = data
for key in keys:
if not isinstance(result, dict):
return default
result = result.get(key, {})
return result if result != {} else defaultAcceptance Criteria
- Choose refactoring approach (wrapper class vs helper function)
- Implement chosen approach
- Refactor all 20+ test assertions
- Add tests for new helper/wrapper
- All existing tests pass
References
Metadata
Metadata
Assignees
Labels
No labels
Projects
Status
Todo