1.9 KiB
1.9 KiB
name, enabled, event, action, conditions
| name | enabled | event | action | conditions | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| warn-large-file | true | file | warn |
|
⚠️ Large File Warning: Over 500 Lines!
This file exceeds the 500-line soft limit for modules. Consider refactoring into a package.
How to convert a large file into a package:
# Before: single large file
src/noteflow/infrastructure/large_module.py (600+ lines)
# After: package with focused modules
src/noteflow/infrastructure/large_module/
├── __init__.py # Re-exports public API
├── _core.py # Core functionality
├── _helpers.py # Helper functions
├── _types.py # Type definitions
└── _constants.py # Constants and config
Step-by-step refactoring:
-
Create the package directory:
mkdir -p src/path/to/module_name -
Identify logical groupings:
- Core business logic
- Helper/utility functions
- Type definitions and protocols
- Constants and configuration
-
Create focused sub-modules:
- Each sub-module should have a single responsibility
- Use
_prefix for internal modules (e.g.,_helpers.py)
-
Create
__init__.pyto maintain API:# __init__.py - re-export public interface from ._core import MainClass, main_function from ._types import SomeType, SomeProtocol __all__ = ["MainClass", "main_function", "SomeType", "SomeProtocol"] -
Update imports in dependent modules
Project limits (from CLAUDE.md):
- Soft limit: 500 lines (warning)
- Hard limit: 750 lines (must refactor)
Benefits of smaller modules:
- Easier to test in isolation
- Better IDE performance
- Clearer separation of concerns
- Easier code review
- Reduced merge conflicts