Code Style Guide
This document provides the coding style guidelines for GraphScope’s codebase, which includes C++, Python, Rust, Java, and shell scripts. Adhering to consistent coding standards across the codebase promotes maintainability, readability, and code quality.
C++ Style
We follow the Google C++ Style Guide for coding standards in C++.
Python Style
We follow the black code style for Python coding standards.
Java Style
Java code in NeuG follows Google Java Style ,
enforced by the Maven Spotless plugin (with google-java-format).
Java source is located at tools/java_driver.
Style Linter and Checker
GraphScope uses different linters and checkers for each language to enforce code style rules:
- C++: clang-format-8 and cpplint
- Python: Flake8
- Java: Spotless Maven Plugin
Each linter can be included in the build process to ensure that the code adheres to the style guide. Below are the commands to check the code style in each language:
For C++, format and lint the code by the MakeFile command:
# format
$ make neug_clformatFor Python:
- Install dependencies first:
$ pushd tools/python_bind
$ python3 -m pip install -r requirements_dev.txt
$ popd- Check the style:
$ pushd tools/python_bind
$ python3 -m isort --check --diff .
$ python3 -m black --check --diff .
$ python3 -m flake8 .
$ popd
$ pushd tools/shell
$ python3 -m isort --check --diff .
$ python3 -m black --check --diff .
$ python3 -m flake8 .
$ popdFor Java:
- Check style only:
$ pushd tools/java_driver
$ mvn spotless:check
$ popd- Auto-format Java files:
$ pushd tools/java_driver
$ mvn spotless:apply
$ popd