Development
This guide explains how to set up your development environment and contribute to DDLCheck.
Setting Up
- Clone the repository
- Install Poetry
DDLCheck uses Poetry for dependency management. If you don't have Poetry installed:
- Install dependencies
- Activate virtual environment
Development Tasks
Running Tests
# Run all tests
poetry run pytest
# Run with coverage report
poetry run pytest --cov=src/ddlcheck --cov-report=term-missing
Building Documentation
Code Quality Tools
DDLCheck uses several tools to ensure code quality:
# Run linting
poetry run flake8
# Run type checking
poetry run mypy src
# Run all pre-commit hooks
poetry run pre-commit run --all-files
Creating a New Check
To create a new check:
- Create a new file in
src/ddlcheck/checks/my_check.py - Implement the check class by extending the
Checkbase class - Add your check to
ALL_CHECKSinsrc/ddlcheck/checks/__init__.py - Add tests in
tests/checks/test_my_check.py - Add documentation in
docs/checks/my_check.md
Example of a check implementation:
"""Check for something risky."""
from typing import Any, Dict, List
from ddlcheck.core import Check
from ddlcheck.models import Issue, SeverityLevel
class MyCheck(Check):
"""Check for something risky."""
@property
def id(self) -> str:
"""Return the unique identifier for this check."""
return "my_check"
@property
def description(self) -> str:
"""Return a description of what this check looks for."""
return "Detects something risky that could cause issues"
@property
def severity(self) -> SeverityLevel:
"""Return the default severity level for issues found by this check."""
return SeverityLevel.MEDIUM
def check_statement(self, stmt: Dict[str, Any], line: int) -> List[Issue]:
"""Check a single SQL statement for issues.
Args:
stmt: The parsed SQL statement
line: The line number where the statement begins
Returns:
List of issues found in the statement
"""
issues = []
# Check logic here...
if issue_detected:
issues.append(
self.create_issue(
message="Something risky was detected",
line=line,
suggestion="Here's how to fix it",
)
)
return issues
Release Process
- Update version in
src/ddlcheck/__init__.py - Update CHANGELOG.md
- Create a new release on GitHub
- The package will be automatically published to PyPI