Fix SAT warnings (#14214)

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich 2023-01-13 19:10:59 +01:00 committed by GitHub
parent 4dd60bb442
commit ee54882841
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 57 additions and 52 deletions

View File

@ -24,44 +24,44 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
@NonNullByDefault @NonNullByDefault
public class Commands { public class Commands {
public static byte[] DISCOVER_SEND = { 0x0c, 0x00, 0x30, 0x00, 0x11, 0x00, 0x12, 0x00, 0x13 }; public static final byte[] DISCOVER_SEND = { 0x0c, 0x00, 0x30, 0x00, 0x11, 0x00, 0x12, 0x00, 0x13 };
public static byte[] DISCOVER_RECEIVE = { 0x0d, 0x00, 0x07, 0x00, 0x02, 0x02, 0x00 }; public static final byte[] DISCOVER_RECEIVE = { 0x0d, 0x00, 0x07, 0x00, 0x02, 0x02, 0x00 };
public static byte[] EMPTY = {}; public static final byte[] EMPTY = {};
public static byte[] GET_HISTORY = { 0x00, 0x30 }; public static final byte[] GET_HISTORY = { 0x00, 0x30 };
public static byte[] REGISTER_0_READ = { 0x00, 0x04 }; public static final byte[] REGISTER_0_READ = { 0x00, 0x04 };
public static byte[] REGISTER_1_READ = { 0x01, 0x04 }; public static final byte[] REGISTER_1_READ = { 0x01, 0x04 };
public static byte[] REGISTER_1_WRITE = { 0x01, 0x06 }; public static final byte[] REGISTER_1_WRITE = { 0x01, 0x06 };
public static byte[] REGISTER_2_READ = { 0x02, 0x04 }; public static final byte[] REGISTER_2_READ = { 0x02, 0x04 };
public static byte[] REGISTER_4_READ = { 0x04, 0x04 }; public static final byte[] REGISTER_4_READ = { 0x04, 0x04 };
public static byte[] REGISTER_6_READ = { 0x06, 0x04 }; public static final byte[] REGISTER_6_READ = { 0x06, 0x04 };
public static byte[] MODE = { 0x14, 0x12 }; public static final byte[] MODE = { 0x14, 0x12 };
public static byte[] MANUAL_FAN_SPEED_STEP = { 0x15, 0x61 }; public static final byte[] MANUAL_FAN_SPEED_STEP = { 0x15, 0x61 };
public static byte[] SUPPLY_FAN_SPEED = { 0x14, 0x50 }; public static final byte[] SUPPLY_FAN_SPEED = { 0x14, 0x50 };
public static byte[] EXTRACT_FAN_SPEED = { 0x14, 0x51 }; public static final byte[] EXTRACT_FAN_SPEED = { 0x14, 0x51 };
public static byte[] SUPPLY_FAN_STEP = { 0x14, 0x28 }; public static final byte[] SUPPLY_FAN_STEP = { 0x14, 0x28 };
public static byte[] EXTRACT_FAN_STEP = { 0x14, 0x29 }; public static final byte[] EXTRACT_FAN_STEP = { 0x14, 0x29 };
public static byte[] BASE_IN = { 0x14, 0x40 }; public static final byte[] BASE_IN = { 0x14, 0x40 };
public static byte[] BASE_OUT = { 0x14, 0x41 }; public static final byte[] BASE_OUT = { 0x14, 0x41 };
public static byte[] BYPASS = { 0x14, 0x60 }; public static final byte[] BYPASS = { 0x14, 0x60 };
public static byte[] BYPASS_DEACTIVATION = { 0x14, 0x63 }; public static final byte[] BYPASS_DEACTIVATION = { 0x14, 0x63 };
public static byte[] BOOST = { 0x15, 0x30 }; public static final byte[] BOOST = { 0x15, 0x30 };
public static byte[] NIGHT_COOLING = { 0x15, 0x71 }; public static final byte[] NIGHT_COOLING = { 0x15, 0x71 };
public static byte[] AUTOMATIC_BYPASS = { 0x17, 0x06 }; public static final byte[] AUTOMATIC_BYPASS = { 0x17, 0x06 };
public static byte[] AUTOMATIC_RUSH_AIRING = { 0x17, 0x02 }; public static final byte[] AUTOMATIC_RUSH_AIRING = { 0x17, 0x02 };
public static byte[] HUMIDITY = { 0x14, 0x70 }; public static final byte[] HUMIDITY = { 0x14, 0x70 };
public static byte[] ROOM_TEMPERATURE = { 0x03, 0x00 }; public static final byte[] ROOM_TEMPERATURE = { 0x03, 0x00 };
public static byte[] ROOM_TEMPERATURE_CALCULATED = { 0x14, (byte) 0x96 }; public static final byte[] ROOM_TEMPERATURE_CALCULATED = { 0x14, (byte) 0x96 };
public static byte[] OUTDOOR_TEMPERATURE = { 0x03, 0x34 }; public static final byte[] OUTDOOR_TEMPERATURE = { 0x03, 0x34 };
public static byte[] SUPPLY_TEMPERATURE = { 0x14, 0x73 }; public static final byte[] SUPPLY_TEMPERATURE = { 0x14, 0x73 };
public static byte[] EXTRACT_TEMPERATURE = { 0x14, 0x74 }; public static final byte[] EXTRACT_TEMPERATURE = { 0x14, 0x74 };
public static byte[] EXHAUST_TEMPERATURE = { 0x14, 0x75 }; public static final byte[] EXHAUST_TEMPERATURE = { 0x14, 0x75 };
public static byte[] BATTERY_LIFE = { 0x03, 0x0f }; public static final byte[] BATTERY_LIFE = { 0x03, 0x0f };
public static byte[] FILTER_LIFE = { 0x14, 0x6a }; public static final byte[] FILTER_LIFE = { 0x14, 0x6a };
public static byte[] FILTER_PERIOD = { 0x14, 0x69 }; public static final byte[] FILTER_PERIOD = { 0x14, 0x69 };
public static byte[] CURRENT_TIME = { 0x15, (byte) 0xe0 }; public static final byte[] CURRENT_TIME = { 0x15, (byte) 0xe0 };
public static byte[] AWAY_TO = { 0x15, 0x20 }; public static final byte[] AWAY_TO = { 0x15, 0x20 };
public static byte[] AWAY_FROM = { 0x15, 0x21 }; public static final byte[] AWAY_FROM = { 0x15, 0x21 };
public static byte[] UNIT_SERIAL = { 0x00, 0x25 }; // endpoint 4 public static final byte[] UNIT_SERIAL = { 0x00, 0x25 }; // endpoint 4
public static byte[] UNIT_NAME = { 0x15, (byte) 0xe5 }; // endpoint 1 public static final byte[] UNIT_NAME = { 0x15, (byte) 0xe5 }; // endpoint 1
public static byte[] CCM_SERIAL = { 0x14, 0x6a }; // endpoint 0 public static final byte[] CCM_SERIAL = { 0x14, 0x6a }; // endpoint 0
} }

View File

@ -28,11 +28,11 @@ import org.openhab.core.thing.ThingTypeUID;
@NonNullByDefault @NonNullByDefault
public class DanfossAirUnitBindingConstants { public class DanfossAirUnitBindingConstants {
public static String BINDING_ID = "danfossairunit"; public static final String BINDING_ID = "danfossairunit";
// The only thing type UIDs // The only thing type UIDs
public static ThingTypeUID THING_TYPE_AIRUNIT = new ThingTypeUID(BINDING_ID, "airunit"); public static final ThingTypeUID THING_TYPE_AIRUNIT = new ThingTypeUID(BINDING_ID, "airunit");
// The thing type as a set // The thing type as a set
public static Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_AIRUNIT); public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_AIRUNIT);
} }

