-
-
Notifications
You must be signed in to change notification settings - Fork 0
Contributing
This page explains where an SPM change belongs and what evidence should accompany it. See Development for the full test commands and Architecture for the layer boundaries.
git clone https://github.com/32bytess/spm.git
cd spm
dart pub get
dart analyze # must be clean
dart test # must be greenRequirements match the rest of the toolchain: Dart 3.9.2 or newer and Flutter 3.3 or newer.
Run the full local gate. A change is not ready until all three pass:
dart analyze # zero issues
dart test # all tests green
dart format . # formattedA PR is expected to:
- keep
dart analyzeclean anddart testgreen; - add or update tests for the behavior it changes (see the per-area guides below);
- stay within one feature module where possible, since
analysis/,isolation/,injection/,profiler/, andvalidation/are independent; - follow the code conventions below.
Use a topic branch (not master) and keep the commit history readable.
These conventions are enforced in review and described further in Architecture and Development:
-
Type aliases. Use the aliases in
src/core/types.dart(Result<T>,AsyncResult<T>,AsyncVoidResult,AsyncVoid, andJsonRecord); never spell the full types out inline. -
Error handling. Return
Either<Failure, T>(Leftis the error case) throughout the data and domain layers. Only throw at the outermost CLI boundary. Data sources may throw; the repository layer maps those exceptions to a typedFailure. -
New error types go in
src/core/errors/failures.dartas aFailuresubclass; aggregate several withCompoundFailure. -
Logging goes through
SpmLogger, neverprint. -
DI. Each feature has a static service locator (
AnalysisDI,IsolationDI,InjectionDI,ValidationDI) built on lazy??=getters. When wiring a new dependency, add it there.
The suite has firm rules, so read Development before writing tests. The essentials:
-
Hand-written fakes only, never mocks. Implement the repository/data-source interface directly.
Repository fakes expose
givenSuccess()/givenFailure(Failure); data-source fakes exposegivenSuccess()/givenThrows(Exception). - Copy list references when capturing call arguments in a fake:
List.of(targets). - Async exception tests are
asyncandawaitthe call inside atry/catch. - File-I/O tests create a
Directory.systemTemp.createTempSync(...)insetUpand delete it intearDown. Never write test artifacts into the repo. - When testing through the DI layer, call the feature DI's
reset()insetUp/tearDown.
- Add a fixture Dart file under
test/fixtures/analysis/that exercises the case. - Add the extractor/visitor in the relevant
analysis/data/data_sources/set. - If it produces a new output field, add it to
AnalysisResultModel.toJsonand document it in Output Formats and Extracted Features. The wiki lists the exact field set, so a new key must land in both. - Add a test under
test/features/analysis/, preferringgetResultsForFixture(...)fromtest/features/analysis/utils/test_helper.dartover re-wiring the pipeline.
Scope detection is shared: the kind lists live in AppConstants (builderScopeWidgets,
positionalBuilderScopeWidgets, rebuildScopeTypes) and the predicates in
analysis/data/data_sources/extensions/state_class_detector.dart. Both isolate
(RebuildScopeVisitor) and analyze (RebuildScopeAnalysisVisitor) read from them.
- Add a realistic fixture under
test/fixtures/isolation/and, if the new kind should be measured, one undertest/fixtures/analysis/rebuild_scopes/. - Add the pattern to the shared constants/predicates rather than to one visitor.
- Add tests under
test/features/isolation/andtest/features/analysis/. - A new scope type widens the
--scope-typesallowed values and thescopeTypecolumn, so document it in analyze and Output Formats.
- Add the code to the
ViolationCodeenum invalidation/domain/entities/validation_report.dart(keep the JSON schema stable). - Implement the check so it appends a
Violation{code, severity, detail}. - Add a fixture case under
test/fixtures/validation/<case>/{base.dart, mutation.dart}proving the violation, and a test undertest/features/validation/. - Update validate and Validate: AST Internals to move the code from the "not yet implemented" list into the checks table.
This wiki documents exact field names and schemas taken from the code. If your change touches a
toJson, a CLI flag, an event name, or a Failure/ViolationCode, update the corresponding wiki
page in the same PR so the two never drift.
Commands
Reference
Internals
Contributing