From d4f62ed0248078a4e9fe1bacff4941162646e3dd Mon Sep 17 00:00:00 2001 From: Yannick Schaus Date: Sat, 13 Nov 2021 22:13:28 +0100 Subject: [PATCH] Add compilation errors & SAT GitHub annotations (#2543) Signed-off-by: Yannick Schaus --- .github/openhab-compile-problems.json | 21 +++++++++++++++++++ .github/workflows/ci-build.yml | 13 ++++++++++++ .../ModbusSlaveErrorResponseException.java | 6 +++--- .../core/cache/ByteArrayFileCache.java | 5 +++-- .../core/library/types/DecimalType.java | 3 --- .../core/library/types/PercentType.java | 5 ----- .../core/library/types/QuantityType.java | 3 --- 7 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 .github/openhab-compile-problems.json diff --git a/.github/openhab-compile-problems.json b/.github/openhab-compile-problems.json new file mode 100644 index 000000000..a5c5c4bb9 --- /dev/null +++ b/.github/openhab-compile-problems.json @@ -0,0 +1,21 @@ +{ + "problemMatcher": [ + { + "owner": "openhab-compile-problems", + "severity": "error", + "pattern": [ + { + "regexp": "Failed to execute goal.*Compilation failure" + }, + { + "regexp": "^\\[ERROR\\] (.+\\.java):\\[(.+),(.+)\\] (.*)$", + "file": 1, + "line": 2, + "col": 3, + "message": 4, + "loop": true + } + ] + } + ] +} diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index aad303ffb..5a7eee2ca 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -54,6 +54,11 @@ jobs: with: maven-version: ${{ matrix.maven }} + - name: Register Problem Matchers + id: problem_matchers + run: | + echo "::add-matcher::.github/openhab-compile-problems.json" + - name: Build id: build run: './.github/scripts/maven-build' @@ -77,3 +82,11 @@ jobs: with: name: sat-summary-report path: target/summary_report.html + + - name: Report SAT Errors as Annotations + uses: ghys/checkstyle-github-action@main + if: ${{ always() && ((steps.build.outcome == 'success') || (steps.build.outcome == 'failure')) }} + with: + title: CheckStyle Violations + path: '**/checkstyle-result.xml' + mode: inline diff --git a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusSlaveErrorResponseException.java b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusSlaveErrorResponseException.java index d581a51ab..58a19df1f 100644 --- a/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusSlaveErrorResponseException.java +++ b/bundles/org.openhab.core.io.transport.modbus/src/main/java/org/openhab/core/io/transport/modbus/exception/ModbusSlaveErrorResponseException.java @@ -28,10 +28,10 @@ import org.eclipse.jdt.annotation.NonNullByDefault; @NonNullByDefault public abstract class ModbusSlaveErrorResponseException extends ModbusTransportException { - private static final Map exceptionCodesIndex = new HashMap<>(10); + private static final Map EXCEPTION_CODES_INDEX = new HashMap<>(10); static { for (KnownExceptionCode code : KnownExceptionCode.values()) { - exceptionCodesIndex.put(code.exceptionCode, code); + EXCEPTION_CODES_INDEX.put(code.exceptionCode, code); } } @@ -64,7 +64,7 @@ public abstract class ModbusSlaveErrorResponseException extends ModbusTransportE } public static Optional tryFromExceptionCode(int exceptionCode) { - return Optional.ofNullable(exceptionCodesIndex.get(exceptionCode)); + return Optional.ofNullable(EXCEPTION_CODES_INDEX.get(exceptionCode)); } } diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/ByteArrayFileCache.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/ByteArrayFileCache.java index 8dbc865c6..5d1218df1 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/ByteArrayFileCache.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/ByteArrayFileCache.java @@ -65,8 +65,9 @@ public class ByteArrayFileCache { * disable this functionality. */ public ByteArrayFileCache(String servicePID, Duration expiry) { - // TODO track and limit folder size - // TODO support user specific folder + // possible to-dos: + // - track and limit folder size + // - support user specific folder cacheFolder = new File(new File(OpenHAB.getUserDataFolder(), CACHE_FOLDER_NAME), servicePID); if (!cacheFolder.exists()) { logger.debug("Creating cache folder '{}'", cacheFolder.getAbsolutePath()); diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/DecimalType.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/DecimalType.java index ccb02d044..3d26556d7 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/DecimalType.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/DecimalType.java @@ -61,7 +61,6 @@ public class DecimalType extends Number implements PrimitiveType, State, Command * The English locale is used to determine (decimal/grouping) separator characters. * * @param value the non null value representing a number - * * @throws NumberFormatException when the number could not be parsed to a {@link BigDecimal} */ public DecimalType(String value) { @@ -73,7 +72,6 @@ public class DecimalType extends Number implements PrimitiveType, State, Command * * @param value the non null value representing a number * @param locale the locale used to determine (decimal/grouping) separator characters - * * @throws NumberFormatException when the number could not be parsed to a {@link BigDecimal} */ public DecimalType(String value, Locale locale) { @@ -102,7 +100,6 @@ public class DecimalType extends Number implements PrimitiveType, State, Command * * @param value the non null value representing a number * @return a new {@link DecimalType} - * * @throws NumberFormatException when the number could not be parsed to a {@link BigDecimal} */ public static DecimalType valueOf(String value) { diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/PercentType.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/PercentType.java index b97a6ba42..51e435134 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/PercentType.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/PercentType.java @@ -45,7 +45,6 @@ public class PercentType extends DecimalType { * Creates a new {@link PercentType} with the given value. * * @param value the value representing a percentage - * * @throws IllegalArgumentException when the value is not between 0 and 100 */ public PercentType(int value) { @@ -58,7 +57,6 @@ public class PercentType extends DecimalType { * The English locale is used to determine (decimal/grouping) separator characters. * * @param value the non null value representing a percentage - * * @throws NumberFormatException when the number could not be parsed to a {@link BigDecimal} * @throws IllegalArgumentException when the value is not between 0 and 100 */ @@ -71,7 +69,6 @@ public class PercentType extends DecimalType { * * @param value the non null value representing a percentage * @param locale the locale used to determine (decimal/grouping) separator characters - * * @throws NumberFormatException when the number could not be parsed to a {@link BigDecimal} * @throws IllegalArgumentException when the value is not between 0 and 100 */ @@ -84,7 +81,6 @@ public class PercentType extends DecimalType { * Creates a new {@link PercentType} with the given value. * * @param value the value representing a percentage. - * * @throws IllegalArgumentException when the value is not between 0 and 100 */ public PercentType(BigDecimal value) { @@ -103,7 +99,6 @@ public class PercentType extends DecimalType { * * @param value the non null value representing a percentage * @return new {@link PercentType} - * * @throws NumberFormatException when the number could not be parsed to a {@link BigDecimal} * @throws IllegalArgumentException when the value is not between 0 and 100 */ diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/QuantityType.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/QuantityType.java index c3322483d..183d66cf3 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/QuantityType.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/QuantityType.java @@ -99,7 +99,6 @@ public class QuantityType> extends Number * The English locale is used to determine (decimal/grouping) separator characters. * * @param value the non null value representing a quantity with an optional unit. - * * @throws NumberFormatException when a quantity without a unit could not be parsed * @throws IllegalArgumentException when a quantity with a unit could not be parsed */ @@ -113,7 +112,6 @@ public class QuantityType> extends Number * * @param value the non null value representing a quantity with an optional unit. * @param locale the locale used to determine (decimal/grouping) separator characters. - * * @throws NumberFormatException when a quantity without a unit could not be parsed * @throws IllegalArgumentException when a quantity with a unit could not be parsed */ @@ -201,7 +199,6 @@ public class QuantityType> extends Number * * @param value the non null value representing a quantity with an optional unit * @return a new {@link QuantityType} - * * @throws NumberFormatException when a quantity without a unit could not be parsed * @throws IllegalArgumentException when a quantity with a unit could not be parsed */