View File

@ -193,6 +193,7 @@ public final class TimetablesV1Impl implements TimetablesV1Api {
/** /**
* Build rest endpoint URL for request the planned timetable. * Build rest endpoint URL for request the planned timetable.
*/ */
@SuppressWarnings("PMD.UnsynchronizedStaticFormatter")
private String buildPlanRequestURL(final String evaNr, final Date date) { private String buildPlanRequestURL(final String evaNr, final Date date) {
synchronized (this) { synchronized (this) {
final String dateParam = DATE_FORMAT.format(date); final String dateParam = DATE_FORMAT.format(date);

View File

@ -186,7 +186,6 @@ public class DeutscheBahnTimetableHandlerTest implements TimetablesV1ImplTestHel
verifyChannelsUpdatedToUndef(bridge, 0, callback); verifyChannelsUpdatedToUndef(bridge, 0, callback);
verifyChannelsUpdatedToUndef(bridge, 1, callback); verifyChannelsUpdatedToUndef(bridge, 1, callback);
verifyChannelsUpdatedToUndef(bridge, 2, callback); verifyChannelsUpdatedToUndef(bridge, 2, callback);
} finally { } finally {
handler.dispose(); handler.dispose();
} }
@ -226,7 +225,6 @@ public class DeutscheBahnTimetableHandlerTest implements TimetablesV1ImplTestHel
verifyThingUpdated(bridge, 0, stop01.getId()); verifyThingUpdated(bridge, 0, stop01.getId());
verifyChannelsUpdatedToUndef(bridge, 1, callback); verifyChannelsUpdatedToUndef(bridge, 1, callback);
verifyChannelsUpdatedToUndef(bridge, 2, callback); verifyChannelsUpdatedToUndef(bridge, 2, callback);
} finally { } finally {
handler.dispose(); handler.dispose();
} }

View File

@ -413,8 +413,9 @@ public class HomekitAccessoryFactory {
.collect(Collectors.toList())) { .collect(Collectors.toList())) {
var characteristic = HomekitMetadataCharacteristicFactory.createCharacteristic(entry.getKey(), var characteristic = HomekitMetadataCharacteristicFactory.createCharacteristic(entry.getKey(),
entry.getValue()); entry.getValue());
if (characteristic.isPresent()) if (characteristic.isPresent()) {
accessory.addCharacteristic(characteristic.get()); accessory.addCharacteristic(characteristic.get());
}
} }
} }

