Skip to content

Commit

Permalink
Warning and codeanalysis (openhab#15828)
Browse files Browse the repository at this point in the history
Signed-off-by: Leo Siepel <[email protected]>
  • Loading branch information
lsiepel authored Nov 3, 2023
1 parent 7724f16 commit fddacb4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@NonNullByDefault
public class BluetoothUtils {

public static final Logger logger = LoggerFactory.getLogger(BluetoothUtils.class);
public static final Logger LOGGER = LoggerFactory.getLogger(BluetoothUtils.class);

public static final int FORMAT_UINT8 = 0x11;
public static final int FORMAT_UINT16 = 0x12;
Expand All @@ -47,9 +47,7 @@ public class BluetoothUtils {
*/
public static int[] toIntArray(byte[] value) {
int[] ret = new int[value.length];
for (int i = 0; i < value.length; i++) {
ret[i] = value[i];
}
System.arraycopy(value, 0, ret, 0, value.length);
return ret;
}

Expand Down Expand Up @@ -90,7 +88,7 @@ public static byte[] toByteArray(int[] value) {
return unsignedToSigned(
unsignedBytesToInt(value[offset], value[offset + 1], value[offset + 2], value[offset + 3]), 32);
default:
logger.error("Unknown format type {} - no int value can be provided for it.", formatType);
LOGGER.error("Unknown format type {} - no int value can be provided for it.", formatType);
}

return null;
Expand All @@ -111,7 +109,7 @@ public static byte[] toByteArray(int[] value) {
case FORMAT_FLOAT:
return bytesToFloat(value[offset], value[offset + 1], value[offset + 2], value[offset + 3]);
default:
logger.error("Unknown format type {} - no float value can be provided for it.", formatType);
LOGGER.error("Unknown format type {} - no float value can be provided for it.", formatType);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ public int hashCode() {
return result;
}

@SuppressWarnings("PMD.SimplifyBooleanReturns")
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ public void deviceDiscovered(BluetoothDevice device) {
logger.debug("Discovered bluetooth device '{}': {}", device.getName(), device);

DiscoveryCache cache = discoveryCaches.computeIfAbsent(device.getAddress(), addr -> new DiscoveryCache());
cache.handleDiscovery(device);
if (cache != null) {
cache.handleDiscovery(device);
}
}

private static ThingUID createThingUIDWithBridge(DiscoveryResult result, BluetoothAdapter adapter) {
Expand Down

0 comments on commit fddacb4

Please sign in to comment.