Skip to content

Commit ec455db

Browse files
author
jzhu
committed
feat: implement comprehensive code quality tools and enforcement
1 parent b6ba846 commit ec455db

83 files changed

Lines changed: 7090 additions & 3835 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.flake8

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[flake8]
2+
# Flake8 configuration for code-assistant-manager
3+
4+
# Compatibility with Black
5+
max-line-length = 88
6+
extend-ignore = E203, W503, E501
7+
8+
# Exclude patterns
9+
exclude =
10+
.git,
11+
__pycache__,
12+
.venv,
13+
venv,
14+
env,
15+
.eggs,
16+
*.egg,
17+
build,
18+
dist,
19+
.tox,
20+
.mypy_cache,
21+
.pytest_cache,
22+
node_modules,
23+
*.egg-info
24+
25+
# Complexity
26+
max-complexity = 15
27+
28+
# McCabe complexity
29+
# Default is 10, we allow slightly more for complex CLI logic
30+
per-file-ignores =
31+
__init__.py:F401,F403
32+
cli.py:C901
33+
tools/base.py:C901
34+
35+
# Plugins configuration
36+
# flake8-bugbear, flake8-comprehensions, flake8-simplify
37+
select = C,E,F,W,B,B9

.pre-commit-config.yaml

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,77 @@
11
repos:
2+
# Standard pre-commit hooks
23
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
4+
rev: v4.5.0
45
hooks:
56
- id: trailing-whitespace
7+
exclude: '\.patch$'
68
- id: end-of-file-fixer
9+
exclude: '\.patch$'
710
- id: check-yaml
11+
- id: check-json
812
- id: check-added-large-files
13+
args: ['--maxkb=1000']
14+
- id: check-case-conflict
15+
- id: check-merge-conflict
16+
- id: check-toml
17+
- id: debug-statements
18+
- id: mixed-line-ending
19+
args: ['--fix=lf']
920

21+
# Python code formatting
1022
- repo: https://github.com/psf/black
11-
rev: 23.7.0
23+
rev: 24.3.0
1224
hooks:
1325
- id: black
26+
language_version: python3
27+
args: ['--config=pyproject.toml']
1428

29+
# Import sorting
30+
- repo: https://github.com/pycqa/isort
31+
rev: 5.13.2
32+
hooks:
33+
- id: isort
34+
args: ['--profile=black', '--line-length=88']
35+
36+
# Linting
1537
- repo: https://github.com/pycqa/flake8
1638
rev: 7.1.2
1739
hooks:
1840
- id: flake8
19-
args: [--max-line-length=88, --extend-ignore=E203,W503]
41+
args: ['--config=.flake8']
42+
additional_dependencies: [
43+
'flake8-bugbear',
44+
'flake8-comprehensions',
45+
'flake8-simplify',
46+
]
2047

48+
# Type checking
2149
- repo: https://github.com/pre-commit/mirrors-mypy
22-
rev: v1.5.1
50+
rev: v1.11.0
2351
hooks:
2452
- id: mypy
25-
additional_dependencies: [types-PyYAML]
53+
args: ['--config-file=pyproject.toml']
54+
additional_dependencies: [
55+
'types-PyYAML',
56+
'types-requests',
57+
'pydantic>=2.6.0',
58+
'typer>=0.12.0',
59+
]
60+
exclude: '^tests/'
61+
62+
# Security checks
63+
- repo: https://github.com/PyCQA/bandit
64+
rev: 1.7.8
65+
hooks:
66+
- id: bandit
67+
args: ['-c', 'pyproject.toml']
68+
additional_dependencies: ['bandit[toml]']
69+
exclude: '^tests/'
70+
71+
# Docstring coverage
72+
- repo: https://github.com/econchick/interrogate
73+
rev: 1.7.0
74+
hooks:
75+
- id: interrogate
76+
args: ['--config=pyproject.toml']
77+
pass_filenames: false

CLAUDE.md

Lines changed: 97 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,105 @@
22

