pipe/test/fixtures/firestore_queries/lib/negative_controls.dart
trvon 1f60197a15
feat(queries): inventory firestore query surfaces as typed records
Add `pipe queries`, which lists every Firestore query a project can issue:
scope, collection, path pattern, filters with operators and value types,
composites, orderBy, limit, cursors, realtime, aggregation, in-loop, plus a
confidence and the reasons it is not exact. Receivers are matched by static
type and cloud_firestore library URI, never by name.

Queries are followed through chains, local variables (flow-insensitive with
two cuts), fields, getters and one level of helper methods with arguments
bound. An --adapter-config (YAML or JSON) maps declarative query APIs such as
a server-side gateway onto the same schema.

Inventory only: no rules, findings or baseline changes. Every emitted name is
validated against a safe character set so no source text reaches the output.
2026-09-23 18:03:09 -06:00

32 lines
920 B
Dart

/// Nothing in this file touches cloud_firestore. Every call below shares a name
/// with a Firestore query method and must NOT be extracted.
class Query {
Query where(String field, {Object? isEqualTo}) => this;
Query limit(int n) => this;
Future<List<Object>> get() async => const [];
Stream<List<Object>> snapshots() => const Stream.empty();
}
class CollectionReference extends Query {
CollectionReference collection(String path) => this;
}
class FakeFirestore {
CollectionReference collection(String path) => CollectionReference();
}
class Limiter {
List<int> limit(List<int> values, int n) => values.take(n).toList();
}
Future<void> lookalikes(List<int> values) async {
values.where((value) => value > 2).take(3).toList();
Limiter().limit(values, 2);
await FakeFirestore()
.collection('lookalike')
.where('a', isEqualTo: 1)
.limit(2)
.get();
Query().snapshots();
}