From 7909ffe9e2bb8d2f3430587cd5e35516229afe44 Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Wed, 10 Jan 2024 11:27:45 +0100 Subject: [PATCH] Forbid code that would reformat poorly Current checkstyle rules somehow allow things like void run() { throw new UnsupportedOperationException(); } Runnable r = () -> { throw new RuntimeException(); } Runnable asRunnable() { a_field++; } void update() { throw new RuntimeException(); } however, when such code is then auto-formatted by IntelliJ with Airbase codestyle, some whitespace is removed, resulting in a code that violates checkstyle rules. This state is undesired: sometimes a person working on a class file may need to undo auto-formatting so pass checkstyle checks. The new rules aim to reduce such situation by recognizing some common would-format-incorrectly patterns. --- CHANGES.md | 2 ++ .../main/resources/checkstyle/airbase-checks.xml | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 3379baedd..a423f78e0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,7 @@ Airbase 149 * Remove bval dependency +* Checkstyle updates: + - Disallow single-line non-empty lambda and method body code blocks. * Plugin updates: - git-commit-id-maven-plugin 7.0.0 (from 6.0.0) - spotbugs-maven-plugins 4.8.1.0 (from 4.7.3.6) diff --git a/airbase-policy/src/main/resources/checkstyle/airbase-checks.xml b/airbase-policy/src/main/resources/checkstyle/airbase-checks.xml index eb8c158df..c366860b6 100644 --- a/airbase-policy/src/main/resources/checkstyle/airbase-checks.xml +++ b/airbase-policy/src/main/resources/checkstyle/airbase-checks.xml @@ -256,6 +256,22 @@ + + + + + + + + + + + + + + + +