diff --git a/.greptile/config.json b/.greptile/config.json new file mode 100644 index 0000000000..bc8a608f63 --- /dev/null +++ b/.greptile/config.json @@ -0,0 +1,10 @@ +{ + "rules": [ + { + "id": "no-regex", + "rule": "Flag every new regular expression (preg_match, preg_replace, preg_split, or a regex pattern passed to a validator). Ask for plain string functions instead, such as str_starts_with, str_ends_with, str_contains, strlen, substr, explode or ctype_*, or an existing validator. Regex is hard to review and easy to get subtly wrong. Accept one only when no string-function alternative exists and the PR explains why.", + "scope": ["**/*.php"], + "severity": "high" + } + ] +} diff --git a/AGENTS.md b/AGENTS.md index da9c7beadc..dd25856331 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -222,6 +222,7 @@ Actions should read like a story. The `action()` method is the plot: [`Teams/Htt ## Conventions - PSR-12 (Pint), PSR-4 autoloading. Avoid dependencies outside the `utopia-php` ecosystem. Never hardcode credentials — use env vars. Code changes may require a container restart; logs live on the relevant container. +- Do not add regular expressions (`preg_*`, regex patterns passed to validators). Use string functions (`str_starts_with`, `str_ends_with`, `str_contains`, `strlen`, `substr`, `explode`, `ctype_*`) or an existing validator instead; regex is hard to review and easy to get subtly wrong. If nothing else works, explain why in the PR. - When updating documents, pass only changed attributes as a sparse Document: ```php