Thank you for your interest in contributing to Trapper! This document provides guidelines and instructions for contributing to the project.
This project adheres to a code of conduct that all contributors are expected to follow. Please be respectful and constructive in all interactions.
- Report bugs: Found a problem? Let us know!
- Suggest features: Have an idea? Open an issue to discuss it.
- Improve documentation: Found a typo or unclear explanation? Submit a PR.
- Write code: Fix bugs or implement new features.
- Test: Try the software and report your experience.
- Java 21 or higher
- Gradle 8.5 or higher
- Git
-
Fork the repository on GitHub
-
Clone your fork:
git clone https://github.com/YOUR-USERNAME/trapper.git cd trapper -
Add upstream remote:
git remote add upstream https://github.com/electrosaur-labs/trapper.git
-
Build the project:
./gradlew build
-
Run tests:
./gradlew test
GUI Mode:
./gradlew runGUICommand-line Mode:
./gradlew runColorSeparator --args="input.psd"- Check existing issues to see if your bug/feature is already being discussed
- Open an issue to discuss significant changes before starting work
- Keep changes focused: One feature/fix per pull request
-
Create a branch for your changes:
git checkout -b feature/your-feature-name # or git checkout -b fix/bug-description -
Make your changes:
- Write clear, commented code
- Follow existing code style
- Add tests for new functionality
- Update documentation as needed
-
Test your changes:
# Run all tests ./gradlew test # Run specific test class ./gradlew test --tests PsdColorSeparatorTest # Test with real images ./gradlew runColorSeparator --args="test.psd"
-
Commit your changes:
git add . git commit -m "Brief description of changes"
Write clear commit messages:
- Use present tense ("Add feature" not "Added feature")
- Keep first line under 72 characters
- Add detailed explanation in body if needed
-
Keep your branch updated:
git fetch upstream git rebase upstream/main
-
Push to your fork:
git push origin feature/your-feature-name
-
Open a Pull Request on GitHub
- Indentation: 4 spaces (no tabs)
- Line length: Max 120 characters
- Naming:
- Classes:
PascalCase - Methods/variables:
camelCase - Constants:
UPPER_SNAKE_CASE
- Classes:
- Comments: Use Javadoc for public methods/classes
- Imports: No wildcard imports (
import java.util.*)
/**
* Calculates the trap size for a given layer based on its lightness.
*
* @param layerIndex The index of the layer (0 = lightest)
* @param totalLayers The total number of layers
* @param dpi Image resolution in dots per inch
* @return The trap size in pixels
*/
public int calculateTrapSize(int layerIndex, int totalLayers, int dpi) {
double normalizedPosition = (double) layerIndex / (totalLayers - 1);
double trapInches = minTrap + (maxTrap - minTrap) * normalizedPosition;
return (int) Math.round(trapInches * dpi);
}- Unit tests: Test individual methods in isolation
- Integration tests: Test complete workflows with real PSD files
- Test naming:
testMethodName_Scenario_ExpectedResult
- All new public methods should have tests
- Bug fixes should include a test that reproduces the bug
- Aim for high coverage, but prioritize meaningful tests
@Test
public void testParseTrapSize_Fraction_ReturnsCorrectValue() throws Exception {
double result = parseTrapSize("1/32");
assertEquals(0.03125, result, 0.0000001);
}
@Test(expected = IllegalArgumentException.class)
public void testParseTrapSize_InvalidFormat_ThrowsException() throws Exception {
parseTrapSize("invalid");
}- Adding new features
- Changing existing behavior
- Fixing bugs that affect usage
- Improving clarity
- README.md: User-facing features, usage examples
- Javadoc comments: Public API methods and classes
- Code comments: Complex algorithms, non-obvious decisions
- CHANGELOG.md: Notable changes (we'll add this soon)
- Code compiles without errors
- All tests pass
- New tests added for new features
- Documentation updated
- Code follows project style
- Commit messages are clear
## Description
Brief description of what this PR does.
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Refactoring
## Testing
Describe how you tested your changes.
## Related Issues
Fixes #123- Maintainers will review your PR
- Address any requested changes
- Once approved, a maintainer will merge
trapper/
├── src/
│ ├── main/java/org/electrosaur/trapper/
│ │ ├── PsdColorSeparator.java # Main trapping engine
│ │ ├── TrapperGUI.java # GUI interface
│ │ ├── TrappingStrategy.java # Strategy pattern interface
│ │ ├── OffsetTrappingStrategy.java # Offset lithography mode
│ │ └── ScreenPrintingTrappingStrategy.java # Screen printing mode
│ └── test/java/org/electrosaur/trapper/
│ ├── PsdColorSeparatorTest.java # Unit tests
│ └── TrappingIntegrationTest.java # Integration tests
├── build.gradle # Build configuration
├── README.md # User documentation
└── CONTRIBUTING.md # This file
Look for issues labeled good first issue - these are perfect for new contributors and include:
- Documentation improvements
- Simple bug fixes
- Adding test cases
- Code cleanup
- Questions: Open a GitHub Discussion
- Bugs: Open a GitHub Issue with details
- Feature ideas: Open an issue to discuss before implementing
All contributors will be acknowledged in the project. Significant contributions may be highlighted in release notes.
By contributing to Trapper, you agree that your contributions will be licensed under the GPL-3.0 license.
Thank you for contributing to Trapper! 🎨