Skip to content

Commit

Permalink
Add compilation errors & SAT GitHub annotations (openhab#2543)
Browse files Browse the repository at this point in the history
Signed-off-by: Yannick Schaus <[email protected]>
  • Loading branch information
ghys authored Nov 13, 2021
1 parent 917e268 commit d4f62ed
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 16 deletions.
21 changes: 21 additions & 0 deletions .github/openhab-compile-problems.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
]
}
13 changes: 13 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
@NonNullByDefault
public abstract class ModbusSlaveErrorResponseException extends ModbusTransportException {

private static final Map<Integer, KnownExceptionCode> exceptionCodesIndex = new HashMap<>(10);
private static final Map<Integer, KnownExceptionCode> EXCEPTION_CODES_INDEX = new HashMap<>(10);
static {
for (KnownExceptionCode code : KnownExceptionCode.values()) {
exceptionCodesIndex.put(code.exceptionCode, code);
EXCEPTION_CODES_INDEX.put(code.exceptionCode, code);
}
}

Expand Down Expand Up @@ -64,7 +64,7 @@ public int getExceptionCode() {
}

public static Optional<KnownExceptionCode> tryFromExceptionCode(int exceptionCode) {
return Optional.ofNullable(exceptionCodesIndex.get(exceptionCode));
return Optional.ofNullable(EXCEPTION_CODES_INDEX.get(exceptionCode));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ public ByteArrayFileCache(String servicePID) {
* 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public DecimalType(double value) {
* 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) {
Expand All @@ -73,7 +72,6 @@ public DecimalType(String value) {
*
* @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) {
Expand Down Expand Up @@ -102,7 +100,6 @@ public String toFullString() {
*
* @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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public PercentType() {
* 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) {
Expand All @@ -58,7 +57,6 @@ public PercentType(int value) {
* 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
*/
Expand All @@ -71,7 +69,6 @@ public PercentType(String value) {
*
* @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
*/
Expand All @@ -84,7 +81,6 @@ public PercentType(String value, Locale locale) {
* 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) {
Expand All @@ -103,7 +99,6 @@ private void validateValue(BigDecimal value) {
*
* @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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public QuantityType() {
* 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
*/
Expand All @@ -113,7 +112,6 @@ public QuantityType(String value) {
*
* @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
*/
Expand Down Expand Up @@ -201,7 +199,6 @@ public String toString() {
*
* @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
*/
Expand Down

0 comments on commit d4f62ed

Please sign in to comment.