Attoflow Risk Assessment VS Code Extension
A VS Code extension that provides real-time code risk assessment for Python, JavaScript, and TypeScript files using machine learning models.
Features
- Real-time code analysis
- Support for multiple languages:
- Python
- JavaScript
- TypeScript
- Risk level assessment (Low, Medium, High)
- Detailed recommendations for code improvement
- Visual indicators in the status bar
- Inline diagnostics for high-risk code
Requirements
- Python 3.8 or higher
- VS Code 1.60.0 or higher
- Required Python packages (installed automatically):
- numpy
- scikit-learn
- joblib
- pandas
- xgboost
- imbalanced-learn
- esprima (for JavaScript/TypeScript parsing)
Installation
- Install the extension from the VS Code marketplace
- Install Python dependencies:
pip install -r requirements.txt
- Restart VS Code
Usage
The extension automatically analyzes Python, JavaScript, and TypeScript files as you type. You can also manually trigger analysis:
- Open a supported file
- Press
Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac)
- Type "Analyze Code Risk" and select the command
Status Bar Indicators
- 🟢 Low Risk
- 🟡 Medium Risk
- 🔴 High Risk
Configuration
The extension can be configured in VS Code settings:
attoflowRiskAssessment.enable : Enable/disable real-time analysis
attoflowRiskAssessment.updateInterval : Analysis update interval in milliseconds
attoflowRiskAssessment.languages : List of languages to analyze (default: ["python", "javascript", "typescript"])
How It Works
The extension extracts features from your code:
- Code complexity
- Lines of code
- Comment ratio
- Nesting depth
- Variable count
- Function count
- Class count
- Import count
- Exception count
- Loop count
These features are analyzed by multiple ML models:
- Random Forest
- SVM
- XGBoost
The models' predictions are combined to provide:
- Overall risk level
- Probability of defects
- Language-specific recommendations
Language-Specific Features
Python
- AST-based analysis
- Python-specific complexity metrics
- PEP 8 style recommendations
JavaScript/TypeScript
- Esprima-based parsing
- Modern JS/TS features support
- Recommendations for:
- Object destructuring
- Array methods
- Higher-order functions
- Async/await patterns
Development
Building from Source
- Clone the repository
- Install dependencies:
npm install
pip install -r requirements.txt
- Build the extension:
npm run compile
Running Tests
python -m unittest discover tests
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
License
MIT
| |