Thank you for your interest in contributing to JEncrypt! This document provides guidelines for contributing to the project.
- Be respectful and inclusive
- Provide constructive feedback
- Focus on what's best for the project and community
- Check if the bug has already been reported in Issues
- If not, create a new issue with:
- Clear, descriptive title
- Steps to reproduce the problem
- Expected vs actual behavior
- Java version and platform (OS)
- Code samples if applicable
- Check if the enhancement has already been suggested
- Create a new issue with:
- Clear description of the enhancement
- Use cases and benefits
- Potential implementation approach (optional)
- Fork the repository and create a branch from
main - Write code following our coding standards (see below)
- Write tests - all new code must have tests with 96%+ coverage
- Run tests - ensure all tests pass:
mvn test - Update documentation - update README.md if changing public APIs
- Commit - write clear, descriptive commit messages
- Submit PR - provide a clear description of changes
CRITICAL - These are enforced by Maven and will fail the build:
-
No Wildcard Imports
// ✅ Good import java.util.Properties; import java.util.List; // ❌ Bad - will fail build import java.util.*;
-
96% Code Coverage Minimum
- All new code must be tested
- Run
mvn testto check coverage - View report:
target/site/jacoco/index.html
-
X.Y Version Format Only
- Versions must be
X.Yformat (e.g., 1.0, 1.1, 2.0) - No
-SNAPSHOTor other suffixes - Enforced by maven-enforcer-plugin
- Versions must be
- Java Version: Java 21
- Naming:
- Classes: PascalCase
- Methods: camelCase
- Constants: UPPER_SNAKE_CASE
- Packages: lowercase
- Formatting:
- 4 spaces for indentation (no tabs)
- Max line length: 120 characters
- Opening braces on same line
- Javadoc:
- All public classes and methods must have Javadoc
- Include
@param,@return,@throwsas applicable - Provide usage examples for public APIs
/**
* Encrypts plaintext using AES-256-GCM.
* <p>
* Each call generates a random IV, ensuring different ciphertexts
* for identical plaintexts.
* </p>
*
* @param plaintext the value to encrypt (must not be null or empty)
* @return base64-encoded IV + ciphertext + authentication tag
* @throws IllegalArgumentException if plaintext is null or empty
* @throws IllegalStateException if encryption fails
*/
public String encrypt(String plaintext) {
if (plaintext == null || plaintext.isEmpty()) {
throw new IllegalArgumentException("Cannot encrypt null or empty plaintext");
}
// ... implementation
}- Unit Tests: All methods must have unit tests
- Edge Cases: Test null, empty, boundary values
- Error Cases: Test all exception paths
- Integration: Test interaction between components
- Thread Safety: Test concurrent access where applicable
@Test
void testMethodName_whenCondition_thenExpectedBehavior() {
// Arrange
AESEncryption encryption = new AESEncryption();
// Act
String result = encryption.encrypt("test");
// Assert
assertTrue(AESEncryption.isEncrypted(result));
}# Run all tests
mvn test
# Run specific test class
mvn test -Dtest=AESEncryptionTest
# Run with coverage report
mvn clean test
open target/site/jacoco/index.html- Never commit secrets: No passwords, API keys, or tokens in code
- Validate inputs: Always validate method parameters
- Document security implications: Note machine-specific encryption behavior
- Use secure defaults: AES-256-GCM, PBKDF2 with 100K iterations
- README.md: Update for new features or API changes
- CHANGELOG.md: Document all changes (Added/Changed/Removed/Fixed)
- Javadoc: Keep in sync with code
- Code comments: Only when WHY is non-obvious (not WHAT)
mvn clean packagemvn clean install- Versions are auto-incremented by CI/CD on merge to main
- Format: X.Y (e.g., 1.0 → 1.1 → 1.2)
- No manual version changes needed
On push to main:
- Build and test
- Check coverage (must be ≥96%)
- Package JAR
- Deploy to packagecloud.io
- Auto-increment version (Y++)
- Commit version bump with
[ci skip]
- Open an issue for questions about contributing
- Check existing issues and PRs for similar discussions
- Review code and tests for examples
By contributing, you agree that your contributions will be licensed under the GNU General Public License v3.0.