Contributing to Azure Functions Doctor¶
This guide provides instructions for contributing to Azure Functions Doctor. Follow these standards to ensure a smooth review process and maintain code quality.
Getting Started¶
- Fork the repository on GitHub and clone your fork locally.
- Add the upstream remote to stay synced with the main repository:
- Create and activate a virtual environment (using venv or your preferred tool).
- Install the package in editable mode with development dependencies:
- Set up the pre-commit hooks:
- Verify your setup by running the full quality gate:
Development Workflow¶
- Sync your local main branch with the upstream main branch.
- Create a descriptive feature branch from main.
- Implement your changes in the
src/azure_functions_doctor/directory. - Add corresponding tests in the
tests/directory. - Run
make check-allto ensure all checks and tests pass locally. - Commit your changes using the Conventional Commits format.
- Push your branch to your fork and create a Pull Request.
Commit Message Convention¶
Titles for issues, pull requests, and commits follow the Title Convention in CONTRIBUTING.md, the single source of truth for the format and the allowed types.
Code Quality Standards¶
All contributions must adhere to the following tools. Exact pinned versions live
in pyproject.toml ([project.optional-dependencies] dev) and
.pre-commit-config.yaml — treat those files as the source of truth rather than
copying versions into docs:
- ruff: formatting and linting in one tool. Line length 100, target
py311, rule selectionC4,E,F,I,UP. There is no Black in this project;ruff formatreplaced it. - mypy: static type checking in strict mode, with missing imports ignored
and
tests/fixtures/excluded. - bandit: security scanning of
src/. - forbid-korean: a pre-commit hook ensuring code and documentation are written in English (locale READMEs excluded).
Makefile Targets¶
Use these commands to manage your development environment:
| Target | Description |
|---|---|
| make format | Format code with ruff format |
| make lint | Run ruff style checks and mypy |
| make typecheck | Run mypy in strict mode |
| make test | Run the full test suite |
| make cov | Run tests and generate a coverage report |
| make security | Run bandit security scans |
| make check-all | Run all formatting, linting, type checking, and tests |
Adding New Diagnostic Rules¶
To add a new diagnostic rule to the doctor:
- Define the rule metadata in
src/azure_functions_doctor/assets/rules/v2.json. - Implement the logic for the rule as a handler method in
src/azure_functions_doctor/handlers/registry.py. - Decorate that method with
@_rule_handler(src/azure_functions_doctor/handlers/_helpers.py); it derives the rule type from the_handle_prefix and registers it in_RULE_DISPATCHautomatically. - Extend
src/azure_functions_doctor/schemas/rules.schema.jsonso the new type is schema-valid. - Add unit tests for the new handler in
tests/test_handler.py. - Update any relevant documentation if the behavior changes user expectations.
Handler Guidelines¶
- Always return a dictionary with
statusanddetailkeys. - Use the internal
_create_result()helper (handlers/_helpers.py) for consistent response structures. - Use
_handle_exception()to map unexpected errors onto afailresult instead of crashing the run. - Include appropriate logging with
logger.debug()orlogger.warning(). - Ensure each handler stays focused on a single responsibility.
Testing Requirements¶
- Every new handler and CLI change must include tests.
- Use
tmp_pathfor tests that interact with the filesystem. - Use
CliRunnerfromtyper.testingfor testing CLI interactions and outputs. - Ensure you test all possible result statuses:
pass,warn,fail, andskip. - Mock external dependencies or network calls to keep tests fast and isolated.
- Use descriptive test names like
test_<handler>_returns_<status>_when_<condition>.
Example Coverage Policy¶
- Maintain at least one representative example for the smallest supported workflow.
- Include one complex example to demonstrate realistic integration scenarios.
- Add smoke tests whenever examples are modified.
- Prioritize lightweight smoke coverage over infrastructure-heavy end-to-end tests.
Pull Request Process¶
- Branch from the latest main branch.
- Use the Conventional Commits format for your commit messages.
- Include comprehensive tests for any new functionality.
- Update documentation if your changes modify existing behavior.
- Keep Pull Requests focused and atomic; avoid bundling unrelated changes.
- Ensure all CI checks pass before requesting a review.
- Link related issues in the description using keywords like
Fixes #123.
Code of Conduct¶
All contributors are expected to adhere to the standards outlined in our CODE_OF_CONDUCT.md.