Thank you for your interest in contributing to Faker C++! This guide will help you get started with contributing to the project.
- Quick Links
- Ways to Contribute
- Getting Started
- Development Workflow
- Code Style
- Testing
- Pull Request Process
- Adding New Modules
- Documentation
- Community
- Building Guide - How to build the project
- Quick Start - Get started with using the library
- Issues - Find something to work on
- Discussions - Ask questions
- Discord - Chat with the community
There are many ways you can contribute to Faker C++:
Found a bug? Create an issue with:
- A clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- Your environment (OS, compiler, version)
Have an idea? Start a discussion or create a feature request issue.
- Fix typos or clarify existing docs
- Add examples
- Write tutorials or blog posts
- Translate documentation
- Fix bugs
- Implement new features
- Add new data generators
- Improve performance
- Add support for new locales
Help review open pull requests and provide constructive feedback.
Before you begin, ensure you have:
- CMake 3.22 or higher
- C++ Compiler with C++20 support:
- GCC 13+
- Clang 16+
- Apple Clang 16+
- MSVC 143 (Visual Studio 2022)+
You can check compiler support at cppreference.
First, fork the repository on GitHub, then clone your fork:
git clone https://github.com/<your-username>/faker-cxx.git
cd faker-cxx
git submodule update --init --recursiveReplace <your-username> with your GitHub username.
See our comprehensive Building Guide for detailed instructions for your compiler.
Quick build:
# Configure
cmake -B build -DFAKER_BUILD_TESTING=ON
# Build
cmake --build build
# Run tests
ctest --test-dir buildCreate a feature or bug fix branch from main:
git checkout -b feature/your-feature-name
# or
git checkout -b fix/bug-descriptionBranch naming conventions:
feature/feature-name- For new featuresfix/bug-description- For bug fixesdocs/description- For documentation changesrefactor/description- For code refactoring
Browse open issues or create a new one to discuss your proposed changes.
Good first issues: Look for issues labeled good first issue if you're new to the project.
- Follow the code style guidelines
- Write clean, readable, and maintainable code
- Add comments for complex logic
- Keep functions focused and small
All new features and bug fixes must include tests!
Tests are located in the tests/ directory. Add your tests in the appropriate module test file.
Example test structure:
#include <gtest/gtest.h>
#include "faker-cxx/your_module.h"
TEST(YourModuleTest, ShouldGenerateExpectedValue)
{
const auto result = faker::yourModule::yourFunction();
ASSERT_FALSE(result.empty());
// Add more assertions
}# Run all tests
ctest --test-dir build
# Run tests with verbose output
ctest --test-dir build --verbose
# Run specific test
ctest --test-dir build -R YourModuleTestThis project uses .clang-format for consistent code formatting.
Format all code:
./scripts/format_code.shOr configure your IDE:
- VS Code: Install the
clang-formatextension - CLion: Enable ClangFormat in Settings → Editor → Code Style
- Visual Studio: Use Format Document (Ctrl+K, Ctrl+D)
- Indentation: 4 spaces (no tabs)
- Line length: Max 120 characters
- Naming conventions:
- Functions:
camelCase() - Variables:
camelCase - Classes:
PascalCase - Constants:
UPPER_SNAKE_CASE - Namespaces:
lowercase
- Functions:
// ✅ Good
std::string firstName(Locale locale = Locale::en_US);
// ❌ Bad
std::string first_name(Locale locale = Locale::en_US);// ✅ Good - Clear function name and documentation
/**
* @brief Generates a random email address.
* @param locale The locale to use.
* @returns Random email address.
*/
std::string email(Locale locale = Locale::en_US);
// ❌ Bad - No documentation
std::string e(Locale l = Locale::en_US);If your file contains non-Latin characters, ensure it's saved with UTF-8 encoding without BOM.
In VS Code:
- Click the encoding in the status bar
- Select "Save with Encoding"
- Choose "UTF-8"
- Tests use Google Test (GTest)
- Each module has its own test file in
tests/modules/ - Test names should be descriptive:
TEST(ModuleName, ShouldDoSomethingWhenCondition)
TEST(InternetTest, ShouldGenerateValidEmail)
{
const auto email = faker::internet::email();
// Check email is not empty
ASSERT_FALSE(email.empty());
// Check email contains @ symbol
ASSERT_TRUE(email.find('@') != std::string::npos);
// Check email contains domain
ASSERT_TRUE(email.find('.') != std::string::npos);
}- Aim for high test coverage
- Test edge cases and error conditions
- Test with different locales when applicable
✅ Checklist:
- Code follows the project's style guidelines
- All tests pass locally
- New tests added for new features/fixes
- Code is formatted with
clang-format - Documentation updated (if needed)
- Commit messages are clear and descriptive
- No merge conflicts with
main
Write clear, descriptive commit messages:
✅ Good commit messages:
- "Add French locale support for person module"
- "Fix memory leak in string generator"
- "Update README with API reference section"
❌ Bad commit messages:
- "fix stuff"
- "update"
- "wip"
Format:
<type>: <subject>
<optional body>
<optional footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
Example:
feat: add Japanese locale support for person names
- Added Japanese first names and last names
- Updated person module to support ja_JP locale
- Added tests for Japanese name generation
Closes #123
-
Push your branch:
git push origin feature/your-feature-name
-
Open a PR on GitHub:
- Go to the repository
- Click "Pull requests" → "New pull request"
- Select your branch
- Fill in the PR template
-
PR Description should include:
- What changes were made
- Why these changes are needed
- How to test the changes
- Screenshots (if applicable)
- Related issues (use "Closes #123")
- Maintainers will review your PR
- Address feedback and requested changes
- Once approved, your PR will be merged!
Be patient and responsive:
- Reviews may take a few days
- Be open to feedback
- Respond to comments
- Make requested changes promptly
Want to add a new data generator module? Follow these steps:
Create include/faker-cxx/your_module.h:
#pragma once
#include <string>
#include <string_view>
#include "faker-cxx/export.h"
#include "faker-cxx/types/locale.h"
namespace faker::yourModule
{
/**
* @brief Your function description.
* @param locale The locale. Defaults to `Locale::en_US`.
* @returns Description of return value.
* @code
* faker::yourModule::yourFunction() // "example output"
* @endcode
*/
FAKER_CXX_EXPORT std::string_view yourFunction(Locale locale = Locale::en_US);
}Create src/modules/your_module_data.h with your data arrays.
Create src/modules/your_module.cpp with implementations.
Create tests/modules/your_module_test.cpp with comprehensive tests.
Add your module to src/CMakeLists.txt and tests/CMakeLists.txt.
- Add your module to README.md
- Add examples
- Update API reference
Use Doxygen-style comments:
/**
* @brief Brief description of function.
*
* Detailed description if needed.
*
* @param paramName Description of parameter.
* @param locale The locale. Defaults to `Locale::en_US`.
*
* @returns Description of return value.
*
* @code
* faker::module::function() // "example output"
* faker::module::function(Locale::pl_PL) // "przykładowy wynik"
* @endcode
*/When adding features:
- Update the module list
- Add to API Reference section
- Include code examples
- Update table of contents if needed
- Discord: Join our Discord server
- Discussions: Use GitHub Discussions
- Issues: Check existing issues
Please read and follow our Code of Conduct. We're committed to providing a welcoming and inclusive environment.
Contributors are recognized in:
- The README contributors section
- Release notes for significant contributions
- Our community channels
If you have questions that aren't covered in this guide:
- Check the documentation
- Search existing issues
- Ask on Discord
- Start a discussion
We appreciate your time and effort in making this library better for everyone.