jps-pre-commit-utils


Namejps-pre-commit-utils JSON
Version 1.2.0 PyPI version JSON
download
home_pageNone
SummaryCustom pre-commit utility for scanning diffs for debug/test patterns, hardcoded paths, and other configurable checks.
upload_time2025-11-01 16:25:40
maintainerNone
docs_urlNone
authorJaideep Sundaram
requires_python>=3.9
licenseMIT License
keywords pre-commit git lint static-analysis utilities
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # jps-pre-commit-utils

![Build](https://github.com/jai-python3/jps-pre-commit-utils/actions/workflows/test.yml/badge.svg)
![Publish to PyPI](https://github.com/jai-python3/jps-pre-commit-utils/actions/workflows/publish-to-pypi.yml/badge.svg)
[![codecov](https://codecov.io/gh/jai-python3/jps-pre-commit-utils/branch/main/graph/badge.svg)](https://codecov.io/gh/jai-python3/jps-pre-commit-utils)


Custom pre-commit utilities for detecting debug/test leftovers, hardcoded paths, and environment-specific code fragments  
in Python, Perl, and YAML files before they are committed.  
These checks catch issues that are not easily detected by flake8, black, mypy, or bandit.

---

## 🧩 Features

βœ… Scans *staged diffs* (`git diff --cached`) before commit  
βœ… Detects newly added lines containing:
- Debugging and testing statements (e.g., `print`, `sys.exit`, `pdb.set_trace`, `logger.debug`)
- Hardcoded filesystem paths (e.g., `/mnt/synth-genomics3/...`)
- Hardcoded environment variables or hostnames
- Inline comments with β€œtest” or β€œTODO”
βœ… Supports **Python**, **Perl**, and **YAML** files  
βœ… Configurable via `.my-pre-commit-checks.yaml` or `~/.config/my-pre-commit-checks.yaml`  
βœ… Integrates easily with manual usage or `.pre-commit-config.yaml`

---

## 🧩 Installation

```bash
pip install jps-pre-commit-utils
```

For local development:

```bash
git clone git@github.com:jai-python3/jps-pre-commit-utils.git
cd jps-pre-commit-utils
pip install -e '.[dev]'
```

---

## 🧩 Usage

Run manually:

```bash
jps-pre-commit-checks
```

Or integrate with Git pre-commit:

```bash
# .git/hooks/pre-commit
#!/bin/bash
python3 -m jps_pre_commit_utils.check_inserted_lines
```

---

## 🧩 Example Configuration

Configuration file:  
`.my-pre-commit-checks.yaml` *(in repo root)*  
or  
`~/.config/my-pre-commit-checks.yaml` *(global fallback)*

```yaml
# Example configuration for jps-pre-commit-utils
base_paths:
  - /mnt/synth-genomics3
  - /Users
ignore_patterns:
  - /mnt/synth-genomics3/bioinfo/shared/
extra_regexes:
  - "jira/[A-Z]+-[0-9]+"
```

---

## 🧩 Example Output

```bash
---------------------------------------------------------
πŸ”§ Performing the following checks:
---------------------------------------------------------
β€’ 🐍 Python debug/test statements
β€’ πŸͺ Perl debug/test statements
β€’ πŸ“ Hardcoded absolute paths
β€’ πŸ§ͺ Comments containing 'test' or 'testing'
---------------------------------------------------------
Scanning inserted lines ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% β€’ 45/45
---------------------------------------------------------
πŸ” Pre-commit inserted-line scan results
---------------------------------------------------------
⚠️  File: src/example.py, Line: 18
    Added line contains pattern: "#[ 	]*.*test"
    β†’ # test
---------------------------------------------------------
⚠️  Total findings: 1
---------------------------------------------------------
```

---

## 🧱 Development

Install dependencies for linting, formatting, and testing:

```bash
pip install -e '.[dev]'
```

Run all development checks:

```bash
make lint
make test
```

Build the distribution:

```bash
make build
```

---

## πŸ§ͺ Testing

```bash
pytest -v --disable-warnings
```

---

## πŸš€ Publishing

```bash
make publish
```

This command builds and uploads the package to PyPI via `twine`.

---

## 🧾 License

MIT License  
Β© 2025 Jaideep Sundaram

---

## 🧠 Notes

- The utility is designed for use with Git repositories that follow a Gitflow workflow.  
- Configuration is fully customizable; extend `.my-pre-commit-checks.yaml` to add your own regexes.  
- Future versions will include additional checks for breakpoints, asserts, sleep statements, and other runtime risks.  

---

### 🧩 Example Workflow

```bash
# Edit a file
echo '# test' >> src/sample.py

# Stage and check
git add src/sample.py
jps-pre-commit-checks
```

If issues are found, they are listed as warnings.  
If none are found, you’ll see:

```bash
βœ… No issues detected. (0 findings)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "jps-pre-commit-utils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "pre-commit, git, lint, static-analysis, utilities",
    "author": "Jaideep Sundaram",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/f8/6e/4c971e2d2438dc5dce67fc8647559c2421a09a87796a5dd21adf625ceedd/jps_pre_commit_utils-1.2.0.tar.gz",
    "platform": null,
    "description": "# jps-pre-commit-utils\n\n![Build](https://github.com/jai-python3/jps-pre-commit-utils/actions/workflows/test.yml/badge.svg)\n![Publish to PyPI](https://github.com/jai-python3/jps-pre-commit-utils/actions/workflows/publish-to-pypi.yml/badge.svg)\n[![codecov](https://codecov.io/gh/jai-python3/jps-pre-commit-utils/branch/main/graph/badge.svg)](https://codecov.io/gh/jai-python3/jps-pre-commit-utils)\n\n\nCustom pre-commit utilities for detecting debug/test leftovers, hardcoded paths, and environment-specific code fragments  \nin Python, Perl, and YAML files before they are committed.  \nThese checks catch issues that are not easily detected by flake8, black, mypy, or bandit.\n\n---\n\n## \ud83e\udde9 Features\n\n\u2705 Scans *staged diffs* (`git diff --cached`) before commit  \n\u2705 Detects newly added lines containing:\n- Debugging and testing statements (e.g., `print`, `sys.exit`, `pdb.set_trace`, `logger.debug`)\n- Hardcoded filesystem paths (e.g., `/mnt/synth-genomics3/...`)\n- Hardcoded environment variables or hostnames\n- Inline comments with \u201ctest\u201d or \u201cTODO\u201d\n\u2705 Supports **Python**, **Perl**, and **YAML** files  \n\u2705 Configurable via `.my-pre-commit-checks.yaml` or `~/.config/my-pre-commit-checks.yaml`  \n\u2705 Integrates easily with manual usage or `.pre-commit-config.yaml`\n\n---\n\n## \ud83e\udde9 Installation\n\n```bash\npip install jps-pre-commit-utils\n```\n\nFor local development:\n\n```bash\ngit clone git@github.com:jai-python3/jps-pre-commit-utils.git\ncd jps-pre-commit-utils\npip install -e '.[dev]'\n```\n\n---\n\n## \ud83e\udde9 Usage\n\nRun manually:\n\n```bash\njps-pre-commit-checks\n```\n\nOr integrate with Git pre-commit:\n\n```bash\n# .git/hooks/pre-commit\n#!/bin/bash\npython3 -m jps_pre_commit_utils.check_inserted_lines\n```\n\n---\n\n## \ud83e\udde9 Example Configuration\n\nConfiguration file:  \n`.my-pre-commit-checks.yaml` *(in repo root)*  \nor  \n`~/.config/my-pre-commit-checks.yaml` *(global fallback)*\n\n```yaml\n# Example configuration for jps-pre-commit-utils\nbase_paths:\n  - /mnt/synth-genomics3\n  - /Users\nignore_patterns:\n  - /mnt/synth-genomics3/bioinfo/shared/\nextra_regexes:\n  - \"jira/[A-Z]+-[0-9]+\"\n```\n\n---\n\n## \ud83e\udde9 Example Output\n\n```bash\n---------------------------------------------------------\n\ud83d\udd27 Performing the following checks:\n---------------------------------------------------------\n\u2022 \ud83d\udc0d Python debug/test statements\n\u2022 \ud83d\udc2a Perl debug/test statements\n\u2022 \ud83d\udcc1 Hardcoded absolute paths\n\u2022 \ud83e\uddea Comments containing 'test' or 'testing'\n---------------------------------------------------------\nScanning inserted lines \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 100% \u2022 45/45\n---------------------------------------------------------\n\ud83d\udd0d Pre-commit inserted-line scan results\n---------------------------------------------------------\n\u26a0\ufe0f  File: src/example.py, Line: 18\n    Added line contains pattern: \"#[ \t]*.*test\"\n    \u2192 # test\n---------------------------------------------------------\n\u26a0\ufe0f  Total findings: 1\n---------------------------------------------------------\n```\n\n---\n\n## \ud83e\uddf1 Development\n\nInstall dependencies for linting, formatting, and testing:\n\n```bash\npip install -e '.[dev]'\n```\n\nRun all development checks:\n\n```bash\nmake lint\nmake test\n```\n\nBuild the distribution:\n\n```bash\nmake build\n```\n\n---\n\n## \ud83e\uddea Testing\n\n```bash\npytest -v --disable-warnings\n```\n\n---\n\n## \ud83d\ude80 Publishing\n\n```bash\nmake publish\n```\n\nThis command builds and uploads the package to PyPI via `twine`.\n\n---\n\n## \ud83e\uddfe License\n\nMIT License  \n\u00a9 2025 Jaideep Sundaram\n\n---\n\n## \ud83e\udde0 Notes\n\n- The utility is designed for use with Git repositories that follow a Gitflow workflow.  \n- Configuration is fully customizable; extend `.my-pre-commit-checks.yaml` to add your own regexes.  \n- Future versions will include additional checks for breakpoints, asserts, sleep statements, and other runtime risks.  \n\n---\n\n### \ud83e\udde9 Example Workflow\n\n```bash\n# Edit a file\necho '# test' >> src/sample.py\n\n# Stage and check\ngit add src/sample.py\njps-pre-commit-checks\n```\n\nIf issues are found, they are listed as warnings.  \nIf none are found, you\u2019ll see:\n\n```bash\n\u2705 No issues detected. (0 findings)\n```\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Custom pre-commit utility for scanning diffs for debug/test patterns, hardcoded paths, and other configurable checks.",
    "version": "1.2.0",
    "project_urls": {
        "Homepage": "https://github.com/jai-python3/jps-pre-commit-utils",
        "Issues": "https://github.com/jai-python3/jps-pre-commit-utils/issues",
        "Repository": "https://github.com/jai-python3/jps-pre-commit-utils"
    },
    "split_keywords": [
        "pre-commit",
        " git",
        " lint",
        " static-analysis",
        " utilities"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "260469f63c1c6e990c4de1f724e986c182a2436716971998e95dcebfa8b65bb8",
                "md5": "6fccd24365de3b507651341222584fd7",
                "sha256": "0c8a5a30c9edcc02e06a84914a8e32d3f371f9080186c07fc22d4b91c0fe8e28"
            },
            "downloads": -1,
            "filename": "jps_pre_commit_utils-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6fccd24365de3b507651341222584fd7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 7225,
            "upload_time": "2025-11-01T16:25:39",
            "upload_time_iso_8601": "2025-11-01T16:25:39.590371Z",
            "url": "https://files.pythonhosted.org/packages/26/04/69f63c1c6e990c4de1f724e986c182a2436716971998e95dcebfa8b65bb8/jps_pre_commit_utils-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f86e4c971e2d2438dc5dce67fc8647559c2421a09a87796a5dd21adf625ceedd",
                "md5": "a1e7d4fccb15db3fe093ada8fd59c0a7",
                "sha256": "0c491d2292d5146a5e9c4ece0ca6e0516acfa3c4ec92a1681f5ee03d52255dad"
            },
            "downloads": -1,
            "filename": "jps_pre_commit_utils-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a1e7d4fccb15db3fe093ada8fd59c0a7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 7458,
            "upload_time": "2025-11-01T16:25:40",
            "upload_time_iso_8601": "2025-11-01T16:25:40.627978Z",
            "url": "https://files.pythonhosted.org/packages/f8/6e/4c971e2d2438dc5dce67fc8647559c2421a09a87796a5dd21adf625ceedd/jps_pre_commit_utils-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-11-01 16:25:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jai-python3",
    "github_project": "jps-pre-commit-utils",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "jps-pre-commit-utils"
}
        
Elapsed time: 0.83376s