Skip to content

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.yaml with strict linting rules. Run:
    Terminal window
    flutter analyze
    Ensure 0 warnings and 0 errors prior to raising pull requests.

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 ChangeNotifier classes in providers/ and read via context.read<T>() for callbacks or Consumer<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 by company_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