mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Remove unused local variables (#10528)
Fixes 26 SAT UnusedLocalVariable findings Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
parent
030329c118
commit
b42101addc
@ -64,11 +64,7 @@ public class MadokaMessageTest {
|
||||
|
||||
@Test
|
||||
public void testParseOperationHours() {
|
||||
String s = "390001120201004004DC0B00004104F40300004204642300004304000000004404000000004504000000004604000000004704000000004800";
|
||||
|
||||
MadokaValue mv = new MadokaValue(0, 4, new byte[] { (byte) 0xF4, 0x03, 0x00, 0x00 });
|
||||
// MadokaValue mv = new MadokaValue(0, 4, new byte[] { 0x00, 0x00, 0x03, (byte) 0xF4 });
|
||||
|
||||
Long v = mv.getComputedValue(ByteOrder.LITTLE_ENDIAN);
|
||||
assertEquals(1012, v);
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ import org.openhab.core.thing.ChannelUID;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingStatus;
|
||||
import org.openhab.core.thing.ThingStatusDetail;
|
||||
import org.openhab.core.thing.ThingTypeUID;
|
||||
import org.openhab.core.thing.binding.BaseThingHandler;
|
||||
import org.openhab.core.types.Command;
|
||||
import org.openhab.core.types.State;
|
||||
@ -227,7 +226,6 @@ public abstract class DaikinBaseHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
private void changeHomekitMode(String homekitmode) throws DaikinCommunicationException {
|
||||
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
|
||||
if (HomekitMode.OFF.getValue().equals(homekitmode)) {
|
||||
changePower(false);
|
||||
} else {
|
||||
|
@ -270,12 +270,10 @@ public class FSInternetRadioDiscoveryParticipant implements UpnpDiscoveryPartici
|
||||
// Some devices report crappy UPnP device description so manufacturer and model are ""
|
||||
// In this case we try to find the match in friendlyName
|
||||
final String uname = friendlyName.toUpperCase();
|
||||
for (Map.Entry<String, Set<String>> entry : SUPPORTED_RADIO_MODELS.entrySet()) {
|
||||
for (Set<String> set : SUPPORTED_RADIO_MODELS.values()) {
|
||||
for (String model : set) {
|
||||
if ((model != null) && !model.isEmpty() && uname.contains(model)) {
|
||||
return new ThingUID(THING_TYPE_RADIO, serialNumber);
|
||||
}
|
||||
for (Set<String> set : SUPPORTED_RADIO_MODELS.values()) {
|
||||
for (String model : set) {
|
||||
if ((model != null) && !model.isEmpty() && uname.contains(model)) {
|
||||
return new ThingUID(THING_TYPE_RADIO, serialNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ public class Mhub4K431Handler extends BaseThingHandler {
|
||||
httpHeaders.setProperty("Cookie", "logintype-88=01");
|
||||
|
||||
try {
|
||||
String response = HttpUtil.executeUrl(httpMethod, url, httpHeaders, stream,
|
||||
HttpUtil.executeUrl(httpMethod, url, httpHeaders, stream,
|
||||
"application/x-www-form-urlencoded; charset=UTF-8", timeout);
|
||||
} catch (IOException e) {
|
||||
logger.debug("Communication with device failed", e);
|
||||
|
@ -49,7 +49,6 @@ import org.oasis_open.docs.wsn.b_2.Subscribe;
|
||||
import org.oasis_open.docs.wsn.b_2.SubscribeResponse;
|
||||
import org.oasis_open.docs.wsn.b_2.TopicExpressionType;
|
||||
import org.oasis_open.docs.wsn.b_2.Unsubscribe;
|
||||
import org.oasis_open.docs.wsn.b_2.UnsubscribeResponse;
|
||||
import org.oasis_open.docs.wsn.bw_2.InvalidFilterFault;
|
||||
import org.oasis_open.docs.wsn.bw_2.InvalidMessageContentExpressionFault;
|
||||
import org.oasis_open.docs.wsn.bw_2.InvalidProducerPropertiesExpressionFault;
|
||||
@ -347,7 +346,7 @@ public class HeliosHandler27 extends BaseThingHandler implements NotificationCon
|
||||
public void unsubscribe() {
|
||||
if (subscription != null) {
|
||||
try {
|
||||
UnsubscribeResponse response = subscription.unsubscribe(new Unsubscribe());
|
||||
subscription.unsubscribe(new Unsubscribe());
|
||||
logger.debug("Unsubscribing the subscription with ID '{}' for '{}' ", getSubscriptionID(),
|
||||
getThing().getUID());
|
||||
} catch (UnableToDestroySubscriptionFault | ResourceUnknownFault e) {
|
||||
|
@ -25,7 +25,6 @@ import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants;
|
||||
import org.openhab.binding.innogysmarthome.internal.client.InnogyClient;
|
||||
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.Capability;
|
||||
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.State;
|
||||
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Device;
|
||||
import org.openhab.binding.innogysmarthome.internal.client.entity.link.Link;
|
||||
import org.openhab.binding.innogysmarthome.internal.client.entity.message.Message;
|
||||
@ -131,9 +130,7 @@ public class DeviceStructureManager {
|
||||
if (d.isRadioDevice() && !d.isReachable()) {
|
||||
logger.debug(">> CAP-State: unknown (device NOT REACHABLE).");
|
||||
} else {
|
||||
if (c.hasState()) {
|
||||
final State state = c.getCapabilityState().getState();
|
||||
} else {
|
||||
if (!c.hasState()) {
|
||||
logger.debug(">> CAP-State: unknown (NULL)");
|
||||
}
|
||||
}
|
||||
|
@ -849,7 +849,6 @@ public class EthernetBridgeHandler extends BaseBridgeHandler implements Transcei
|
||||
|
||||
Matcher matcher = RESPONSE_PATTERN.matcher(response);
|
||||
if (matcher.matches()) {
|
||||
String byteCountAsString = matcher.group(1);
|
||||
message = matcher.group(2);
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ public class KeContactTransceiver {
|
||||
new Object[] { new String(theBuffer.array()),
|
||||
theChannel.getLocalAddress(),
|
||||
theChannel.getRemoteAddress() });
|
||||
int byteswritten = theChannel.write(theBuffer);
|
||||
theChannel.write(theBuffer);
|
||||
} catch (NotYetConnectedException e) {
|
||||
theHandler.updateStatus(ThingStatus.OFFLINE,
|
||||
ThingStatusDetail.COMMUNICATION_ERROR,
|
||||
|
@ -23,7 +23,6 @@ import java.util.stream.Stream;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceClassObject;
|
||||
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceMetaData;
|
||||
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceOperation;
|
||||
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceProperty;
|
||||
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.HomeDevice;
|
||||
import org.openhab.core.thing.Bridge;
|
||||
@ -162,15 +161,6 @@ public abstract class MieleApplianceHandler<E extends Enum<E> & ApplianceChannel
|
||||
// Ignore - this is due to an unrecognized and not yet reverse-engineered array property
|
||||
}
|
||||
}
|
||||
|
||||
for (JsonElement operation : dco.Operations.getAsJsonArray()) {
|
||||
try {
|
||||
DeviceOperation devop = gson.fromJson(operation, DeviceOperation.class);
|
||||
DeviceMetaData pmd = gson.fromJson(devop.Metadata, DeviceMetaData.class);
|
||||
} catch (Exception p) {
|
||||
// Ignore - this is due to an unrecognized and not yet reverse-engineered array property
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,6 @@ public class AtomicStampedKeyValueTest {
|
||||
*/
|
||||
@Test
|
||||
public void testCopyIfStampAfterEqual() {
|
||||
Object key = new Object();
|
||||
Object val = new Object();
|
||||
AtomicStampedValue<Object> keyValue = new AtomicStampedValue<>(42L, val);
|
||||
AtomicStampedValue<Object> copy = keyValue.copyIfStampAfter(42L);
|
||||
@ -98,7 +97,6 @@ public class AtomicStampedKeyValueTest {
|
||||
assertThat(keyValue.getValue(), is(equalTo(copy.getValue())));
|
||||
|
||||
// after update they live life of their own
|
||||
Object key2 = new Object();
|
||||
Object val2 = new Object();
|
||||
copy.update(-99L, val2);
|
||||
|
||||
@ -144,7 +142,6 @@ public class AtomicStampedKeyValueTest {
|
||||
assertThat(keyValue.getValue(), is(equalTo(copy.getValue())));
|
||||
|
||||
// after update they live life of their own
|
||||
Object key2 = new Object();
|
||||
Object val2 = new Object();
|
||||
copy.update(-99L, val2);
|
||||
|
||||
|
@ -230,28 +230,27 @@ public abstract class AbstractBrokerHandler extends BaseBridgeHandler implements
|
||||
* @param topic the topic (as specified during registration)
|
||||
*/
|
||||
public final void unregisterDiscoveryListener(MQTTTopicDiscoveryParticipant listener, String topic) {
|
||||
Map<MQTTTopicDiscoveryParticipant, @Nullable TopicSubscribe> topicListeners = discoveryTopics.compute(topic,
|
||||
(k, v) -> {
|
||||
if (v == null) {
|
||||
logger.warn(
|
||||
"Tried to unsubscribe {} from discovery topic {} on broker {} but topic not registered at all. Check discovery logic!",
|
||||
listener, topic, thing.getUID());
|
||||
return null;
|
||||
}
|
||||
v.compute(listener, (l, w) -> {
|
||||
if (w == null) {
|
||||
logger.warn(
|
||||
"Tried to unsubscribe {} from discovery topic {} on broker {} but topic not registered for listener. Check discovery logic!",
|
||||
listener, topic, thing.getUID());
|
||||
} else {
|
||||
w.stop();
|
||||
logger.trace("Unsubscribed {} from discovery topic {} on broker {}", listener, topic,
|
||||
thing.getUID());
|
||||
}
|
||||
return null;
|
||||
});
|
||||
return v.isEmpty() ? null : v;
|
||||
});
|
||||
discoveryTopics.compute(topic, (k, v) -> {
|
||||
if (v == null) {
|
||||
logger.warn(
|
||||
"Tried to unsubscribe {} from discovery topic {} on broker {} but topic not registered at all. Check discovery logic!",
|
||||
listener, topic, thing.getUID());
|
||||
return null;
|
||||
}
|
||||
v.compute(listener, (l, w) -> {
|
||||
if (w == null) {
|
||||
logger.warn(
|
||||
"Tried to unsubscribe {} from discovery topic {} on broker {} but topic not registered for listener. Check discovery logic!",
|
||||
listener, topic, thing.getUID());
|
||||
} else {
|
||||
w.stop();
|
||||
logger.trace("Unsubscribed {} from discovery topic {} on broker {}", listener, topic,
|
||||
thing.getUID());
|
||||
}
|
||||
return null;
|
||||
});
|
||||
return v.isEmpty() ? null : v;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -263,7 +263,6 @@ public class ShellyComponents {
|
||||
updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_CONTACT,
|
||||
getString(sdata.sensor.state).equalsIgnoreCase(SHELLY_API_DWSTATE_OPEN) ? OpenClosedType.OPEN
|
||||
: OpenClosedType.CLOSED);
|
||||
String sensorError = getString(sdata.sensorError);
|
||||
boolean changed = thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_ERROR,
|
||||
getStringType(sdata.sensorError));
|
||||
if (changed) {
|
||||
|
@ -227,7 +227,7 @@ public class ShellyManagerActionPage extends ShellyManagerPage {
|
||||
actionUrl = buildActionUrl(uid, action);
|
||||
} else {
|
||||
try {
|
||||
String result = api.resetStaCache();
|
||||
api.resetStaCache();
|
||||
message = getMessage("action.resetsta-confirm");
|
||||
} catch (ShellyApiException e) {
|
||||
message = getMessageP("action.resetsta-failed", e.toString());
|
||||
@ -243,7 +243,7 @@ public class ShellyManagerActionPage extends ShellyManagerPage {
|
||||
actionUrl = buildActionUrl(uid, action);
|
||||
} else {
|
||||
try {
|
||||
String result = api.setWiFiRecovery(enable);
|
||||
api.setWiFiRecovery(enable);
|
||||
message = getMessage("action.setwifirec-confirm", enable ? "enabled" : "disabled");
|
||||
} catch (ShellyApiException e) {
|
||||
message = getMessage("action.setwifirec-failed", e.toString());
|
||||
@ -260,7 +260,7 @@ public class ShellyManagerActionPage extends ShellyManagerPage {
|
||||
actionUrl = buildActionUrl(uid, action);
|
||||
} else {
|
||||
try {
|
||||
String result = api.setApRoaming(enable);
|
||||
api.setApRoaming(enable);
|
||||
message = getMessage("action.aproaming-confirm", enable ? "enabled" : "disabled");
|
||||
} catch (ShellyApiException e) {
|
||||
message = getMessage("action.aproaming-failed", e.toString());
|
||||
|
@ -91,7 +91,7 @@ public class ShellyManagerCache<K, V> extends ConcurrentHashMap<K, V> {
|
||||
long currentTime = new Date().getTime();
|
||||
for (K key : timeMap.keySet()) {
|
||||
if (currentTime > (timeMap.get(key) + expiryInMillis)) {
|
||||
V value = remove(key);
|
||||
remove(key);
|
||||
timeMap.remove(key);
|
||||
}
|
||||
}
|
||||
|
@ -430,6 +430,7 @@ public class ValloxMVWebSocket {
|
||||
BigDecimal bdTempIncoming = getTemperature(bytes, 138);
|
||||
|
||||
int iHumidity = getNumberBE(bytes, 148);
|
||||
@SuppressWarnings("unused")
|
||||
int iCo2 = getNumberBE(bytes, 150);
|
||||
|
||||
int iStateOrig = getNumberBE(bytes, 214);
|
||||
|
@ -62,7 +62,7 @@ public class DummyItemRegistry implements ItemRegistry {
|
||||
|
||||
@Override
|
||||
public Item add(Item element) {
|
||||
Item put = items.put(element.getUID(), element);
|
||||
items.put(element.getUID(), element);
|
||||
for (RegistryChangeListener<Item> l : listeners) {
|
||||
l.added(element);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class DummyMetadataRegistry implements MetadataRegistry {
|
||||
|
||||
@Override
|
||||
public Metadata add(Metadata element) {
|
||||
Metadata put = items.put(element.getUID(), element);
|
||||
items.put(element.getUID(), element);
|
||||
for (RegistryChangeListener<Metadata> l : listeners) {
|
||||
l.added(element);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class DummyRuleRegistry implements RuleRegistry {
|
||||
|
||||
@Override
|
||||
public Rule add(Rule element) {
|
||||
Rule put = items.put(element.getUID(), element);
|
||||
items.put(element.getUID(), element);
|
||||
for (RegistryChangeListener<Rule> l : listeners) {
|
||||
l.added(element);
|
||||
}
|
||||
|
@ -70,7 +70,6 @@ import org.openhab.core.thing.ThingStatus;
|
||||
import org.openhab.core.thing.ThingStatusDetail;
|
||||
import org.openhab.core.thing.ThingStatusInfo;
|
||||
import org.openhab.core.thing.ThingUID;
|
||||
import org.openhab.core.thing.binding.ThingHandler;
|
||||
import org.openhab.core.thing.binding.builder.BridgeBuilder;
|
||||
import org.openhab.core.thing.binding.builder.ChannelBuilder;
|
||||
import org.openhab.core.thing.binding.builder.ThingBuilder;
|
||||
@ -154,7 +153,6 @@ public class ModbusDataHandlerTest extends AbstractModbusOSGiTest {
|
||||
}
|
||||
|
||||
private Bridge createTcpMock() {
|
||||
ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502, false);
|
||||
Bridge tcpBridge = ModbusPollerThingHandlerTest.createTcpThingBuilder("tcp1").build();
|
||||
ModbusTcpThingHandler tcpThingHandler = Mockito.mock(ModbusTcpThingHandler.class);
|
||||
tcpBridge.setStatusInfo(new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, ""));
|
||||
@ -824,7 +822,6 @@ public class ModbusDataHandlerTest extends AbstractModbusOSGiTest {
|
||||
assertThat(dataHandler.getThing().getStatus(), is(equalTo(ThingStatus.ONLINE)));
|
||||
|
||||
verify(comms, never()).submitOneTimePoll(eq(request), notNull(), notNull());
|
||||
ModbusPollerThingHandler handler = (ModbusPollerThingHandler) poller.getHandler();
|
||||
// Wait for all channels to receive the REFRESH command (initiated by the core)
|
||||
waitForAssert(
|
||||
() -> verify((ModbusPollerThingHandler) poller.getHandler(), times(CHANNEL_TO_ACCEPTED_TYPE.size()))
|
||||
@ -854,7 +851,6 @@ public class ModbusDataHandlerTest extends AbstractModbusOSGiTest {
|
||||
Bridge parent;
|
||||
if (pollerFunctionCode == null) {
|
||||
parent = createTcpMock();
|
||||
ThingHandler foo = parent.getHandler();
|
||||
addThing(parent);
|
||||
} else {
|
||||
ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502, false);
|
||||
|
@ -16,7 +16,6 @@ import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
import org.openhab.binding.wemo.internal.WemoBindingConstants;
|
||||
import org.openhab.binding.wemo.internal.handler.AbstractWemoHandler;
|
||||
import org.openhab.core.config.core.Configuration;
|
||||
import org.openhab.core.thing.Bridge;
|
||||
import org.openhab.core.thing.Channel;
|
||||
@ -25,7 +24,6 @@ import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingStatus;
|
||||
import org.openhab.core.thing.ThingTypeUID;
|
||||
import org.openhab.core.thing.ThingUID;
|
||||
import org.openhab.core.thing.binding.ThingHandler;
|
||||
import org.openhab.core.thing.binding.builder.BridgeBuilder;
|
||||
import org.openhab.core.thing.binding.builder.ChannelBuilder;
|
||||
import org.openhab.core.thing.binding.builder.ThingBuilder;
|
||||
@ -85,12 +83,6 @@ public class GenericWemoLightOSGiTestParent extends GenericWemoOSGiTest {
|
||||
.withBridge(bridgeUID).build();
|
||||
|
||||
managedThingProvider.add(thing);
|
||||
|
||||
ThingHandler handler = thing.getHandler();
|
||||
if (handler != null) {
|
||||
AbstractWemoHandler h = (AbstractWemoHandler) handler;
|
||||
}
|
||||
|
||||
return thing;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user