Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
34 changes: 33 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,48 @@
# Pre-commit hooks for secret scanning
# Pre-commit hooks for DreamServer
# Install: pip install pre-commit && pre-commit install
# Run manually: pre-commit run --all-files

repos:
# Secret scanning
- repo: https://github.com/gitleaks/gitleaks
rev: v8.21.2
hooks:
- id: gitleaks

# Shell script linting
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
args: ["--exclude=SC1091,SC2034,SC2086", "--severity=error"]
files: \.sh$

# Python linting with Ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
hooks:
- id: ruff
args: ["--select", "E,F,W", "--ignore", "E501"]
files: ^dream-server/.*\.py$

# Python formatting with Black
- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black
args: ["--line-length=100"]
files: ^dream-server/.*\.py$

# General file checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: detect-private-key
- id: check-added-large-files
args: ['--maxkb=500']
- id: trailing-whitespace
exclude: \.md$
- id: end-of-file-fixer
- id: check-yaml
args: ["--unsafe"]
- id: check-json
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,36 @@ Nothing exotic:
- **Python** uses standard formatting (we're not picky -- just be consistent with the file you're editing).
- Keep things readable. Comments are welcome where intent isn't obvious.

## Pre-commit Hooks

This project uses pre-commit hooks to ensure code quality. To set up:

```bash
pip install pre-commit
pre-commit install
```

The hooks will run automatically on `git commit` and check for:
- Secret leaks (gitleaks)
- Shell script issues (shellcheck)
- Python linting (ruff)
- Python formatting (black)
- Large files, trailing whitespace, YAML/JSON syntax

To run hooks manually on all files:

```bash
pre-commit run --all-files
```

To bypass hooks (not recommended):

```bash
git commit --no-verify
```

**Note:** All Python files have been formatted with `black --line-length=100`. The pre-commit hooks will enforce this formatting going forward.

## Pull Request Process

1. **Describe your changes** in the PR description. A sentence or two is fine for small changes; more detail helps for larger ones.
Expand Down
Loading