Thank you for your interest in contributing to Code-Guardian! This document provides guidelines and information for contributors.
This project follows a code of conduct to ensure a welcoming environment for all contributors. Please be respectful and constructive in all interactions.
- Fork the repository on GitHub
- Clone your fork locally
- Set up the development environment:
git clone https://github.com/d-oit/code-guardian.git cd code-guardian cargo build cargo test
- Use
cargo fmtfor formatting (4-space indentation, 100 char lines) - Follow Rust naming conventions: snake_case for functions/variables, PascalCase for types
- Group imports: std, external crates, then local crates
- Use explicit imports over globs where possible
- Follow the modular architecture with separate crates for different concerns
- Keep modules under 500 lines of code
- Use strong typing and prefer
&stroverStringfor parameters - Use
Result<T, E>for fallible operations
- Use
thiserrorfor custom errors,anyhowfor generic errors - Prefer the
?operator for error propagation
- Document all public APIs with
///comments - Use
cargo docto generate documentation - Write clear, concise documentation with examples where helpful
- Write unit tests for all new code using
#[test] - Use
#[cfg(test)]modules for test-specific code - Aim for 82%+ test coverage
- Run tests with
cargo test
- Use
rayonfor parallelism where appropriate - Prefer channels over shared state for concurrency
- Use
serdewith derive macros - Prefer JSON/YAML over binary formats when possible
Code-Guardian uses specialized AI agents for different aspects:
- Core Agent: Scanning logic and pattern detection
- Storage Agent: Database operations
- Output Agent: Formatting and output generation
- CLI Agent: User interface and command handling
- Testing Agent: Quality assurance and testing
- CI Agent: Automation and continuous integration
- Docs Agent: Documentation management
- Create a feature branch from
main - Make your changes following the guidelines above
- Run the quality checks:
cargo fmt --check cargo clippy cargo test cargo build - Commit with clear, descriptive messages
- Push to your fork and create a pull request
Use conventional commit format:
feat:for new featuresfix:for bug fixesdocs:for documentation changesrefactor:for code refactoringtest:for test additions/changeschore:for maintenance tasks
Example: feat: add support for custom pattern detection
- Ensure your PR description clearly describes the changes and their purpose
- Reference any related issues
- Ensure all CI checks pass
- Request review from maintainers
- Address any feedback and make necessary changes
All pull requests must comply with the branch protection rules configured for the repository. This includes:
- 2 Approvals: At least two maintainer approvals are required before merging.
- Signed Commits: All commits must be signed to verify authorship.
- Passing Status Checks: All CI/CD pipelines, including tests, linting, and security scans, must pass.
For detailed setup instructions and configuration, refer to BRANCH_PROTECTION_SETUP.md.
When reporting bugs or requesting features:
- Use the GitHub issue tracker
- Provide clear, detailed descriptions
- Include steps to reproduce for bugs
- Specify your environment (OS, Rust version, etc.)
To add new pattern detectors:
- Implement the
PatternDetectortrait in thecorecrate - Add the detector to the scanner in the CLI
- Update documentation and tests
To add new output formats:
- Implement the
Formattertrait in theoutputcrate - Add the format option to the CLI
- Update documentation and tests
- Keep the README up-to-date
- Add examples for new features
- Update API documentation with code changes
- Write comprehensive tests for new functionality
- Test edge cases and error conditions
- Ensure integration tests cover cross-crate interactions
- Be mindful of security implications in code changes
- Report security issues privately to maintainers
- Follow secure coding practices
By contributing, you agree that your contributions will be licensed under the same license as the project.
Thank you for contributing to Code-Guardian!