- Project Overview
- Features
- Architecture
- Key Components
- Installation
- Usage
- Configuration
- Code Quality Metrics
- Contributing
- License
The Critical SQL Analysis Tool is a sophisticated system designed to analyze and evaluate SQL stored procedures based on various code quality, security, maintenance, optimization, and compliance metrics. This tool aims to improve the overall quality and performance of SQL code by providing detailed insights and recommendations.
# Code Quality Metrics
1. Code Review Compliance: 8
- The stored procedure has undergone basic code review compliance with error handling and validation checks.
- However, a more detailed review could be beneficial to catch potential logic errors or performance bottlenecks.
2. Use of Parameterized Queries: 9
- Parameterized queries are used effectively throughout the stored procedure, reducing the risk of SQL injection attacks.
3. Naming Conventions: 7
- Naming conventions are mostly followed, but some variables and temporary tables could have clearer and more descriptive names for better readability.
{... shortened for readme brevity ...}
- Automated analysis of SQL stored procedures
- Evaluation based on comprehensive metrics
- Detailed reporting on code quality, security, and performance
- Integration with existing development workflows
- Support for large-scale SQL projects
The project follows a modular architecture, leveraging the following key technologies and patterns:
- .NET Core for cross-platform compatibility
- Mediator pattern for decoupling components
- Dependency Injection for managing object lifecycles
- AutoGen for AI-assisted code analysis
- SQL Server for database operations
-
AnalysisAgent: Responsible for analyzing file contents using AI-assisted techniques. It utilizes OpenAI's GPT-3.5 model for advanced code analysis.
-
AgentUtilities: A utility class that provides methods for creating and configuring agents used in the analysis process. It includes methods for creating user agents and analysis agents with specific configurations.
-
DocumentationHandler: Handles the generation of documentation based on analysis results.
-
ProjectFileHandler: Manages the processing of project files.
-
ProjectFileLoader: Loads SQL files from specified project directories.
-
Worker: Background service that orchestrates the analysis process.
-
Clone the repository:
git clone https://github.com/your-username/critical-sql-analysis-tool.git
-
Navigate to the project directory:
cd critical-sql-analysis-tool
-
Restore dependencies:
dotnet restore
-
Build the project:
dotnet build
-
Ensure you have SQL Server installed and accessible.
-
Update the connection string in
appsettings.json
to point to your SQL Server instance. -
Run the application:
dotnet run
-
The tool will automatically scan the specified SQL directories and generate analysis reports.
The tool can be configured through the appsettings.json
file. Key configuration options include:
SqlDirectories
: List of directories containing SQL files to analyzeOutputDirectory
: Directory where analysis reports will be generatedMetricsFile
: Path to the file containing evaluation metricsOpenAIConfig
: Configuration for the OpenAI integration (API key, model, etc.)
By default tool evaluates SQL code based on the following categories of metrics:
This is completely configuration with natural human language
-
Code Quality Metrics
- Code Review Compliance
- Use of Parameterized Queries
- Naming Conventions
- Comment Density
- Modularization
- Error Handling
- Cyclomatic Complexity
- Code Duplication
- Consistent Formatting
- Use of Stored Procedures vs. Inline SQL
-
Security Metrics
- SQL Injection Vulnerabilities
- Principle of Least Privilege Implementation
- Data Encryption at Rest
- Secure Authentication Mechanisms
- Access Control Lists (ACLs) Implementation
- Sensitive Data Masking
- Security Patch Management
-
Maintenance Metrics
- Backup Frequency and Reliability
- Index Fragmentation
- Unused Indexes
- Schema Documentation
- Code Version Control
- Dependency Tracking
- Database Consistency Checks
- Log File Management
-
Optimization Metrics
- Query Complexity
- Data Redundancy
- Consistent Use of Constraints
- Table Partitioning Strategy
- Proper Use of Temporary Tables
- Efficient Use of JOINs
-
Compliance and Best Practices Metrics
- Adherence to Standards
- Documentation Completeness
- Schema Version Control
- Audit Trail Implementation
- Data Retention Policy Compliance
- GDPR Compliance (if applicable)
- Regular Code Reviews
- Use of Database Normalization
- Consistent Naming Conventions across Database Objects
- Implementation of Database Design Patterns
Contributions to the Critical SQL Analysis Tool are welcome! Please follow these steps to contribute:
- Fork the repository
- Create a new branch for your feature or bug fix
- Make your changes and commit them with descriptive commit messages
- Push your changes to your fork
- Submit a pull request to the main repository
Please ensure that your code adheres to the existing coding standards and includes appropriate tests.
This project is licensed under the MIT License. See the LICENSE file for details.