Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black
name: black
entry: black
language: system
types: [python]
files: ^sarif/
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Pull requests are welcome.
1. Fork the repository.
2. Make and test your changes (see Developer Guide below).
3. Run `poetry run ruff format` and `poetry run black sarif` to format the code.
- Alternatively, install pre-commit hooks to run black automatically before each commit (see [Setting up pre-commit hooks](#setting-up-pre-commit-hooks) below).
4. Run `poetry run pylint sarif` and check for no new errors or warnings.
5. Raise Pull Request in GitHub.com.

Expand Down Expand Up @@ -142,3 +143,19 @@ poetry update
### Adding resource files to the project

Add the file within the `sarif` directory and it will be installed with the Python source. For example, `sarif/operations/templates/sarif_summary.html`.

### Setting up pre-commit hooks

This repository uses [pre-commit](https://pre-commit.com/) to automatically run black code formatter before each commit. To set up pre-commit:

1. Ensure pre-commit is installed in your development environment:
```bash
poetry install
```

2. Install the git hooks:
```bash
poetry run pre-commit install
```

Once installed, black will automatically run on the files you've changed when you commit. If the formatter makes any changes, the commit will be aborted, allowing you to stage the formatting changes and try again.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pyyaml = "^6.0.1"

[tool.poetry.dev-dependencies]
jsonschema = "^4.23.0"
pre-commit = "^4.2.0"
pylint = "^3.2"
pytest = "^8.3"
pytest-cov = "^5.0"
Expand Down