]> git.basschouten.com Git - openhab-addons.git/commitdiff
Remove unused local variables (#10528)
authorWouter Born <github@maindrain.net>
Fri, 16 Apr 2021 20:35:01 +0000 (22:35 +0200)
committerGitHub <noreply@github.com>
Fri, 16 Apr 2021 20:35:01 +0000 (22:35 +0200)
Fixes 26 SAT UnusedLocalVariable findings

Signed-off-by: Wouter Born <github@maindrain.net>
20 files changed:
bundles/org.openhab.binding.bluetooth.daikinmadoka/src/test/java/org/openhab/binding/bluetooth/daikinmadoka/internal/MadokaMessageTest.java
bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/handler/DaikinBaseHandler.java
bundles/org.openhab.binding.fsinternetradio/src/main/java/org/openhab/binding/fsinternetradio/internal/FSInternetRadioDiscoveryParticipant.java
bundles/org.openhab.binding.hdanywhere/src/main/java/org/openhab/binding/hdanywhere/internal/handler/Mhub4K431Handler.java
bundles/org.openhab.binding.helios/src/main/java/org/openhab/binding/helios/internal/handler/HeliosHandler27.java
bundles/org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal/manager/DeviceStructureManager.java
bundles/org.openhab.binding.irtrans/src/main/java/org/openhab/binding/irtrans/internal/handler/EthernetBridgeHandler.java
bundles/org.openhab.binding.keba/src/main/java/org/openhab/binding/keba/internal/handler/KeContactTransceiver.java
bundles/org.openhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/handler/MieleApplianceHandler.java
bundles/org.openhab.binding.modbus/src/test/java/org/openhab/binding/modbus/internal/AtomicStampedKeyValueTest.java
bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/AbstractBrokerHandler.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyComponents.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/manager/ShellyManagerActionPage.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/manager/ShellyManagerCache.java
bundles/org.openhab.binding.valloxmv/src/main/java/org/openhab/binding/valloxmv/internal/ValloxMVWebSocket.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/mocks/DummyItemRegistry.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/mocks/DummyMetadataRegistry.java
bundles/org.openhab.io.hueemulation/src/test/java/org/openhab/io/hueemulation/internal/rest/mocks/DummyRuleRegistry.java
itests/org.openhab.binding.modbus.tests/src/main/java/org/openhab/binding/modbus/tests/ModbusDataHandlerTest.java
itests/org.openhab.binding.wemo.tests/src/main/java/org/openhab/binding/wemo/internal/test/GenericWemoLightOSGiTestParent.java

index 0ee0f245f647ce2785315ec931a4aaeaa98477a3..bbe06711e3b80465a26fa93e290e823268f98518 100644 (file)
@@ -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);
     }
index cd6dd74ee458243b4c185405de26ba441ad11300..76357e4803d9056ddbb078aa94c5a9ce1751e822 100644 (file)
@@ -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 {
index dd4d8b9fce20212989ff99d5b675a58e27e474dc..32dcfe40fcee5d485ad6c0666c108ccde47b1605 100644 (file)
@@ -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);
                             }
                         }
                     }
index 79b114d45698ddeea167a2236f47b79a51253ba7..9ea81044c0309181ada68a579fb213c65cc0fa2b 100644 (file)
@@ -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);
index abf829d93b23f069610d487beafd949a99b8706b..25c12aab361406e7acd4b90ff896731233b540a9 100644 (file)
@@ -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) {
index 5be3b1dee877a2b70d17a038149a5fea70bf76cc..da4d5f3238548a323fc4809f588589846435dc40 100644 (file)
@@ -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)");
                         }
                     }
index 4e0aae384e9c47811dc0b5f9eddbee813825c87b..4992ebc34b27325118cf29310319f343a329dc31 100644 (file)
@@ -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);
         }
 
index 61139dfe0f3a17f1d35a80d0286fae286b1533be..df21760ce8f5c08f6207db9ddf2195da168d409e 100644 (file)
@@ -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,
index b3ba33c1969cf4f1c048d3693d7143f83dc6edcf..560eed510e17ca7f169a2364bdd4f29f62da3955 100644 (file)
@@ -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
-                    }
-                }
             }
         }
     }
index 9eca1d4cc5dd43ccb5a3430c559825ed77a281bb..fd7658a05a00b984443d0b0001cde27bf63470eb 100644 (file)
@@ -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);
 
index 52381ba11fa7c3878d9f9696446eebfe3b6f9822..dc5dbb3fa8590fcdc5c2c2726d13244741260ae9 100644 (file)
@@ -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;
+        });
     }
 
     /**
index fa0cc1333571210717cef836312ae0089a259a28..8b8ab9d9b338b9b4cef02ba8d62519110786c33c 100644 (file)
@@ -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) {
index 927fbe6cbe2fe0099e3904d611bd690a087e34e8..38ede361c61fdb65d2a3cc934438adefd7a8f8d5 100644 (file)
@@ -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());
index 5af3e0fb8e51371580b7e6d5de8814e546a57ee8..9655e9dbec796991950c3110de23afcf34581ead 100644 (file)
@@ -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);
                 }
             }
index 13a29228317f1b1b0a1832dce410744c3949479e..62f0adbb8fa73606ad0da921fed9696e668868a2 100644 (file)
@@ -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);
index 88cab2eb21d2b0dbb0e939b9758c5e00b3570eb8..f83200c9979ad27a9866e2e0dae9dec48734e3f8 100644 (file)
@@ -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);
         }
index b61b85c7b7876d47fc53aa6b62efc53e3f5668d9..b6a3125483a7f4173315edcb8f8178c4cd77ad8b 100644 (file)
@@ -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);
         }
index 740dc341428b3965ad285a31cfd2ea20a2ba880e..a270687305a048c2731fe27f098051e7bf446646 100644 (file)
@@ -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);
         }
index 5cd510e099aaea14d4ee50f27e9762178bf25929..1f3cf38aa6f67d985851a150a166e006437fbd6c 100644 (file)
@@ -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);
index 86e5a824cee3b1192dce07269b95948b56b4aaa6..b23e8f77ddf90d8366e01e04aa8d121cc31ccc5c 100644 (file)
@@ -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;
     }