Features
Code Scan

Code Scanner

Comprehensive static code analysis to identify potential issues, vulnerabilities, and areas for improvement in your codebase.

Key Features

  1. Static Analysis: The feature performs in-depth analysis of your code to identify potential issues, vulnerabilities, and areas for improvement.

  2. Multi-language Support: Code Scanner can analyze code in various programming languages and frameworks.

  3. Detailed Reporting: Generates comprehensive reports highlighting issues, potential bugs, and suggestions for improvement.

  4. Security Vulnerability Detection: Identifies potential security vulnerabilities in the codebase.

  5. Code Quality Metrics: Provides metrics and insights on code quality and maintainability.

How it Works

  • Input your source code or provide access to your repository.
  • The Code Scanner employs advanced algorithms and AI to analyze the code and generate a detailed report of findings.
  • The scanner identifies potential issues, vulnerabilities, and areas for improvement in your codebase.

Code Scan Analysis Workflow

You can find an example here (opens in a new tab)

Usage Guide

Here's a detailed step-by-step guide on how to use the Code Scanner:

  1. Follow the initial setup guide here.

  2. Create a new Python file and import the necessary modules from Kaizen:

     from kaizen.reviewer.code_scan import CodeScanner
     from kaizen.llms.provider import LLMProvider
     import json
  3. Create an instance of the CodeScanner:

    reviewer = CodeScanner(llm_provider=LLMProvider())
  4. Provide the source code file or directory path which you want to scan:

    You can scan a single file at a time:

     filename = "path/to/your/file.py"
     with open(filename, "r+") as f:
         file_data = f.read()
     review_data = reviewer.review_code(file_data=file_data, user="YourUsername/ProjectName")

    Or a whole directory:

     dir_path = "path/to/your/directory/"
     review_data = reviewer.review_code_dir(
         dir_path=dir_path, reevaluate=True, user="YourUsername/ProjectName"
     )
  5. Display the test results:

     print(f"Total {len(review_data.issues)} Issues found!!!!")
     print(json.dumps(review_data.issues, indent=2))
  6. Review the generated report and address the identified issues in your code.

Example

Here's a complete example to generate unit tests for a specific file:

    from kaizen.reviewer.code_scan import CodeScanner
    from kaizen.llms.provider import LLMProvider
    import json
 
    # Create an instance of the CodeScanner
    reviewer = CodeScanner(llm_provider=LLMProvider())
 
    # Scan a single file
    filename = "github_app/main.py"
    with open(filename, "r+") as f:
        file_data = f.read()
    review_data = reviewer.review_code(file_data=file_data, user="Example/CodeScan")
 
    # Scan a whole directory
    dir_path = "github_app/"
    review_data = reviewer.review_code_dir(
        dir_path=dir_path, reevaluate=True, user="Example/CodeScan"
    )
 
    # Display the results
    print(f"Total {len(review_data.issues)} Issues found!!!!")
    print(json.dumps(review_data.issues, indent=2))

Supported Languages

  • All programming languages

Benefits

  • Early Bug Detection
  • Security Vulnerability Identification
  • Code Quality Improvement
  • Coding Standard Enforcement
  • Technical Debt Reduction

Limitations

  • False Positives: Some identified issues may not be actual problems in certain contexts.
  • Language Coverage: Effectiveness may vary depending on programming language and framework.
  • AI Limitations: May not catch all possible issues or understand complex project-specific requirements.