Comprehensive code quality analyzer untuk ANY Python project dengan Role-Aware Validation
Universal Code Validator adalah tool analisis kode Python yang menggunakan AST (Abstract Syntax Tree) untuk mendeteksi masalah kualitas kode secara mendalam. Yang membuatnya unik adalah kemampuan Role-Aware Validation yang secara otomatis mendeteksi apakah kode Anda adalah SCRIPT, ENGINE, atau FRAMEWORK, lalu menyesuaikan metrik validasi sesuai konteks.
Bekerja di Desktop (Windows/Linux/macOS) dan Android (Pydroid 3/Termux) - No external dependencies!
- Deteksi otomatis peran kode: SCRIPT / ENGINE / FRAMEWORK dengan confidence score
- Adaptive rule weighting - Complexity penalty disesuaikan dengan role:
- SCRIPT: Strict validation (weight 1.0x)
- ENGINE: Balanced approach (weight 0.6-0.7x)
- FRAMEWORK: Lenient on complexity (weight 0.3-0.4x)
- Context-intelligent scoring - Tidak ada false positive pada framework yang kompleks
- Zero penalty untuk kompleksitas yang memang diperlukan (lihat: UNIVERSAL_CODE_VALIDATOR_V3.py detected as FRAMEWORK = no complexity penalty!)
- β Syntax & Parsing - Deteksi error sintaks sebelum runtime
- π Security Vulnerabilities - Context-aware (no false positives dari comments/strings)
exec()detection dengan severity scoring- Command injection patterns
- Path traversal vulnerabilities
- Pickle usage warnings
- π Complexity Metrics - Role-normalized scoring
- Cyclomatic complexity (per function)
- Cognitive complexity (human readability)
- Max nesting depth detection
- β‘ Performance Issues - Deteksi bottleneck potensial
- Inefficient loops
- Repeated operations
- Memory-intensive patterns
- π Code Quality - PEP 8 & best practices
- Function/class length violations
- Parameter count warnings
- Code duplication hints
- π Documentation Coverage - Docstring analysis
- Missing docstrings detection
- Comment ratio calculation
- π« Anti-patterns - Deteksi code smell
- Empty except blocks β (see output: detects all empty excepts!)
- God objects
- Dead code
- π§ Maintainability Index - Halstead metrics calculation
- Cyclomatic Complexity: Independent code paths
- Cognitive Complexity: Mental effort to understand
- Maintainability Index: 0-100 scale (calculated per file)
- Documentation Coverage: Percentage of documented code
- Security Risk Score: Weighted by role
- Role Classification Confidence: 0-100%
- β Zero Dependencies - Pure Python stdlib only
- β Cross-Platform - Windows/Linux/macOS/Android
- β Interactive Mode - Perfect untuk mobile (no CLI args needed)
- β Batch Processing - Analyze multiple files at once
- β Real-time Progress - Streaming output saat analysis
- β Multiple Report Formats - Console + HTML + JSON
# Clone repository
git clone https://github.com/goinboxme/universal-code-validator.git
cd universal-code-validator
# Tidak perlu dependency eksternal - Pure Python!
python UNIVERSAL_CODE_VALIDATOR_V3.py# Di Termux
pkg install python git
git clone https://github.com/goinboxme/universal-code-validator.git
cd universal-code-validator
python UNIVERSAL_CODE_VALIDATOR_V3.py
# Di Pydroid 3
# Download file UNIVERSAL_CODE_VALIDATOR_V3.py
# Buka di Pydroid 3 dan run!# Analyze single file
python UNIVERSAL_CODE_VALIDATOR_V3.py myfile.py
# Analyze entire directory
python UNIVERSAL_CODE_VALIDATOR_V3.py /path/to/project
# Analyze current directory (where the script is located)
python UNIVERSAL_CODE_VALIDATOR_V3.py .# Run tanpa arguments untuk menu interaktif
python UNIVERSAL_CODE_VALIDATOR_V3.py
# Anda akan melihat:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π UNIVERSAL CODE VALIDATOR v3.0.0 π β
β β
β Analyze ANY Python code without prior knowledge β
β Now with ROLE-AWARE VALIDATION - Context-Intelligent! β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Usage options:
1. Analyze single file: python validator.py myfile.py
2. Analyze directory: python validator.py /path/to/project
3. Analyze current dir: python validator.py .
Enter file or directory path (or '.' for current):
# Ketik '.' untuk scan folder saat ini
# Atau ketik nama file: mycode.py
# Atau ketik path lengkap: /sdcard/projects/myapp.pyValidator menghasilkan 3 jenis output:
π Scanning for Python files in: .
π Found 13 Python file(s)
================================================================================
π¬ ANALYZING FILES
================================================================================
[1/13] Analyzing: ENGINEERING_MASTER.py
π― Detected Role: SCRIPT (confidence: 70%)
π 2 HIGH priority issue(s)
π Maintainability: 40.0/100
[2/13] Analyzing: AI_CTE_ASSIST.py
π― Detected Role: SCRIPT (confidence: 70%)
β
No issues found
π Maintainability: 61.0/100
[11/13] Analyzing: UNIVERSAL_CODE_VALIDATOR_V3.py
π― Detected Role: FRAMEWORK (confidence: 100%)
π Maintainability: 39.6/100
================================================================================
π ANALYSIS SUMMARY
================================================================================
π Project: .
π
Timestamp: 2026-02-07T18:59:22
π Validator Version: 3.0.0
π Files Analyzed: 13
π Total Lines: 14,968
π― Role Distribution:
FRAMEWORK: 3 file(s) (23%)
SCRIPT: 10 file(s) (77%)
π― Overall Score: 31.6/100 (Role-Normalized)
π Grade: D - NEEDS IMPROVEMENT
π Issues Found:
Total: 322
π΄ Critical: 2
π High: 18
π Metrics:
Functions: 521
Classes: 108
Avg Complexity: 3.68
Avg Maintainability: 42.7/100
π Security: 11 issue(s)
β‘ Performance: 27 issue(s)
π Complexity: 101 issue(s)
================================================================================
π― ROLE-SPECIFIC INSIGHTS
================================================================================
π MINI_AI_AGENT_V6.py
Role: SCRIPT (confidence: 70%)
Expected Complexity: LOW
Actual Complexity: 44.0
Verdict: ABOVE expected range
Reasoning:
β’ SCRIPT: Linear utility/helper code
β’ Simple structure (45 functions, 4 classes)
β’ LOC: 1281
Issues (role-adjusted): 18
π UNIVERSAL_CODE_VALIDATOR_V3.py
Role: FRAMEWORK (confidence: 100%)
Expected Complexity: HIGH
Actual Complexity: 21.0
Verdict: WITHIN expected range β
Reasoning:
β’ FRAMEWORK: Meta-analyzer/orchestrator pattern detected
β’ Multiple visitor/analyzer patterns detected (11)
β’ Very high max complexity (21)
Issues (role-adjusted): 69
================================================================================
π΄ TOP CRITICAL/HIGH ISSUES
================================================================================
π΄ CRITICAL Security Vulnerability
π MINI_AI_AGENT_V5.py:631
β Using exec() can execute arbitrary code
βοΈ Role-adjusted weight: 0.8x
π‘ Refactor to avoid exec()
π HIGH Anti-pattern
π AI_PATTERN_ANALYZER.py:250
β Empty except block silently ignores errors
π‘ Log the error or handle it appropriately
================================================================================
π‘ RECOMMENDATIONS
================================================================================
π΄ URGENT: Fix critical issues immediately!
π Security: Address 11 security issue(s)
β
Next Steps:
1. Review the HTML report in your browser
2. Check role classifications - are they accurate?
3. Fix critical and high priority issues first
4. Run the validator again to track improvements
================================================================================
β¨ Analysis Complete!
================================================================================
- π Visual dashboard dengan role distribution chart
- π Per-file role analysis dengan confidence score
- π¨ Color-coded issue severity (Critical/High/Medium/Low)
- βοΈ Role-adjusted weight indicators
- π‘ Detailed metrics & actionable suggestions
- π₯οΈ Dapat dibuka di browser desktop atau Android
File generated: code_analysis_YYYYMMDD_HHMMSS.html
{
"project_path": ".",
"timestamp": "2026-02-07T18:59:22",
"validator_version": "3.0.0",
"total_files": 13,
"total_lines": 14968,
"role_distribution": {
"FRAMEWORK": 3,
"SCRIPT": 10
},
"overall_score": 31.6,
"critical_issues": 2,
"high_issues": 18,
"file_analyses": [...]
}File generated: code_analysis_YYYYMMDD_HHMMSS.json
- β Perfect untuk CI/CD integration
- β Easy parsing untuk automated workflows
- β Version control friendly
- Karakteristik: Simple, sequential logic
- Contoh: CLI tools, helper scripts, utilities
- Validasi: Strict pada complexity & maintainability
- Karakteristik: State management, complex algorithms
- Contoh: Data processors, game engines, business logic
- Validasi: Balanced approach, fokus pada security
- Karakteristik: Visitor patterns, high abstraction
- Contoh: Code analyzers, compilers, orchestrators
- Validasi: Lenient pada complexity, strict pada security
- Python 3.7+
- No external dependencies! (Pure Python standard library)
- Platform: Linux, Windows, macOS, Android (Termux/Pydroid 3)
- β Ubuntu 20.04+ / Debian / Fedora
- β Windows 10/11
- β macOS 11+ (Big Sur and later)
- β Android 7+ with Termux
- β Android 7+ with Pydroid 3
# Install Python dan Git
pkg update && pkg upgrade
pkg install python git
# Clone dan run
git clone https://github.com/goinboxme/universal-code-validator.git
cd universal-code-validator
python UNIVERSAL_CODE_VALIDATOR_V3.py .- Download
UNIVERSAL_CODE_VALIDATOR_V3.pydari GitHub - Simpan di folder yang sama dengan kode Anda
- Buka di Pydroid 3
- Tap Run (
βΆοΈ ) - Input: ketik
.untuk scan folder saat ini
# Current directory (recommended)
.
# Specific file in same folder
mycode.py
# Internal storage
/sdcard/projects/myapp.py
# Termux home
/data/data/com.termux/files/home/projects/
# Pydroid 3 directory
/storage/emulated/0/Pydroid/# Setelah analysis selesai:
# File: code_analysis_YYYYMMDD_HHMMSS.html
# Cara 1: File Manager
# Buka dengan Chrome/Firefox/browser apapun
# Cara 2: Termux (with termux-open)
pkg install termux-tools
termux-open code_analysis_*.html
# Cara 3: Share file HTML ke desktop via:
# - Google Drive / Dropbox
# - Email attachment
# - USB transferEdit THRESHOLDS dan ROLE_WEIGHTS di dalam script untuk menyesuaikan:
THRESHOLDS = {
'max_function_length': 50,
'max_class_length': 300,
'max_cyclomatic_complexity': 10,
'max_cognitive_complexity': 15,
'max_nesting_depth': 4,
'max_parameters': 5,
'min_maintainability_index': 20,
'min_comment_ratio': 0.10,
'min_docstring_coverage': 0.50,
}# Di Termux atau Pydroid 3
python UNIVERSAL_CODE_VALIDATOR_V3.py .
# Perfect untuk:
# - Learning Python on the go
# - Quick code quality checks
# - Coding practice validation
# - Portfolio project assessment# .git/hooks/pre-commit
#!/bin/bash
python UNIVERSAL_CODE_VALIDATOR_V3.py . --json-only
if [ $? -ne 0 ]; then
echo "Code quality check failed!"
exit 1
fi# .github/workflows/code-quality.yml
- name: Code Quality Check
run: |
python UNIVERSAL_CODE_VALIDATOR_V3.py . --json-only# Desktop: Review specific files
git diff --name-only main | grep '\.py$' | xargs python UNIVERSAL_CODE_VALIDATOR_V3.py
# Android: Quick check before committing
python UNIVERSAL_CODE_VALIDATOR_V3.py mychanged_file.py# Perfect untuk mahasiswa/pelajar yang coding di Android
# - Check homework assignments
# - Validate practice exercises
# - Learn best practices
# - Prepare for code reviewsContributions are welcome! Silakan:
- Fork repository ini
- Buat feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add some AmazingFeature') - Push ke branch (
git push origin feature/AmazingFeature) - Buka Pull Request
- β¨ NEW: Role-Aware Validation system
- β¨ NEW: Adaptive rule weighting
- β¨ NEW: Context-intelligent scoring
- π Fixed: Zero false positives on framework complexity
- β¨ Context-aware security scanning (AST-based)
- π Eliminated false positives from strings/comments
- π Duplicate issue detection prevention
- Complete rewrite with AST-based analysis
- Added multiple report formats
- Enhanced metric calculations
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by tools like pylint, flake8, and radon
- Built with Python's powerful
astmodule - Thanks to the open-source community
- Author: [goinboxme]
- Email: inbox.globaltrade@gmail.com
- GitHub: @goinboxme
If you find this project useful, please consider giving it a star!
A: Ya! 100% compatible dengan Termux dan Pydroid 3. Tidak perlu root atau dependencies eksternal.
A: Tidak sama sekali. Pure Python standard library - langsung run!
A:
- β Role-aware validation (unique feature!)
- β Zero dependencies vs puluhan dependencies
- β Cross-platform termasuk Android
- β Context-intelligent scoring
- β Interactive mode untuk mobile
A: Bisa! Gunakan file manager, pilih file HTML, buka dengan Chrome/Firefox. Atau gunakan termux-open di Termux.
A: Check "Role Classification" - jika salah deteksi (misal: ENGINE detected as SCRIPT), complexity penalty jadi terlalu tinggi. Ini normal untuk code yang memang complex by design.
A: Ini multiplier yang diterapkan ke severity issue berdasarkan role:
- SCRIPT: 1.0x (full penalty)
- ENGINE: 0.6-0.7x (reduced penalty)
- FRAMEWORK: 0.3-0.5x (minimal penalty)
A: Ya, tapi butuh waktu. Untuk project besar, consider analyze per module/package.
A: Untuk:
- CI/CD automation
- Trend tracking (compare JSON across commits)
- Custom dashboard integration
- Automated quality gates
A:
- 100% = Pasti (detected visitor pattern, high complexity)
- 70% = Probably (default untuk simple scripts)
- Lower confidence = might need manual review
Made with β€οΈ and Python - Runs Everywhere!


