Skip to content

Commit efe0b08

Browse files
authored
copilot: instructions for apis to not use multiple bools (#5256)
Add instructions to steer against functions with multiple booleans, that are hard to review.
1 parent 5d6ab1c commit efe0b08

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎.github/copilot-instructions.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ For cross-compilation from WSL2 to Windows, see
1717
`Guide/src/dev_guide/getting_started/cross_compile.md` and source
1818
`. ./build_support/setup_windows_cross.sh`.
1919

20+
## API Design
21+
22+
- Avoid multiple positional `bool` parameters in functions and constructors.
23+
Call sites should show what each choice means without requiring the reader
24+
to inspect the signature.
25+
- Prefer small, named constructors for distinct creation modes, such as
26+
`new_primary(...)` and `new_secondary(...)`, rather than one constructor
27+
controlled by flags. Each constructor should take only the inputs its mode
28+
needs. Share implementation internally where useful.
29+
- Use a descriptive enum when a value selects a mode at runtime. Keep booleans
30+
for independent on/off properties, not for encoding modes.
31+
- Do not replace flag lists with a general-purpose builder or configuration
32+
framework when a few named constructors suffice.
33+
2034
## Protocol Buffers Enums
2135

2236
For `.proto` changes (including gRPC/ttrpc), read and follow the

0 commit comments

Comments
 (0)