Engineering Standards & Testing
Engineering Standards & Testing
To maintain consistency and stability across the PLANOVI platform, all contributors must adhere to the engineering guidelines outlined below.
1. Code Style & Formatting
- Official Formatter: Always run
dart format .before pushing code. - Line Length: Adhere to the standard 80-character line length where practical.
- Static Analysis: The repository uses
analysis_options.yamlwith strict linting rules. Run:Ensure 0 warnings and 0 errors prior to raising pull requests.Terminal window flutter analyze
2. Architectural Guidelines
Domain-Driven Feature Isolation
- New screens and business logic must be placed within
lib/features/<module_name>/. - Shared widgets, utilities, and common models belong in
lib/core/.
State Management
- Avoid passing mutable state through deep widget trees.
- Use
ChangeNotifierclasses inproviders/and read viacontext.read<T>()for callbacks orConsumer<T>/context.watch<T>()for reactive rebuilds. - Separate heavy side-effects (API queries, PDF generation) into dedicated services in
services/.
Tenancy & Security
- Never query Supabase tables without ensuring the query respects tenant isolation (either automatically via backend Postgres RLS using
auth.uid()or by explicitly filtering bycompany_id). - Check UI button permissions using
RbacContextProvider.
3. Testing Standards
- Unit Tests: Place in
test/unit/for service calculations, tariff balance algorithms, and data model JSON serialization. - Widget Tests: Place in
test/widget/for critical interactive elements (like modal dialogs and form validation). - Running Tests:
Terminal window flutter test