Contributing
We welcome contributions to Haft! This page provides a quick overview. For detailed guidelines, see CONTRIBUTING.md.
Quick Start
# Clone the repository
git clone https://github.com/KashifKhn/haft.git
cd haft
# Install dependencies
go mod download
# Run tests
go test ./...
# Build
make build
# Run
./bin/haft --help
Code Standards
Haft follows strict coding standards:
No Comments
Code should be self-documenting. Use clear function and variable names instead of comments.
// Bad
// GetUserByID retrieves a user by their ID
func GetUserByID(id int) (*User, error) { ... }
// Good - self-explanatory
func GetUserByID(id int) (*User, error) { ... }
DRY Principle
Never repeat code. Extract common logic into reusable functions.
Size Limits
- Functions: Maximum 50 lines
- Files: Maximum 300 lines
Naming
| Type | Convention | Example |
|---|---|---|
| Exported | PascalCase | ParseConfig |
| Private | camelCase | parseFile |
| Files | snake_case | user_service.go |
Development Workflow
- Fork the repository
- Create a feature branch from
dev - Make your changes
- Run tests:
go test ./... - Submit a pull request
Commit Messages
Use conventional commits:
feat: add dependency search
fix: handle empty pom.xml
docs: update installation guide
refactor: simplify parser logic
Testing
- Target 80%+ code coverage
- Use table-driven tests
- Mock filesystem with
afero
func TestParser_Parse(t *testing.T) {
tests := []struct {
name string
input []byte
want *Project
wantErr bool
}{
// test cases
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// test logic
})
}
}
Getting Help
- GitHub Issues — Bug reports
- GitHub Discussions — Questions
License
By contributing, you agree that your contributions will be licensed under the MIT License.