KogenCredo.Diff.Rules.QueryLostScope (KogenCredo v0.1.0)
View Sourcequery-lost-scope: a changed function that still builds or runs a query compares a configured
scope field (an owner or tenant id) fewer times than at the base.
Option :sensitive_fields (default [:user_id, :tenant_id, :account_id, :organization_id])
lists the fields. A comparison is x.field == ..., x.field in ..., field(x, :field) == ...
or a keyword pair such as where: [user_id: ^id] / Repo.get_by(Post, user_id: id). Maps and
structs (patterns, literals) and function heads are ignored. Counts include same-module
helpers the function reaches, so extracting the scope into a helper is quiet.
Limits
Purely a count per field: scope enforced by another module, a policy layer or a
Ecto.Query.where hidden in a variable is invisible, and replacing one comparison by a
different one on the same field is not noticed. When the function lost repo reads altogether
the rule stays quiet. Advisory by default; no precision has been measured.