All code (app, scripts, tests) must follow these rules.
-
Explicit types — All variables must have explicit type definitions. Avoid
varwhen type isn't obvious. -
Prefer
final— Declare variables asfinalwhenever possible. -
Empty lines — Put empty line between
finaldeclarations, and betweenfinals and regular code. -
Break down complexity — Avoid complex single-step calculations. Use intermediate variables with descriptive names.
-
Parenthesize complex conditions — Wrap multi-element comparisons in parentheses.
-
No one-liner conditionals — Always use curly braces
{}around conditional blocks. -
Named parameters preferred — Allow positional only for ≤2 parameters of different types.
-
Run
flutter analyze— After generating or modifying code. -
Update CHANGELOG.md — For every commit, add entry at end of appropriate section.
-
Commit signature — Include
Signed-off-by: Name <email>(last line) andCo-Authored-By: AI_MODEL <email>. -
git add -Aon commit — Avoid forgetting files. -
Don't manually run
build_runner build— Watch instance is already running. -
Update TODO.md — Check if any completed items should be marked done.
-
Keep it linear — No deep nesting. Code reads top to bottom. One level deep where possible.
-
Bound every loop — Explicit, enforced maximum iterations. Define ceiling and fallback behavior.
-
One function, one job — ≤60 lines, describable in one sentence without "and". Include docstring.
-
State assumptions — Use assertions for preconditions and postconditions.
-
Never swallow errors — Every error logged, raised, or explicitly returned.
-
Narrow your state — Scope locally, pass dependencies explicitly.
-
Surface side effects — I/O, mutations, network calls obvious at call site. Separate pure computation from effects.
-
One layer of magic — Prefer linear composition over deep indirection.
-
Warnings are errors — Zero compiler warnings. Run analysis on every change.
-
Tests first — Write tests before or alongside implementation. Cover edge cases and failure modes.
-
Don´t create default constructors equal to forCWJM constructors - the default ones should try to receive parameters in a way that is more intuitive for the user. For example, for a THDoublePart parameter, it should accept a double and then use the default THDoublePart constructor to create the THDoublePart instance. Check other default command constructors for details.
- Localizations: Use
mpLocator.appLocalizations. Exception:MapiahHomeusesAppLocalizations.of(context). - No magic numbers: Define constants in
lib/src/constants/mp_constants.dart - No duplicated code: Extract reusable logic
- Separate UI from business logic: Use MobX controllers
- All user strings localized: Via
AppLocalizations— edit.arbfiles, runflutter gen-l10n - No all-caps in UI text
- Update help pages (
assets/help/) for new features (EN + PT, markdown) - Update keyboard shortcuts (
assets/help/), keep alphabetical order - Suggest tests for new features (numeric prefix, descriptive name,
_test.dart) - URLs: Prefer
MPURLTextWidget - Don't worry about formatting — Automatic on commit
- Avoid duplicated code
- No all-caps in user-facing text
Follow all General Guidelines (no additional rules beyond those).