33
This file documents repository-level expectations and instructions intended to guide contributors and AI-assisted editing tools (like Claude Code) when making changes in this project.
44

5-
- Ask for approval before any git commit and push
6-
- Always run tests before completing all development of new changes
7-
- Always test the CLI usages
8-
- After any changes, run the folling to reinstall the project:
9-
```
5+
## Core Guidelines
6+
7+
- **Ask for approval before any git commit and push**
8+
- **Always run tests** before completing all development of new changes
9+
- **Always test the CLI usages** to ensure functionality works end-to-end
10+
- **Run code quality checks** before committing (see below)
11+
12+
## Development Workflow
13+
14+
### After Any Changes
15+
16+
Reinstall the project to test in production-like environment:
17+
18+
```bash
1019
rm -rf dist/*
1120
./install.sh uninstall
1221
./install.sh
1322
cp ~/.config/code-assistant-manager/settings.json.bak ~/.config/code-assistant-manager/settings.json
1423
```
24+
25+
### Code Quality Requirements
26+
27+
Before committing, ensure all quality checks pass:
28+
29+
```bash
30+
# Quick check (formatting + linting + type-check + tests)
31+
make check
32+
33+
# Or run individually:
34+
make format # Auto-format code with Black and isort
35+
make lint # Check code style with Flake8
36+
make type-check # Verify type hints with mypy
37+
make security # Scan for security issues with Bandit
38+
make test # Run test suite
39+
```
40+
41+
**Pre-commit hooks** are automatically installed with `make dev-install` and will run these checks before each commit.
42+
43+
### Code Style Standards
44+
45+
- **Formatting**: Use Black (line length: 88)
46+
- **Import sorting**: Use isort (Black-compatible profile)
47+
- **Linting**: Follow Flake8 rules (see `.flake8`)
48+
- **Type hints**: Add type hints for new code (checked with mypy)
49+
- **Docstrings**: Use Google-style docstrings for public functions/classes
50+
- **Security**: No hardcoded secrets, follow Bandit recommendations
51+
52+
### Testing Requirements
53+
54+
- Write tests for all new functionality
55+
- Maintain or improve test coverage
56+
- Use appropriate test markers (`@pytest.mark.unit`, `@pytest.mark.integration`, etc.)
57+
- Mock external dependencies (APIs, file system, network)
58+
59+
## Quick Reference
60+
61+
### Setup Development Environment
62+
63+
```bash
64+
# One-time setup
65+
make dev-install # Install with dev dependencies + pre-commit hooks
66+
```
67+
68+
### Common Commands
69+
70+
```bash
71+
make help # Show all available commands
72+
make format # Auto-format code
73+
make check # Run all quality checks
74+
make test # Run test suite
75+
make test-cov # Run tests with coverage report
76+
```
77+
78+
### Before Submitting Code
79+
80+
1. ✅ Run `make check` - All checks must pass
81+
2. ✅ Run `make test` - All tests must pass
82+
3. ✅ Test CLI manually - Ensure functionality works
83+
4. ✅ Update documentation - If adding/changing features
84+
5. ✅ Review changes - Use `git diff` before committing
85+
86+
## Documentation
87+
88+
- See `CONTRIBUTING.md` for detailed contribution guidelines
89+
- See `docs/CODE_QUALITY.md` for comprehensive code quality tool documentation
90+
- See `docs/DESIGN_PATTERNS_README.md` for architecture patterns
91+
92+
## Attribution
93+
94+
When using AI assistance for code generation, add attribution in commit messages:
95+
96+
```bash
97+
git commit -m "feat: implement new feature
98+
99+
Co-Authored-By: Claude <noreply@anthropic.com>"
100+
```
101+
102+
## Questions?
103+
104+
- Review this document and `CONTRIBUTING.md`
105+
- Check code quality documentation in `docs/CODE_QUALITY.md`
106+
- Consult design patterns guide in `docs/DESIGN_PATTERNS_README.md`

0 commit comments

Comments
 (0)