Repository navigation
StyleGuide
This is a style guide doc that guides new contributers and existing contributors on how to style code in the repo.
These rules only apply to the code in the Platform Independant Vault Core folder src/core.
Each Class must have its own folder to hold its .cpp and .h files. It is preferable to have one class per folder, although if multiple .cpp files rely/implement something in a .h file it is fine.
The Vault must have its own folder with multiple nested base class folders inside it like src/core/vault/crypto/crypto.h. Vault Items should avoid appending Vault to the fron of each class since the classes are nested inside the Vault folder. The Vault Core must be held inside the src/core folder which contains the Vault itself and the item types (eg: LoginItem).
Helper funcs and classes should be nested inside a utils folder.
All files and folders must use lower snake case (eg: drivers_license.cpp) and must avoid using Camel Case or Capital letters.
All Item modifiers (eg: LoginItem) must be nested inside an items folder.
All C++ Files and Headers must use .cpp and .h.
Classes/Structs must utilise Pascal Case for naming, eg: DriversLicense, Crypto, etc. (Note: file names must still use Lower Snake Case)
Functions must utilise Camel Case for naming, eg: getName, getUsername, etc.
Local Variables must utilise Snake case for naming, eg: license_item, etc
Global Variables must utilise Snake case with a prepending of g_, eg: g_vault_manager, etc
Member Variables must utilise Snake case with a prepending of m_, eg: m_vault, etc
Private Variables/Functions must append a _ with the above rules applied, eg: m_vault_, unlock_, etc
All Global Consts must prepend a c_ with the above rules applied, eg: c_app_name, etc
All Defines must use All Caps with Snake Case, eg: CLIENTWARDEN_APP, etc
All files in the Vault core must be under a clientwarden namespace.
All Namespaces must use lower Snake Case, eg: clientwarden::utils, folder_utils, etc
All code must use 4 Spaces for indentation.
Code must use the K&R style for braces, eg:
void main() {
return;
}
Line Length must be limited by 100 characters (Note: This varies across langs and UI's, so this is only valid for the C++ Core).
Pointers must be aligned to the left, eg: char** name;.
nullptr's must be used to specify a NULL (Do not use NULL or 0).
All enums must be an enum class.
Raw Pointers are not to used, as they are unsafe. shared_ptr's must be used to to hold a pointer (Note: references are allowed - &).
auto's are NOT to be used in this repo. All var types must be specified.
const type& var are not to be used, except for references to prevent copies.
Forward Declarations are not to be used, unless absolutely necessary to prevent circular dependencies.
Due to the flaws and un-maintainability of the old codebase, it is now REQUIRED to use JavaDoc style comments, eg:
/**
* @brief Attempts to unlock using the password
*
* First, the password is generate an interalKey and masterPasswordHash. Then, the
* protectedKey is retrieved and is used to obtain a stretched mac and enc key,
* which is then used the unlock and decrypt the Vault.
*
* @param password The password is used to generate a Key that can decrypt the Vault
* @return If the operation succeeds then true, otherwise false
*/
bool unlock_(type password);
A try/catch must be used in every call to the Vault Core from the UI. However, the VaultManager must also use a try/catch when initialising and setting up the Vault. Serious errors like the Invalid Mac Key must cause the Vault to enter a Failed State which alerts the User that something has gone seriously wrong and the app must be restarted.