django-code-audit


Namedjango-code-audit JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/ravikempanayaka/Code-Audit#
SummaryA Django app for auditing Python code using pylint
upload_time2025-09-18 12:28:07
maintainerNone
docs_urlNone
authorRavi K
requires_python>=3.8
licenseMIT
keywords django pylint code audit code quality django admin static analysis linting audit python quality
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Django Code Audit

**Django Code Audit** is a reusable Django app that automates Python code quality checks using **Pylint**, stores audit reports in the database, and provides an **admin interface** to view both latest and historical scores.

---

## 🚀 Features

- Run **Pylint** checks on Django apps, modules, or files
- Store audit reports and pylint scores in the database
- View **latest score** and **all past runs** in Django Admin
- Generate HTML reports for detailed review
- Supports project-specific `.pylintrc` configuration
- Easy integration with existing Django projects

---

## ⚡ Installation

1. **Install the package** via pip:

```bash
pip install django-code-audit
```

2. Add the app to **INSTALLED_APPS** in your Django project’s settings.py:
````pythonpython
INSTALLED_APPS = [
    ...
    'code_audit',
    ...
]


CODE_AUDIT = {
    "DEFAULT_PYLINTRC": "/path/to/.pylintrc",
    "BASE_DIR": True,  # enable per-author level reports
}
````
3. Run **migrations** to create necessary database tables:
```bash
python manage.py migrate code_audit
``` 
## 4. Usage Instructions (via **Django Admin**)

Follow these steps to create and run a code audit report efficiently:

### **Step 1: Login**
🔑 Login to your Django Admin dashboard.

### **Step 2: Navigate to Code Audit Reports**
📂 In the admin sidebar, click on **Code Audit Reports**.

### **Step 3: Add a New Report**
➕ Click **Add Code Audit Report**.

### **Step 4: Fill Mandatory Fields**
Fill in the following fields:

- **Module Name** – The Django app or module you want to audit.  
- **File Name** – Python file or app to audit.  
- **Report Path** – Directory where the HTML report will be stored (e.g., `/tmp/`).  

> Make sure all mandatory fields are filled; otherwise, the report cannot be generated.

### **Step 5: Save the Report**
💾 Click **Save** to create the audit report entry.

### **Step 6: Run the Audit**
▶️ After saving, click **Run Report** to generate the code audit using Pylint.

### **Step 7: View the Report**
👀 Once the audit is complete, click **View Report** to open the HTML report in your browser.

### **Step 8: Check Scores**
📊 In the admin interface, you can:
- View the **latest pylint score** for this report.
- Browse **all historical scores** for each run.

## 4.File Author Level Reports
Django Code Audit supports generating per-author reports by filtering files that explicitly declare a maintainer or author inside the file itself.

Author Declaration Format

To be included in an author-specific audit, each file must contain a docstring with one of the following patterns (case-insensitive):
```python:python
"""
current maintainer: ravi
"""

or

"""
current maintainer: ravi
"""
```
The system will scan all .py files in the given app/module and include only those files where the declared author matches the File Author field specified in the report.

### Example

#### chat.py:
```python:python
"""
current maintainer: ravi
"""
def send_message():
    return "ok"
```

#### utils.py:
```python:python
"""
author: john
"""
```
If you create a Code Audit Report with:

File Author = ravi

✅ chat.py will be included in the audit.

❌ utils.py will be excluded.

> **Tip:** You can customize Pylint rules by providing a `.pylintrc` file in your project.


## ## 🛠️ Configuration
You can customize the behavior of Django Code Audit by adding the following settings to your `settings.py`:

