mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
chore: discourage regular expressions in AGENTS.md and Greptile rules
Regular expressions are hard to review and easy to get subtly wrong. AGENTS.md now asks for string functions or an existing validator instead, and a Greptile rule flags new ones in PHP files.
This commit is contained in:
1 parent
33fadf8f93
commit
71951303ae
2 files changed
+11
No files matched your search
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user