DEVELOPMENT_GUIDE.md
This document provides a general overview for writing and designing code for Valkey. During our long development history, we've made a lot of inconsistent decisions, but we strive to get incrementally better.
Most of the style guidelines are enforced by clang format, but some additional comments are included here.
/* comment */ can be used for both single and multi-line comments.
C++ comments // can only be used for single line comments.
Multi line comments should have the leading * align and the final */ should be on the same line as the last line of text.
e.g./* Blah Blah
* Blah Blah. */
_, and they are kept as is to make it easier to backport changes.Valkey has a long history of inconsistent naming conventions. Generally follow the style of the surrounding code, but you can also always use the following conventions for variable and structure names:
snake_case or all lower case for short names (e.g. cached_reply or keylen).camelCase or namespace_camelCase (e.g. createStringObject or IOJobQueue_isFull).UPPER_CASE (e.g. MAKE_CMD).camelCase (e.g. user).When creating new source code files, use the following snippet to indicate the license:
/*
* Copyright (c) Valkey Contributors
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*/
If you are making material changes to a file that has a different license at the top, also add the above license snippet. There isn't a well defined test for what is considered a material change, but a good rule of thumb is that material changes are more than 100 lines of code.
Valkey uses two types of tests: unit and integration tests. All contributions should include a test of some form.
Unit tests are present in the src/unit directory, and are intended to test individual structures or files.
For example, most changes to data structures should include corresponding unit tests.
Integration tests are located in the tests/ directory, and are intended to test end-to-end functionality.
Adding new commands should come with corresponding integration tests.
When writing cluster mode tests, do not use the legacy tests/cluster framework, which has been deprecated, and instead write tests in unit/cluster.
Valkey keeps most of the user documentation in the valkey-doc repository in a few areas:
When a PR is opened that requires documentation to be updated, the needs-doc-pr should be added until the corresponding documentation PR is open.