By default, the app uses the project’s .pylintrc if available.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ravikempanayaka/Code-Audit#",
    "name": "django-code-audit",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "django, pylint, code audit, code quality, django admin, static analysis, linting, audit, python quality",
    "author": "Ravi K",
    "author_email": "Ravi K <kravi2439@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/84/46/ce8eb6b61f6fb44166fb4d4d7817d38e24fc4b7fa1e17358650115b64054/django_code_audit-0.2.2.tar.gz",
    "platform": null,
    "description": "# Django Code Audit\n\n**Django Code Audit** is a reusable Django app that automates Python code quality checks using **Pylint**, stores audit reports in the database, and provides an **admin interface** to view both latest and historical scores.\n\n---\n\n## \ud83d\ude80 Features\n\n- Run **Pylint** checks on Django apps, modules, or files\n- Store audit reports and pylint scores in the database\n- View **latest score** and **all past runs** in Django Admin\n- Generate HTML reports for detailed review\n- Supports project-specific `.pylintrc` configuration\n- Easy integration with existing Django projects\n\n---\n\n## \u26a1 Installation\n\n1. **Install the package** via pip:\n\n```bash\npip install django-code-audit\n```\n\n2. Add the app to **INSTALLED_APPS** in your Django project\u2019s settings.py:\n````pythonpython\nINSTALLED_APPS = [\n    ...\n    'code_audit',\n    ...\n]\n\n\nCODE_AUDIT = {\n    \"DEFAULT_PYLINTRC\": \"/path/to/.pylintrc\",\n    \"BASE_DIR\": True,  # enable per-author level reports\n}\n````\n3. Run **migrations** to create necessary database tables:\n```bash\npython manage.py migrate code_audit\n``` \n## 4. Usage Instructions (via **Django Admin**)\n\nFollow these steps to create and run a code audit report efficiently:\n\n### **Step 1: Login**\n\ud83d\udd11 Login to your Django Admin dashboard.\n\n### **Step 2: Navigate to Code Audit Reports**\n\ud83d\udcc2 In the admin sidebar, click on **Code Audit Reports**.\n\n### **Step 3: Add a New Report**\n\u2795 Click **Add Code Audit Report**.\n\n### **Step 4: Fill Mandatory Fields**\nFill in the following fields:\n\n- **Module Name** \u2013 The Django app or module you want to audit.  \n- **File Name** \u2013 Python file or app to audit.  \n- **Report Path** \u2013 Directory where the HTML report will be stored (e.g., `/tmp/`).  \n\n> Make sure all mandatory fields are filled; otherwise, the report cannot be generated.\n\n### **Step 5: Save the Report**\n\ud83d\udcbe Click **Save** to create the audit report entry.\n\n### **Step 6: Run the Audit**\n\u25b6\ufe0f After saving, click **Run Report** to generate the code audit using Pylint.\n\n### **Step 7: View the Report**\n\ud83d\udc40 Once the audit is complete, click **View Report** to open the HTML report in your browser.\n\n### **Step 8: Check Scores**\n\ud83d\udcca In the admin interface, you can:\n- View the **latest pylint score** for this report.\n- Browse **all historical scores** for each run.\n\n## 4.File Author Level Reports\nDjango Code Audit supports generating per-author reports by filtering files that explicitly declare a maintainer or author inside the file itself.\n\nAuthor Declaration Format\n\nTo be included in an author-specific audit, each file must contain a docstring with one of the following patterns (case-insensitive):\n```python:python\n\"\"\"\ncurrent maintainer: ravi\n\"\"\"\n\nor\n\n\"\"\"\ncurrent maintainer: ravi\n\"\"\"\n```\nThe system will scan all .py files in the given app/module and include only those files where the declared author matches the File Author field specified in the report.\n\n### Example\n\n#### chat.py:\n```python:python\n\"\"\"\ncurrent maintainer: ravi\n\"\"\"\ndef send_message():\n    return \"ok\"\n```\n\n#### utils.py:\n```python:python\n\"\"\"\nauthor: john\n\"\"\"\n```\nIf you create a Code Audit Report with:\n\nFile Author = ravi\n\n\u2705 chat.py will be included in the audit.\n\n\u274c utils.py will be excluded.\n\n> **Tip:** You can customize Pylint rules by providing a `.pylintrc` file in your project.\n\n\n## ## \ud83d\udee0\ufe0f Configuration\nYou can customize the behavior of Django Code Audit by adding the following settings to your `settings.py`:\n\nBy default, the app uses the project\u2019s .pylintrc if available.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Django app for auditing Python code using pylint",
    "version": "0.2.2",
    "project_urls": {
        "Homepage": "https://github.com/ravikempanayaka/Code-Audit#"
    },
    "split_keywords": [
        "django",
        " pylint",
        " code audit",
        " code quality",
        " django admin",
        " static analysis",
        " linting",
        " audit",
        " python quality"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1f917b33dc7a2d4d0223a38a34ad221116b764dca49ee2153cb3765150756af1",
                "md5": "358f0a88527bfbc4ef3afa11574ceae5",
                "sha256": "816872f7a76634e74e059e9745903cf809d6c7689ea59ff43512a600710560c3"
            },
            "downloads": -1,
            "filename": "django_code_audit-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "358f0a88527bfbc4ef3afa11574ceae5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 23148,
            "upload_time": "2025-09-18T12:28:05",
            "upload_time_iso_8601": "2025-09-18T12:28:05.377369Z",
            "url": "https://files.pythonhosted.org/packages/1f/91/7b33dc7a2d4d0223a38a34ad221116b764dca49ee2153cb3765150756af1/django_code_audit-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8446ce8eb6b61f6fb44166fb4d4d7817d38e24fc4b7fa1e17358650115b64054",
                "md5": "5f707ed2a7bca61afccddf5536ff0302",
                "sha256": "b0d2fbe38c9dce5b104b2a877358307f88985c1b1ccae4946b596fe720b61aac"
            },
            "downloads": -1,
            "filename": "django_code_audit-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "5f707ed2a7bca61afccddf5536ff0302",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 21243,
            "upload_time": "2025-09-18T12:28:07",
            "upload_time_iso_8601": "2025-09-18T12:28:07.063106Z",
            "url": "https://files.pythonhosted.org/packages/84/46/ce8eb6b61f6fb44166fb4d4d7817d38e24fc4b7fa1e17358650115b64054/django_code_audit-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-18 12:28:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ravikempanayaka",
    "github_project": "Code-Audit#",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "django-code-audit"
}
        
Elapsed time: 2.03644s