Skip to content

Latest commit

 

History

History
72 lines (50 loc) · 3.06 KB

File metadata and controls

72 lines (50 loc) · 3.06 KB

Dataspace Ecosystem Code Style Guide

This repository uses a specific code style configuration for the Java programming language. The configuration is based on the Google Java Style Guide, with some modifications to suit our needs. The configuration is defined in an XML file located in the resources directory.

The usage of this code style configuration is enforced through the Checkstyle tool, which can be integrated into your IDE or run as part of the build process.

By using this code style configuration, we aim to maintain a consistent coding style across the project, making it easier for developers to read and understand the code.

Running Java checkstyle

The Checkstyle can be run using Gradle:

./gradlew checkstyleMain checkstyleTest

If any violation is found, this execution will trigger a build failure.

Moreover, if you are using an IDE, you can also run Checkstyle as a plugin. Most IDEs have Checkstyle support available; here are examples for two popular IDEs:

By installing the Checkstyle plugin in your IDE, you can get real-time feedback on your code style violations as you write code. This can help you catch issues early and ensure that your code adheres to the project's coding standards.

After the installation, you can configure the Checkstyle plugin to use the provided XML configuration file. This will ensure that the plugin checks your code against the same rules that are enforced in the CI build process.

Running Terraform checks

If you're working on Terraform files under the system-tests directory, we have validation checks available. You can run them using the following commands:

cd system-tests/
terraform fmt -recursive
terraform init -backend=false -input=false -no-color
terraform validate -no-color

PR checkstyle validation

Besides running Checkstyle locally, we also run it on our GitHub Actions pipeline. This could result in failing GitHub Action pipelines, and reviewers might reject PRs due to Checkstyle violations. Thus, it is highly recommended to run Checkstyle locally as well.

[Optional] Configure code formatting save action in IDE

To ensure that your code is always formatted according to the project's coding style, you can configure your IDE to automatically format your code on save. This can help you avoid Checkstyle violations and maintain a consistent coding style throughout the project. Below are examples for IntelliJ IDEA and VS Code:

IntelliJ IDEA

Intellij Code Save Action

VS Code

In VS Code, you can enable format on save by adding the following to your settings.json:

{
  "editor.formatOnSave": true,
  "[java]": {
    "editor.defaultFormatter": "redhat.java"
  }
}