Read Anthropic’s case study about Graphite Reviewer

An overview of using DeepCode AI for code review

Sara Verdi
Sara Verdi
Graphite software engineer
Try Graphite

DeepCode, developed by Snyk, is a powerful tool for automated code review, emphasizing static application security testing (SAST). This guide explores DeepCode AI's features, its integration into development workflows, and how it complements tools like Graphite Reviewer for enhanced code quality and security.

DeepCode AI uses sophisticated algorithms to analyze your code repositories, and it identifies security vulnerabilities and quality issues by scanning code in real-time. It leverages machine learning models that digest hundreds of thousands of repositories to learn patterns and detect anomalies.

  • Static Application Security Testing (SAST): DeepCode AI excels in SAST by examining static source code to detect flaws that could lead to security vulnerabilities, without running the code.
  • SNYK DeepCode AI features: Integration with Snyk allows DeepCode AI to access a broad database of known security issues, enhancing its scanning capabilities with up-to-date vulnerability data.
  • DeepCode AI code analysis: This process involves parsing the code into an abstract syntax tree (AST), which helps in understanding the code's structure at a granular level, allowing for more precise issue detection.
  1. Security vulnerability detection: Suppose you have a Java application using Spring Framework. DeepCode AI can detect issues like missing CSRF protection or SQL injection vulnerabilities by analyzing the patterns and code structure.

    Terminal
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public void addUser(@RequestParam String username, @RequestParam String password) {
    // Vulnerable to SQL Injection
    jdbcTemplate.execute("INSERT INTO users (username, password) VALUES ('" + username + "', '" + password + "')");
    }

    DeepCode AI would highlight the SQL injection risk in the code snippet above, suggesting parameterized queries or prepared statements as a safer alternative.

  2. Quality checks: For a Python project, DeepCode AI might flag a redundant if-statement that could be simplified, improving code maintainability and readability.

    Terminal
    if condition:
    return True
    else:
    return False

    It would recommend simplifying it to return condition.

Graphite Reviewer enhances the capabilities of DeepCode AI by focusing on codebase-specific feedback and maintaining high coding standards without the noise typical in other tools. It uses a repository-specific AI to understand your team’s coding patterns, providing relevant and actionable feedback.

  • Custom rules and security patterns: While DeepCode AI identifies general security and code quality issues, Graphite Reviewer allows teams to enforce custom rules tailored to their specific codebase needs, such as regex patterns to prevent secrets from being committed.

  • Feedback loop and learning: Graphite Reviewer analyzes historical pull requests using Retrieval-Augmented Generation (RAG) to provide context-aware feedback, enhancing the learning loop where generic tools might lack.

  • Zero setup with immediate feedback: Teams can activate Graphite Reviewer with minimal setup, instantly incorporating AI-driven insights into the review process, making it a seamless addition alongside DeepCode AI.

Here's an example of integrating both tools in your workflow:

  1. Configure DeepCode AI for your repository to scan for vulnerabilities and code quality issues.
  2. Enable Graphite Reviewer on the same repository to review pull requests for custom patterns and provide additional, context-specific feedback.

Using DeepCode AI for static application security testing in tandem with Graphite Reviewer offers a robust solution for maintaining high standards in code security and quality. By leveraging both tools, development teams can ensure a comprehensive review process that minimizes security risks and enhances code consistency across projects.

Built for the world's fastest engineering teams, now available for everyone