Skip to content

feat(dev): add pre-commit hooks for code quality and security#74

Open
emmanuelgjr wants to merge 1 commit intoGenAI-Security-Project:v0.2from
emmanuelgjr:feat/51-pre-commit-hooks
Open

feat(dev): add pre-commit hooks for code quality and security#74
emmanuelgjr wants to merge 1 commit intoGenAI-Security-Project:v0.2from
emmanuelgjr:feat/51-pre-commit-hooks

Conversation

@emmanuelgjr
Copy link
Copy Markdown

Summary

  • Add .pre-commit-config.yaml with hooks for trailing whitespace, EOF fixer, YAML validation, large file detection (500KB), merge conflict markers, and debug statement detection
  • Add ruff pre-commit hooks for linting (with auto-fix) and code formatting
  • Add bandit pre-commit hook for automated security scanning
  • Add [tool.ruff] and [tool.bandit] configuration to pyproject.toml
  • Add pre-commit and bandit[toml] to dev dependencies

Ruff rules enabled

Rule Description
E pycodestyle errors
W pycodestyle warnings
F pyflakes
I isort (import sorting)
B flake8-bugbear
UP pyupgrade

Setup for contributors

pip install -e ".[dev]"
pre-commit install

Test plan

  • pre-commit and bandit install successfully via pip install -e ".[dev]"
  • pre-commit run --all-files passes on the codebase
  • pre-commit install sets up git hooks correctly
  • Committing a file with trailing whitespace triggers the hook

Closes #51

Generated with Claude Code

Add .pre-commit-config.yaml with:
- pre-commit-hooks: trailing whitespace, end-of-file, YAML check,
  large files (500KB limit), merge conflict markers, debug statements
- ruff: linting with auto-fix and formatting
- bandit: security scanning (excludes tests)

Add ruff configuration to pyproject.toml with rules for pycodestyle,
pyflakes, isort, flake8-bugbear, and pyupgrade. Add bandit config
excluding test directory. Add pre-commit and bandit to dev dependencies.

Closes GenAI-Security-Project#51

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant