Codemood
Advanced code analysis platform that combines AI sentiment analysis with comprehensive code quality assessment and custom model training.
Codemood provides multi-dimensional code analysis including mood detection, security vulnerability scanning, performance bottleneck identification, optimization suggestions, and code quality metrics. Features custom model training pipeline and automatic fallback systems. Built for developers who want actionable insights into their codebase.
Key Features
🧠 Advanced Sentiment Analysis
- 12 feature categories: Elegant patterns, documentation, type hints, code smells
- AST-based analysis for Python structure understanding
- Emotional tone detection: 7 distinct emotional states from "Delighted" to "Distressed"
- Custom model training: Train your own models with provided pipeline
- Automatic fallback: Rule-based → Custom model → Hugging Face API
🔧 Optimization Engine
- 6 optimization categories: Nested loops, string concatenation, linear searches
- Specific fix suggestions: Working code examples for each issue
- Impact assessment: High/Medium/Low priority classification
- Performance improvements: O(n²) → O(n) optimizations
🔒 Security Analysis
- 5 vulnerability types: SQL injection, hardcoded secrets, shell injection
- Severity classification: Critical, High, Medium, Low
- Line-by-line detection with remediation suggestions
📊 Comprehensive Scoring
- Multi-layered analysis: Sentiment + Security + Performance + Quality
- Confidence scoring with reasoning explanations
- Weighted metrics: Balanced assessment across all dimensions
Installation
pip install codemood
Quick Start
Advanced Sentiment Analysis
from codemood import analyze_sentiment_advanced
code = '''
def fibonacci_generator(n: int):
"""Generate fibonacci sequence up to n terms."""
a, b = 0, 1
for _ in range(n):
yield a
a, b = b, a + b
'''
sentiment = analyze_sentiment_advanced(code)
print(f"Overall Score: {sentiment.overall_score:.2f}")
print(f"Emotional Tone: {sentiment.emotional_tone}")
print(f"Confidence: {sentiment.confidence:.2f}")
# Output: Score: 7.20, Tone: Delighted - This code sparks joy!
Optimization Suggestions
from codemood import get_optimization_suggestions
problematic_code = '''
result = []
for i in range(len(items)):
for j in range(len(items)): # Nested loops - O(n²)
if items[i] == items[j]:
result.append(items[i])
'''
suggestions = get_optimization_suggestions(problematic_code)
for suggestion in suggestions:
print(f"Issue: {suggestion.issue_type}")
print(f"Fix: {suggestion.suggested_fix}")
print(f"Impact: {suggestion.impact}")
# Output: Issue: nested_loops, Fix: Use set operations, Impact: High
Custom Model Training
# Train your own sentiment model
cd model_training
python model_trainer.py
# Model automatically integrates with codemood
from codemood import analyze_sentiment_advanced
result = analyze_sentiment_advanced(code) # Uses your custom model + rules
Advanced Usage
Individual Analyzers
from codemood import (
AdvancedCodeAnalyzer,
SecurityAnalyzer,
PerformanceAnalyzer
)
# Specialized analysis
security = SecurityAnalyzer()
issues = security.analyze(code)
performance = PerformanceAnalyzer()
bottlenecks = performance.analyze(code)
advanced = AdvancedCodeAnalyzer()
mood_result = advanced.analyze(code)
Custom Model Configuration
from codemood import CodeMoodAnalyzer
# Use custom Hugging Face model
analyzer = CodeMoodAnalyzer(model="your-custom-model")
result = analyzer.analyze(code)
Configuration
Hugging Face Integration
Codemood works offline by default. For cloud inference:
export HF_TOKEN="your_hugging_face_token"
Language Support
- Python: Full AST analysis with comprehensive metrics
- Other languages: Pattern-based analysis with generic scoring
API Reference
Core Functions
analyze_sentiment_advanced(snippet)- Advanced sentiment with emotional toneget_optimization_suggestions(snippet)- Specific code improvementsanalyze_comprehensive(snippet, language)- Full analysis suiteanalyze_code(snippet, model)- Basic Hugging Face sentimentreset_analyzers()- Clear cached models
Analysis Results
@dataclass
class ComprehensiveAnalysis:
mood_analysis: AdvancedMoodResult
security_issues: List[SecurityIssue]
performance_issues: List[PerformanceIssue]
security_score: float
performance_score: float
overall_score: float
sentiment: Dict[str, Any]
summary: str
Use Cases
- Code Reviews: Automated sentiment analysis with optimization suggestions
- Developer Education: Learn from emotional feedback and specific improvements
- Performance Optimization: Identify and fix O(n²) algorithms with examples
- Custom Model Training: Build domain-specific code quality models
- CI/CD Integration: Quality gates with detailed explanations
- Security Audits: Vulnerability detection with remediation guidance
- Technical Debt Analysis: Emotional understanding of code quality issues
Contributing
Contributions welcome! Please read our contributing guidelines and submit pull requests for improvements.
License
MIT License - see LICENSE file for details.
Roadmap
v0.3.0 - Language Expansion
- JavaScript/TypeScript AST support
- Java bytecode analysis
- Go static analysis
v0.4.0 - Advanced Features
- Machine learning-based quality prediction
- Real-time code analysis
- Custom rule definitions
v1.0.0 - Production Ready
- IDE plugins (VS Code, IntelliJ)
- Team analytics dashboard
- Enterprise integrations
- Performance benchmarking
Metadata
Release files for codemood 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| codemood-0.2.0.tar.gz | 27.7 kB | Without provenance | Details for codemood-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| codemood-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for codemood-0.2.0-py3-none-any.whl |
Total release size: 58.9 kB
Release files / codemood-0.2.0.tar.gz
| Download URL | codemood-0.2.0.tar.gz |
|---|---|
| Size | 27.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
914920f42e6621929679180f373469b8d45cd007bb2f52cc364f11d33a02f533
|
|
BLAKE2b-256 checksum How to use checksums |
4e55db74d1aba68fa132a7fb85cbea359f05de63d2cd504305b6359837a29c38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / codemood-0.2.0-py3-none-any.whl
| Download URL | codemood-0.2.0-py3-none-any.whl |
|---|---|
| Size | 31.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e9e0a8d233f2e38253f5e31dfc03c34e20ffd257fac94da107ba4ef1a42ffe7
|
|
BLAKE2b-256 checksum How to use checksums |
7981cccb5f025af9e541ac83f706923d2b04da30af22665d750ebf2788e198cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for codemood 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.