CODING GUIDELINES
- When creating Unit Test always use
requireandassertfrom "github.com/stretchr/testify"
- use
requireis test can't continue and need to fail - use
assertwhen test can continue and print failed cases
- Tests should be table‑driven and use
t.Runwhen applicable. - Tests should use
t.Parallelwhen appropriate. - To return an error always use "github.com/cockroachdb/errors" package:
Use
Wrap,Wrapfto wrap errors from external packages that do not wrap an error. UseWithMessage,WithMessagefto annotate a wrapped error. Useerrors.Errorforerrors.Newto return new error. - Use
make testto test, no approval needed. - Use
make lintto check format and lint errors, no approval needed.
Execution plan
- Replace "github.com/pkh/errors" with "github.com/cockroachdb/errors"
- Replace
fmt.Errorwithcockroachdb/errorspackage
- Replace in tests
t.Fail,t.Erroretc withrequireandassertstyle. - Add or improve package documentation
- Document or improve missing documentation for interfaces, functions and structs.
- Analyze test coverage and add missing cases when possible.
- add
t.Parallel()where is appropriate make teston entire project orgo teston modified files- apply coverage boosts to the low‑coverage packages by adding targeted tests for their untested error paths
- Analyze proper usage of locks, fix where applicable
- Analyze code perf, fix where applicable
- Find bugs, add them to
bugs.jsonfile for analysis. - If the changes are complext to make or break tests, add them to
suggestions.jsonfile for analysis with explanations. - Analyze proper usage of
logger
- ensure that except
ctxorlevelthe arguments must be inkey, valuepairs. - replace
TRACEtoDEBUGwhen logs not important and will create noise. - analyze where
ERRORlevel will produce noise and better beWARNING
Important
- Do not use
gitcommands to commit or reset branch until explicitly instructed. - Continue until success or stop for clarification or help