View File

@ -72,7 +72,7 @@ public class HomekitMetadataCharacteristicFactory {
private static final Logger logger = LoggerFactory.getLogger(HomekitMetadataCharacteristicFactory.class); private static final Logger logger = LoggerFactory.getLogger(HomekitMetadataCharacteristicFactory.class);
// List of optional characteristics that can be set via metadata, and the corresponding method to create them. // List of optional characteristics that can be set via metadata, and the corresponding method to create them.
private final static Map<HomekitCharacteristicType, Function<Object, Characteristic>> optional = new HashMap<>() { private static final Map<HomekitCharacteristicType, Function<Object, Characteristic>> optional = new HashMap<>() {
{ {
put(ACTIVE_IDENTIFIER, HomekitMetadataCharacteristicFactory::createActiveIdentifierCharacteristic); put(ACTIVE_IDENTIFIER, HomekitMetadataCharacteristicFactory::createActiveIdentifierCharacteristic);
put(ACTIVE_STATUS, HomekitMetadataCharacteristicFactory::createActiveStatusCharacteristic); put(ACTIVE_STATUS, HomekitMetadataCharacteristicFactory::createActiveStatusCharacteristic);
@ -101,8 +101,9 @@ public class HomekitMetadataCharacteristicFactory {
public static Optional<Characteristic> createCharacteristic(String characteristic, Object value) { public static Optional<Characteristic> createCharacteristic(String characteristic, Object value) {
var type = HomekitCharacteristicType.valueOfTag(characteristic); var type = HomekitCharacteristicType.valueOfTag(characteristic);
if (type.isEmpty() || !optional.containsKey(type.get())) if (type.isEmpty() || !optional.containsKey(type.get())) {
return Optional.empty(); return Optional.empty();
}
return Optional.of(optional.get(type.get()).apply(value)); return Optional.of(optional.get(type.get()).apply(value));
} }

View File

@ -155,6 +155,7 @@ You must either
* port forward your openHAB installation to port 80, * port forward your openHAB installation to port 80,
(`iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080`) (`iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080`)
* install a reverse proxy on port 80, for example nginx with the following configuration: * install a reverse proxy on port 80, for example nginx with the following configuration:
``` ```
server { server {
listen 80; listen 80;
@ -167,10 +168,12 @@ You must either
} }
} }
``` ```
* or let openHAB run on port 80 (the entire java process requires elevated privileges). * or let openHAB run on port 80 (the entire java process requires elevated privileges).
* For Amazon Echo the pairing process may fail due to a 302 response from openHAB, this can be resolved by using a reverse proxy to change the request url from `/api` to `/api/`, for example nginx with the following configuration: * For Amazon Echo the pairing process may fail due to a 302 response from openHAB, this can be resolved by using a reverse proxy to change the request url from `/api` to `/api/`, for example nginx with the following configuration:
```
```
server { server {
listen 80; listen 80;
location /api { location /api {
@ -178,6 +181,7 @@ You must either
} }
} }
``` ```
Please open port 80 tcp and port 1900 udp in your firewall installation. Please open port 80 tcp and port 1900 udp in your firewall installation.
You can test if the hue emulation does its job by enabling pairing mode including the option "Amazon Echo device discovery fix". You can test if the hue emulation does its job by enabling pairing mode including the option "Amazon Echo device discovery fix".

View File

@ -74,7 +74,7 @@ public class NetworkUtils {
/** /**
* Adds cors headers to the given response and returns it. * Adds cors headers to the given response and returns it.
*/ */
public static ResponseBuilder ResponseWithCors(ResponseBuilder response) { public static ResponseBuilder responseWithCors(ResponseBuilder response) {
return response.encoding(StandardCharsets.UTF_8.name()) // return response.encoding(StandardCharsets.UTF_8.name()) //
.header("Access-Control-Allow-Origin", "*") .header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Headers", "origin, content-type, accept, authorization") .header("Access-Control-Allow-Headers", "origin, content-type, accept, authorization")

View File

@ -95,7 +95,7 @@ public class CommonSetup {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public <T> Storage<T> getStorage(String name) { public <T> Storage<T> getStorage(String name) {
if (name.equals("hueEmulationUsers")) { if ("hueEmulationUsers".equals(name)) {
return (Storage<T>) new DummyUsersStorage(); return (Storage<T>) new DummyUsersStorage();
} }
throw new IllegalStateException(); throw new IllegalStateException();

View File

@ -122,7 +122,7 @@ public class UsersAndConfigTests {
} }
@Test @Test
public void UnauthorizedAccessTest() { public void unauthorizedAccessTest() {
// Unauthorized config // Unauthorized config
Response response; Response response;
response = commonSetup.client.target(commonSetup.basePath + "/config").request().get(); response = commonSetup.client.target(commonSetup.basePath + "/config").request().get();