Cognito is an interactive AI assistant that provides code review insights one suggestion at a time. It initially supports Python and C, with plans to add more languages. By leveraging ML/NLP, Cognito aims to enhance code quality by:
- Improving readability
- Ensuring security (aligned with OWASP guidelines)
- Optimizing code performance
- Code Readability Analysis
- Checks for naming conventions, comments, and code structure.
- Suggests refactoring for clearer and more maintainable code.
- Security Vulnerability Detection
- Detects common security issues and flags vulnerabilities according to OWASP standards.
- Highlights risky functions and suggests safer alternatives.
- Performance Analysis
- Analyzes algorithmic complexity and memory usage.
- Flags inefficient patterns and recommends optimizations.
- Interactive Suggestions
- Provides one suggestion at a time, allowing users to review, accept, or dismiss.
- Offers optional explanations for each suggestion if requested.
# Clone the repository
git clone https://github.com/Klus3kk/cognito.git
# Navigate to repository
cd cognito
# Install the package from the local directory
pip install -e .
# Set up Hugging Face token for ML features (required)
# Create an account at huggingface.co and generate a token
export HUGGINGFACE_TOKEN="your_token_here"
After installation, you can run Cognito using the command-line interface:
# Simply run the command
cognito
-
When you start Cognito, you'll see a menu with options to:
- Enter code directly
- Load code from a file
- Exit the program
-
After entering or loading code, Cognito will:
- Automatically detect the programming language
- Analyze the code for readability issues using ML models
- Check for performance bottlenecks and complexity issues
- Scan for potential security vulnerabilities
- Display the results with color-coded feedback
-
You can then save the analysis results to a file for future reference.
Cognito automatically identifies whether you're working with Python or C code, allowing for language-specific analysis without manual configuration.
Using the CodeBERT model from Hugging Face, Cognito provides intelligent code readability assessment that goes beyond simple rule-based checking.
The security analyzer identifies potential vulnerabilities based on OWASP guidelines, including:
- Injection vulnerabilities
- Insecure function usage
- Hardcoded credentials
- Path traversal risks
The performance analyzer evaluates code efficiency by examining:
- Algorithmic complexity
- Nested loop structures
- Memory usage patterns
- Recursive function safety
The color-coded terminal interface makes it easy to:
- Identify critical issues (marked in red)
- Celebrate good practices (marked in green)
- Save comprehensive reports for future reference
Work's in REALLY REALLY EARLY process, but the core functionality is operational. Future development will focus on expanding language support, improving ML model accuracy, and adding IDE integrations.