Skip to content

Commit

Permalink
Add checkstyle (michelin#327)
Browse files Browse the repository at this point in the history
* Add checkstyle

* fix sonar
  • Loading branch information
Loïc GREFFIER authored Oct 2, 2023
1 parent 729e865 commit dcbe6ce
Show file tree
Hide file tree
Showing 188 changed files with 15,146 additions and 13,678 deletions.
382 changes: 382 additions & 0 deletions .checkstyle/checkstyle.xml

Large diffs are not rendered by default.

75 changes: 39 additions & 36 deletions .github/workflows/on_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,42 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build jacocoTestReport sonar --info

- name: Publish test report
if: always()
uses: mikepenz/action-junit-report@v4
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

- name: Check Style
run: ./gradlew checkstyleMain checkstyleTest

- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build jacocoTestReport sonar --info

- name: Publish test report
if: always()
uses: mikepenz/action-junit-report@v4
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
3 changes: 3 additions & 0 deletions .github/workflows/on_push_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

- name: Check Style
run: ./gradlew checkstyleMain checkstyleTest

- name: Build and analyze
id: build_jar
env:
Expand Down
51 changes: 36 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,43 @@

Welcome and thank you for considering contributing to Ns4kafka!

By following these guidelines, you can help make the contribution process easy and effective for everyone involved. It also shows that you agree to respect the time of the developers managing and developing these open source projects. In return, we will reciprocate that respect by addressing your issue, assessing changes, and helping you finalize your pull requests.
By following these guidelines, you can help make the contribution process easy and effective for everyone involved. It
also shows that you agree to respect the time of the developers managing and developing these open source projects. In
return, we will reciprocate that respect by addressing your issue, assessing changes, and helping you finalize your pull
requests.

## Getting Started

### Issues

Issues should be used to report problems, request a new feature, or to discuss potential changes before a PR is created. When you create a new Issue, a template will be loaded that will guide you through collecting and providing the information we need to investigate.
Issues should be used to report problems, request a new feature, or to discuss potential changes before a PR is created.
When you create a new Issue, a template will be loaded that will guide you through collecting and providing the
information we need to investigate.

If you find an existing issue that addresses the problem you're having, please add your own reproduction information to the existing issue instead of creating a new one. Adding a [reaction](https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) can also indicate to our maintainers that a particular problem is affecting more than just the reporter.
If you find an existing issue that addresses the problem you're having, please add your own reproduction information to
the existing issue instead of creating a new one. Adding
a [reaction](https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) can also indicate to
our maintainers that a particular problem is affecting more than just the reporter.

If you're unable to find an open issue addressing the problem, open a new one. Be sure to include a title and a clear description, relevant information, and a code sample or executable test case demonstrating the expected behavior that is not occurring.
If you're unable to find an open issue addressing the problem, open a new one. Be sure to include a title and a clear
description, relevant information, and a code sample or executable test case demonstrating the expected behavior that is
not occurring.

### Pull Requests

PRs are always welcome and can be a quick way to get your fix or improvement slated for the next release. In general, PRs should:
PRs are always welcome and can be a quick way to get your fix or improvement slated for the next release. In general,
PRs should:

- Only fix/add the functionality in question OR address wide-spread style issues, not both.
- Add unit or integration tests for fixed or changed functionality (if a test suite already exists).
- Address a single concern in the least number of changed lines as possible.
- Be accompanied by a complete Pull Request template (loaded automatically when a PR is created).

Be sure to use the past tense ("Added new feature...", "Fixed bug on...") and add tags to the PR ("documentation" for documentation updates, "bug" for bug fixing, etc.).
Be sure to use the past tense ("Added new feature...", "Fixed bug on...") and add tags to the PR ("documentation" for
documentation updates, "bug" for bug fixing, etc.).

For changes that address core functionality or would require breaking changes (e.g. a major release), it's best to open an Issue to discuss your proposal first. This is not required but can save time creating and reviewing changes.
For changes that address core functionality or would require breaking changes (e.g. a major release), it's best to open
an Issue to discuss your proposal first. This is not required but can save time creating and reviewing changes.

In general, we follow the ["fork-and-pull" Git workflow](https://github.com/susam/gitpr)

Expand All @@ -37,14 +50,22 @@ In general, we follow the ["fork-and-pull" Git workflow](https://github.com/susa
- Push changes to your fork
- Open a PR in our repository targeting master and follow the PR template so that we can efficiently review the changes.

## Styleguides
## Style Guide

### Git Commit Messages
### Code Style

When contributing to the project, it's important to follow a consistent style for Git commit messages. Here are some guidelines to keep in mind:
We maintain a consistent code style using [Checkstyle](https://checkstyle.sourceforge.io/).

- Use the present tense, such as "Add feature," rather than the past tense, such as "Added feature."
- Use the imperative mood, such as "Move cursor to..." rather than "Moves cursor to..."
- Limit the first line of the commit message to 72 characters or less.
- Use references to issues and pull requests after the first line as needed.
- If your commit only changes documentation, include `[ci skip]` in the commit title.
The configuration file is defined in the `.checkstyle` folder.
To perform Checkstyle validation, run the following:

```bash
./gradlew checkstyleMain checkstyleTest
```

Before you start contributing new code, it is recommended to:

- Install the IntelliJ [CheckStyle-IDEA](https://plugins.jetbrains.com/plugin/1065-checkstyle-idea) plugin.
- Configure the plugin to use Ns4Kafka's Checkstyle configuration file.

Adhering to this code style ensures consistency and helps maintain code quality throughout the project.
Loading

0 comments on commit dcbe6ce

Please sign in to comment.