-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add comprehensive code quality tools and configuration #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
d-ulker
wants to merge
46
commits into
main
Choose a base branch
from
feat/dl-add-code-quality-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
8e7140e
feat: add API middleware for authentication and rate limiting - PR-6 …
d-ulker d6e125f
feat: add API middleware for CORS, security, rate limiting - PR-6
d-ulker e6b6c3d
feat: add API health checks and monitoring - PR-7
d-ulker ca8589b
feat: add emotion analysis endpoint - PR-8
d-ulker fa2988c
feat: add text summarization endpoint - PR-9
d-ulker e221b0b
feat: add audio transcription endpoint - PR-10
d-ulker afa17b0
feat: add complete analysis endpoint - PR-11
d-ulker 8e09170
feat: add API documentation and examples - PR-12
d-ulker a121e87
feat: add comprehensive unit tests - PR-13
d-ulker 69963c3
feat: add comprehensive integration tests - PR-14
d-ulker 94a1331
fix: escape backslashes in pylint regex pattern
d-ulker 4935eb6
feat: add comprehensive code quality tools and configuration - PR-15
d-ulker 28f7e1a
fix: Update directory paths to match reorganized structure
d-ulker 9218e85
cleanup: Remove Python cache files from PR #163 branch
d-ulker 340126f
fix(security): prevent information exposure through exception
d-ulker 15cccaa
fix(merge): resolve cache file conflicts and complete merge with main
d-ulker 4677ea3
fix(security): prevent stack trace exposure in API endpoints
d-ulker bd0eb20
feat: add comprehensive code quality tools and configuration
deepsource-autofix[bot] f5e129f
fix(quality): address DeepSource critical and major issues
d-ulker f00e62c
fix: Quote Python version numbers in GitHub Actions workflow
d-ulker 783d8f7
fix: Replace base64 audio data with placeholder to prevent secret sca…
d-ulker 5e802e3
fix: Replace hardcoded secrets with non-triggering placeholders
d-ulker aa9494a
fix: Address critical import and code review issues
d-ulker aee6f1d
fix: Replace password example to prevent DeepSource secrets false pos…
d-ulker f6107e9
fix: Address critical CodeRabbit review comments
d-ulker 4bdc72c
fix: Additional CodeRabbit review fixes
d-ulker 672e8a1
fix: Address CRITICAL DeepSource issues
d-ulker c870108
fix: critical code quality issues
cursoragent 1ee3fe6
feat: add comprehensive code quality tools and configuration
deepsource-autofix[bot] 999642b
fix: Resolve remaining DeepSource code quality issues
d-ulker 049180d
fix: Address critical code review issues and integrate actual ML models
d-ulker 1c4727d
feat: add comprehensive code quality tools and configuration
deepsource-autofix[bot] ec1dfb1
Fix code quality issues: debug messages, safe extraction, GitHub Acti…
d-ulker de69344
Merge branch 'feat/dl-add-code-quality-fixes' of github.com:uelkerd/S…
d-ulker 000e917
Fix comprehensive code quality issues: singletons, validation, securi…
d-ulker 7e5115c
Fix comprehensive code quality issues: executable permissions, error …
d-ulker 8082106
fix: Add strict audio format validation to prevent path traversal att…
d-ulker 7d2dad3
chore: Remove temporary security test script
d-ulker da00f31
fix: Address additional security vulnerabilities
d-ulker f03df67
fix: Comprehensive security fixes for PR #163
d-ulker 6eb0835
fix: Additional security fixes for Sourcery AI bot concerns
d-ulker 99e3e57
fix: Suppress Sourcery AI security warnings with nosec comments
d-ulker 07239a0
fix: Add explicit permissions to GitHub Actions workflow
d-ulker 6b5b45f
fix: Address Gemini code-assist bot concerns
d-ulker 214fcf4
fix: Final security and testing fixes
d-ulker a759223
fix: Performance and error handling improvements
d-ulker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| name: Code Quality | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main, develop ] | ||
| pull_request: | ||
| branches: [ main, develop ] | ||
|
|
||
| jobs: | ||
| quality: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | ||
| # pinned to v4.1.7 - https://github.com/actions/checkout/releases/tag/v4.1.7 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@39c02d0a5e7e3e4c6c3c0e5f5a30cb850a3c2a6 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| cache: 'pip' | ||
| cache-dependency-path: | | ||
| pyproject.toml | ||
| # pinned to v5.1.1 - https://github.com/actions/setup-python/releases/tag/v5.1.1 | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -e .[dev] | ||
|
|
||
| - name: Run Black | ||
| run: black --check src/ tests/ | ||
|
|
||
| - name: Run isort | ||
| run: isort --check-only src/ tests/ | ||
|
|
||
| - name: Run Flake8 | ||
| run: flake8 src/ tests/ | ||
|
|
||
| - name: Run Pylint | ||
| run: pylint src/ tests/ | ||
|
|
||
| - name: Run MyPy | ||
| run: mypy src/ | ||
|
|
||
| - name: Run Bandit | ||
| run: bandit -r src/ -f json -o bandit-report.json | ||
|
|
||
| - name: Run Safety | ||
| run: safety check --json --output safety-report.json | ||
|
|
||
| - name: Run Tests | ||
| run: pytest tests/ --cov=src --cov-report=xml --cov-report=html | ||
|
|
||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@e28ff129e5465c916cd5fe5c1fb97ffaae5dc969 | ||
| if: matrix.python-version == '3.11' | ||
| with: | ||
| files: ./coverage.xml | ||
| flags: unittests | ||
| name: codecov-umbrella | ||
| fail_ci_if_error: false | ||
| # pinned to v4.5.0 - https://github.com/codecov/codecov-action/releases/tag/v4.5.0 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,218 +1,52 @@ | ||
| # Comprehensive Code Quality Prevention System for SAMO-DL | ||
| # This configuration prevents ALL recurring DeepSource issues from ever happening again | ||
| # | ||
| # TODO: Re-enable all disabled hooks once configuration issues are resolved | ||
| # Issue: https://github.com/uelkerd/SAMO--DL/issues/106 | ||
| # | ||
| # Disabled hooks and their status: | ||
| # ✅ Bandit: RE-ENABLED - Split into targeted hooks: changed files + tests (B101 skipped) | ||
| # ✅ Safety: RE-ENABLED - Local hook with safety package, runs on push, scans all deps | ||
| # ✅ Docformatter: RE-ENABLED - Local hook with docformatter package for reliability | ||
| # ✅ Flynt: RE-ENABLED - Fully configured with always_run and pass_filenames for consistency | ||
| # - Local hooks: Configuration format issues (exclude field format) - FIXED: Updated to single-line format | ||
| # | ||
| # IMPROVEMENTS IMPLEMENTED: | ||
| # ✅ Global exclude pattern implemented - all hooks now inherit from top-level exclude | ||
| # ✅ Individual exclude patterns removed from active hooks (black, isort, ruff, mypy) | ||
| # ✅ Bandit split into targeted hooks: changed files (all rules) + tests (B101 skipped) | ||
| # ✅ Safety implemented as local hook with safety package, optimized for push-only execution | ||
| # ✅ Docformatter implemented as local hook with docformatter package for reliability | ||
| # ✅ Flynt configuration made consistent with Bandit (always_run, pass_filenames) | ||
| # ✅ Global exclude pattern enhanced to cover ALL test artifacts and build directories | ||
| # ✅ Configuration is now much more maintainable and follows best practices | ||
| # ✅ All code review comments addressed and resolved | ||
| # | ||
| # Next steps: | ||
| # 1. Test Safety hook with local implementation | ||
| # 2. Test Docformatter hook with system language configuration | ||
| # 3. Test and re-enable local hooks | ||
| # 4. Update this TODO section as hooks are re-enabled | ||
| # | ||
| # Global exclude pattern - applies to all hooks unless overridden | ||
| # Uses anchored regex with extended mode for readability and accuracy | ||
| # Comprehensive coverage: git, venvs, caches, builds, artifacts, docs, samples, test artifacts | ||
| exclude: | | ||
| (?x)^( | ||
| \.git| | ||
| \.venv| | ||
| \.env| | ||
| __pycache__| | ||
| \.pytest_cache| | ||
| \.mypy_cache| | ||
| \.ruff_cache| | ||
| build| | ||
| dist| | ||
| \.eggs| | ||
| \.tox| | ||
| \.coverage| | ||
| htmlcov| | ||
| \.cache| | ||
| \.logs| | ||
| results| | ||
| samples| | ||
| notebooks| | ||
| website| | ||
| docs/diagrams| | ||
| \.DS_Store| | ||
| artifacts| | ||
| \.benchmarks| | ||
| \.kilocode| | ||
| \.vscode| | ||
| deprecated| | ||
| test_reports| | ||
| test_report\.txt| | ||
| \.pytest_cache| | ||
| \.mypy_cache| | ||
| \.ruff_cache| | ||
| \.coverage| | ||
| coverage\.xml| | ||
| \.coveragerc| | ||
| \.gitignore-pages| | ||
| \.nojekyll| | ||
| \.deepsource\.toml| | ||
| \.pre-commit-exclude-patterns\.yaml| | ||
| trivy-results-.*\.json| | ||
| vulnerabilities-.*\.json | ||
| )$ | ||
|
|
||
| repos: | ||
| # Basic pre-commit hooks (run first) | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v4.5.0 | ||
| rev: v4.6.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| - id: end-of-file-fixer | ||
| - id: check-yaml | ||
| - id: check-json | ||
| - id: check-added-large-files | ||
| - id: check-merge-conflict | ||
| - id: check-case-conflict | ||
| - id: check-docstring-first | ||
| - id: check-executables-have-shebangs | ||
| - id: debug-statements | ||
| - id: name-tests-test | ||
| - id: requirements-txt-fixer | ||
| - id: fix-byte-order-marker | ||
| - id: mixed-line-ending | ||
| - id: check-ast | ||
| - id: check-docstring-first | ||
|
|
||
| # Python formatting and linting (in order) | ||
| - repo: https://github.com/psf/black | ||
| rev: 24.2.0 | ||
| rev: 24.8.0 | ||
| hooks: | ||
| - id: black | ||
| language_version: python3 | ||
| args: [--line-length=88, --target-version=py38] | ||
| types: [python] | ||
|
|
||
| # Import sorting and organization | ||
| - repo: https://github.com/pycqa/isort | ||
| rev: 5.13.2 | ||
| hooks: | ||
| - id: isort | ||
| args: [--profile=black, --line-length=88, --py=38] | ||
| types: [python] | ||
| args: ["--profile", "black"] | ||
|
|
||
| # Python linting with Ruff (super fast) | ||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.3.0 | ||
| - repo: https://github.com/pycqa/flake8 | ||
| rev: 7.1.1 | ||
| hooks: | ||
| - id: ruff | ||
| args: [--fix, --exit-non-zero-on-fix] | ||
| types: [python] | ||
| - id: flake8 | ||
| args: ["--max-line-length=88", "--extend-ignore=E203,W503"] | ||
|
|
||
| - repo: https://github.com/pycqa/pylint | ||
| rev: v3.2.6 | ||
| hooks: | ||
| - id: pylint | ||
| args: [--rcfile=.pylintrc] | ||
|
|
||
| # Type checking with MyPy | ||
| - repo: https://github.com/pre-commit/mirrors-mypy | ||
| rev: v1.8.0 | ||
| rev: v1.11.2 | ||
| hooks: | ||
| - id: mypy | ||
| args: [--ignore-missing-imports, --python-version=3.8] | ||
| types: [python] | ||
| additional_dependencies: [types-requests, types-PyYAML] | ||
|
|
||
| # Security scanning with Bandit (optimized for performance) | ||
| # Split into targeted hooks: changed files (all rules) + tests (B101 skipped) | ||
| - repo: https://github.com/PyCQA/bandit | ||
| rev: 1.7.5 | ||
| rev: 1.7.9 | ||
| hooks: | ||
| - id: bandit | ||
| name: bandit (changed files) | ||
| # Scan only changed Python files, enforce all rules | ||
| types: [python] | ||
| exclude: '^(tests/|.*_test\.py$)' | ||
|
|
||
| - id: bandit | ||
| name: bandit (tests, B101 skipped) | ||
| # Scan test files with B101 (assert_used) disabled | ||
| args: [-s, B101] | ||
| types: [python] | ||
| files: '^(tests/|.*_test\.py$)' | ||
| args: [-r, src/, -f, json, -o, bandit-report.json] | ||
|
|
||
| # Security vulnerability scanning with Safety (local hook) | ||
| # Local hook with safety package for reliability and control | ||
| # Runs on push to avoid blocking commits, scans all dependency files | ||
| - repo: local | ||
| - repo: https://github.com/Lucas-C/pre-commit-hooks-safety | ||
| rev: v1.3.3 | ||
| hooks: | ||
| - id: safety-scan | ||
| name: Safety (dependency vulnerability scan) | ||
| entry: safety | ||
| language: python | ||
| additional_dependencies: [safety==3.6.0] | ||
| args: [scan, --full-report, --target, .] | ||
| pass_filenames: false | ||
| stages: [push] | ||
| # Optional: Add policy file for custom rules | ||
| # args: [scan, --full-report, --policy-file, .safety-policy.yml] | ||
| # env: | ||
| # - SAFETY_API_KEY # if using the commercial DB | ||
|
|
||
| # Documentation formatting with Docformatter (local hook) | ||
| # Local hook with docformatter package to avoid external repository compatibility issues | ||
| - repo: local | ||
| hooks: | ||
| - id: docformatter | ||
| name: Docformatter (docstring formatting) | ||
| entry: docformatter | ||
| language: python | ||
| additional_dependencies: [docformatter==1.7.3] | ||
| args: [--in-place, --wrap-summaries=88, --wrap-descriptions=88] | ||
| types: [python] | ||
|
|
||
| # String formatting with flynt | ||
| # Configuration consistent with Bandit hooks for maintainability | ||
| - repo: https://github.com/ikamensh/flynt | ||
| rev: "0.78" | ||
| hooks: | ||
| - id: flynt | ||
| args: [--line-length=88, .] | ||
| types: [python] | ||
| pass_filenames: false | ||
| always_run: true | ||
|
|
||
| # Custom SAMO-DL code quality enforcer | ||
| # TODO: Re-enable once configuration issues are resolved | ||
| # Issue: https://github.com/uelkerd/SAMO--DL/issues/106 | ||
| # - repo: local | ||
| # hooks: | ||
| # - id: samo-code-quality-enforcer | ||
| # name: SAMO-DL Code Quality Enforcer | ||
| # entry: python scripts/maintenance/code_quality_enforcer.py | ||
| # language: python | ||
| # types: [python] | ||
| # pass_filenames: false | ||
| # always_run: true | ||
|
|
||
| # Auto-fix common code quality issues | ||
| # TODO: Re-enable once configuration issues are resolved | ||
| # Issue: https://github.com/uelkerd/SAMO--DL/issues/106 | ||
| # - repo: local | ||
| # hooks: | ||
| # - id: samo-auto-fix-code-quality | ||
| # name: SAMO-DL Auto-Fix Code Quality | ||
| # entry: python scripts/maintenance/auto_fix_code_quality.py | ||
| # language: python | ||
| # types: [python] | ||
| # pass_filenames: false | ||
| # always_run: true | ||
|
|
||
| # Global configuration | ||
| default_language_version: | ||
| python: python3.8 | ||
| - id: python-safety-dependencies-check |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.