From ad0f02cfa9805e9df0e0aa78fd25f37f564b9b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=ABsFot?= Date: Wed, 18 Nov 2020 00:50:27 +0100 Subject: [PATCH 01/10] Add checkstyle gradle plugin --- build.gradle | 7 +- minestom_checks.xml | 303 ++++++++++++++++++ .../net/minestom/server/entity/Player.java | 5 +- 3 files changed, 310 insertions(+), 5 deletions(-) create mode 100644 minestom_checks.xml diff --git a/build.gradle b/build.gradle index ab464fc91..ab70c7eb5 100644 --- a/build.gradle +++ b/build.gradle @@ -6,6 +6,7 @@ plugins { id 'maven-publish' id 'net.ltgt.apt' version '0.10' id 'org.jetbrains.kotlin.jvm' version '1.4.10' + id 'checkstyle' } group 'net.minestom.server' @@ -36,7 +37,7 @@ allprojects { maven { url 'https://jitpack.io' } maven { name 'sponge' - url 'http://repo.spongepowered.org/maven' + url 'https://repo.spongepowered.org/maven' } } javadoc { @@ -72,6 +73,10 @@ sourceSets { } } +tasks.withType(Checkstyle) { + configFile file("${projectDir}/minestom_checks.xml") +} + java { // Minestom uses LWJGL libs as optional dependency if interfacing with a GPU is asked registerFeature("lwjgl") { diff --git a/minestom_checks.xml b/minestom_checks.xml new file mode 100644 index 000000000..142f6229b --- /dev/null +++ b/minestom_checks.xml @@ -0,0 +1,303 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/net/minestom/server/entity/Player.java b/src/main/java/net/minestom/server/entity/Player.java index 31764aa27..682aa9508 100644 --- a/src/main/java/net/minestom/server/entity/Player.java +++ b/src/main/java/net/minestom/server/entity/Player.java @@ -70,7 +70,6 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; - /** * Those are the major actors of the server, * they are not necessary backed by a {@link NettyPlayerConnection} as shown by {@link FakePlayer} @@ -119,7 +118,6 @@ public class Player extends LivingEntity implements CommandSender { private long defaultEatingTime = 1000L; private long eatingTime; private boolean isEating; - // Game state (https://wiki.vg/Protocol#Change_Game_State) private boolean enableRespawnScreen; @@ -1119,8 +1117,7 @@ public class Player extends LivingEntity implements CommandSender { /** * Gets the player display name in the tab-list. * - * @return the player display name, - * null means that {@link #getUsername()} is displayed + * @return the player display name, null means that {@link #getUsername()} is displayed */ @Nullable public ColoredText getDisplayName() { From d968946c4495c12e7a062b4fb4cc02e05b20064e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=ABsFot?= Date: Wed, 18 Nov 2020 00:52:33 +0100 Subject: [PATCH 02/10] Restore deleted empty lines --- src/main/java/net/minestom/server/entity/Player.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/net/minestom/server/entity/Player.java b/src/main/java/net/minestom/server/entity/Player.java index 682aa9508..ef8f3365e 100644 --- a/src/main/java/net/minestom/server/entity/Player.java +++ b/src/main/java/net/minestom/server/entity/Player.java @@ -70,6 +70,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; + /** * Those are the major actors of the server, * they are not necessary backed by a {@link NettyPlayerConnection} as shown by {@link FakePlayer} @@ -118,6 +119,7 @@ public class Player extends LivingEntity implements CommandSender { private long defaultEatingTime = 1000L; private long eatingTime; private boolean isEating; + // Game state (https://wiki.vg/Protocol#Change_Game_State) private boolean enableRespawnScreen; From b5793270d6572a0249c86d8e9053b5dad12834fd Mon Sep 17 00:00:00 2001 From: JesFot Date: Wed, 18 Nov 2020 01:05:15 +0100 Subject: [PATCH 03/10] Add Github action for checking pr code style --- .github/workflows/check-pr-style.yml | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/check-pr-style.yml diff --git a/.github/workflows/check-pr-style.yml b/.github/workflows/check-pr-style.yml new file mode 100644 index 000000000..2f1e35259 --- /dev/null +++ b/.github/workflows/check-pr-style.yml @@ -0,0 +1,30 @@ +name: Check PR code style + +on: + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 1.11 + - name: Run java checkstyle + uses: nikitasavinov/checkstyle-action@0.3.1 + with: + # Report level for reviewdog [info,warning,error] + level: info + # Reporter of reviewdog command [github-pr-check,github-pr-review] + reporter: github-pr-check + # Filtering for the reviewdog command [added,diff_context,file,nofilter]. + filter_mode: added + # Exit code for reviewdog when errors are found [true,false]. + fail_on_error: false + # Checkstyle config file + checkstyle_config: minestom_checks.xml From 980178b02581d8f7c109b681adf9bd008add379f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=ABsFot?= Date: Wed, 18 Nov 2020 02:52:36 +0100 Subject: [PATCH 04/10] Remove style check for inline '

' --- minestom_checks.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/minestom_checks.xml b/minestom_checks.xml index 142f6229b..674c3996f 100644 --- a/minestom_checks.xml +++ b/minestom_checks.xml @@ -268,7 +268,9 @@ - + + + Date: Thu, 19 Nov 2020 15:48:11 +0100 Subject: [PATCH 05/10] Use compatible config file until actions is updated --- .github/workflows/check-pr-style.yml | 2 +- minestom_checks_8.36.xml | 303 +++++++++++++++++++++++++++ 2 files changed, 304 insertions(+), 1 deletion(-) create mode 100644 minestom_checks_8.36.xml diff --git a/.github/workflows/check-pr-style.yml b/.github/workflows/check-pr-style.yml index 2f1e35259..ed1dcbae0 100644 --- a/.github/workflows/check-pr-style.yml +++ b/.github/workflows/check-pr-style.yml @@ -27,4 +27,4 @@ jobs: # Exit code for reviewdog when errors are found [true,false]. fail_on_error: false # Checkstyle config file - checkstyle_config: minestom_checks.xml + checkstyle_config: minestom_checks_8.36.xml diff --git a/minestom_checks_8.36.xml b/minestom_checks_8.36.xml new file mode 100644 index 000000000..eb513ae72 --- /dev/null +++ b/minestom_checks_8.36.xml @@ -0,0 +1,303 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 4b07deae27dc321fd52f436e072441a30255555f Mon Sep 17 00:00:00 2001 From: JesFot Date: Thu, 19 Nov 2020 16:47:16 +0100 Subject: [PATCH 06/10] Use last commit of checkstyle-action --- .github/workflows/check-pr-style.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-pr-style.yml b/.github/workflows/check-pr-style.yml index ed1dcbae0..f13f760b5 100644 --- a/.github/workflows/check-pr-style.yml +++ b/.github/workflows/check-pr-style.yml @@ -16,7 +16,7 @@ jobs: with: java-version: 1.11 - name: Run java checkstyle - uses: nikitasavinov/checkstyle-action@0.3.1 + uses: nikitasavinov/checkstyle-action@61104b8abd3ea7fb471f9b991e5ed71c20a4c9f7 with: # Report level for reviewdog [info,warning,error] level: info From d138acceb1c8dfdfd6361a84841899da40314dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=ABsFot?= Date: Fri, 20 Nov 2020 01:30:01 +0100 Subject: [PATCH 07/10] Fix gradle checktyle version --- build.gradle | 9 +- minestom_checks.xml | 2 - minestom_checks_8.36.xml | 303 --------------------------------------- 3 files changed, 5 insertions(+), 309 deletions(-) delete mode 100644 minestom_checks_8.36.xml diff --git a/build.gradle b/build.gradle index ab70c7eb5..f3c77a35c 100644 --- a/build.gradle +++ b/build.gradle @@ -46,6 +46,11 @@ allprojects { addBooleanOption('html5', true) } } + + checkstyle { + toolVersion "8.37" + configFile file("${projectDir}/minestom_checks.xml") + } } sourceSets { @@ -73,10 +78,6 @@ sourceSets { } } -tasks.withType(Checkstyle) { - configFile file("${projectDir}/minestom_checks.xml") -} - java { // Minestom uses LWJGL libs as optional dependency if interfacing with a GPU is asked registerFeature("lwjgl") { diff --git a/minestom_checks.xml b/minestom_checks.xml index 674c3996f..eb513ae72 100644 --- a/minestom_checks.xml +++ b/minestom_checks.xml @@ -279,10 +279,8 @@ - - diff --git a/minestom_checks_8.36.xml b/minestom_checks_8.36.xml deleted file mode 100644 index eb513ae72..000000000 --- a/minestom_checks_8.36.xml +++ /dev/null @@ -1,303 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 5fdd62fb58462ee3e24301d7097d10fe65b9860d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=ABsFot?= Date: Fri, 20 Nov 2020 01:33:43 +0100 Subject: [PATCH 08/10] Use last version of checkstyle in github action --- .github/workflows/check-pr-style.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-pr-style.yml b/.github/workflows/check-pr-style.yml index f13f760b5..7ac69d24b 100644 --- a/.github/workflows/check-pr-style.yml +++ b/.github/workflows/check-pr-style.yml @@ -16,7 +16,7 @@ jobs: with: java-version: 1.11 - name: Run java checkstyle - uses: nikitasavinov/checkstyle-action@61104b8abd3ea7fb471f9b991e5ed71c20a4c9f7 + uses: nikitasavinov/checkstyle-action@d87d526a914fc5cb0b003908e35038dbb2d6e1b7 with: # Report level for reviewdog [info,warning,error] level: info @@ -27,4 +27,5 @@ jobs: # Exit code for reviewdog when errors are found [true,false]. fail_on_error: false # Checkstyle config file - checkstyle_config: minestom_checks_8.36.xml + checkstyle_config: minestom_checks.xml + checkstyle_version: "8.37" From 8accc82e2b55628e4b8c2814afbd343b559bdbf0 Mon Sep 17 00:00:00 2001 From: JesFot Date: Fri, 20 Nov 2020 02:11:22 +0100 Subject: [PATCH 09/10] Restore gradle test command --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6d233db27..12fd62a60 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,5 +21,5 @@ jobs: run: chmod +x gradlew - name: Build Minestom run: ./gradlew build - - name: Run tests + - name: Run Minestom tests run: ./gradlew test From c3b693d7b9e23ae45898c888e6e758fdf275ed62 Mon Sep 17 00:00:00 2001 From: JesFot Date: Fri, 20 Nov 2020 02:20:59 +0100 Subject: [PATCH 10/10] Only compile classes for tests --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ce338e019..c6d8bda7c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,6 +30,6 @@ jobs: maven-local-ignore-paths: | net/minestom/ - name: Build Minestom - run: ./gradlew build + run: ./gradlew classes testClasses - name: Run Minestom tests run: ./gradlew test