Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Fixed issues found by Static Code Analysis Tool (few checks) (#5086)
Browse files Browse the repository at this point in the history
Signed-off-by: Kristina S. Simova <kssimovaa@gmail.com>
  • Loading branch information
kssimova authored and maggu2810 committed Feb 19, 2018
1 parent 9c6e980 commit 3f65c8a
Show file tree
Hide file tree
Showing 38 changed files with 134 additions and 110 deletions.
Expand Up @@ -26,7 +26,7 @@
* @author Yordan Mihaylov - Initial Contribution
* @author Ana Dimova - Initial Contribution
* @author Vasil Ilchev - Initial Contribution
* @param <T>
* @param <E>
*/
public interface TemplateRegistry<E extends Template> extends Registry<E, String> {

Expand Down
Expand Up @@ -10,4 +10,4 @@ Import-Package:
org.eclipse.jdt.annotation;resolution:=optional,
org.eclipse.smarthome.automation,
org.eclipse.smarthome.test.storage
Require-Bundle: org.junit;bundle-version="4.8.1"
Require-Bundle: org.junit
@@ -1,6 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse SmartHome Automation Core
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.eclipse.smarthome.automation.core
Bundle-Vendor: Eclipse.org/SmartHome
Bundle-Version: 0.10.0.qualifier
Expand Down
Expand Up @@ -33,11 +33,11 @@ Import-Package:
org.osgi.framework,
org.osgi.service.event,
org.osgi.util.tracker,
org.slf4j;version="1.7.2"
org.slf4j
Require-Bundle:
org.eclipse.smarthome.automation.api,
org.eclipse.smarthome.automation.core,
org.eclipse.smarthome.automation.module.core,
org.eclipse.smarthome.automation.parser.gson,
org.eclipse.smarthome.automation.providers,
org.junit;bundle-version="4.0.0"
org.junit
Expand Up @@ -37,7 +37,7 @@ Import-Package:
org.osgi.service.event,
org.osgi.service.packageadmin,
org.osgi.util.tracker,
org.slf4j;version="1.7.2"
org.slf4j
Require-Bundle:
org.eclipse.smarthome.automation.api,
org.eclipse.smarthome.automation.core,
Expand All @@ -46,4 +46,4 @@ Require-Bundle:
org.eclipse.smarthome.automation.providers,
org.eclipse.smarthome.automation.sample.extension.json,
org.eclipse.smarthome.io.console,
org.junit;bundle-version="4.0.0"
org.junit
Expand Up @@ -29,4 +29,4 @@ Require-Bundle:
org.eclipse.smarthome.automation.module.core,
org.eclipse.smarthome.automation.parser.gson,
org.eclipse.smarthome.automation.providers,
org.junit;bundle-version="4.0.0"
org.junit
Expand Up @@ -25,5 +25,5 @@ Import-Package:
org.osgi.framework,
org.osgi.service.component,
org.osgi.util.tracker,
org.slf4j;version="1.7.2"
org.slf4j
Service-Component: OSGI-INF/*.xml
Expand Up @@ -35,12 +35,12 @@ Import-Package:
org.osgi.framework,
org.osgi.service.event,
org.osgi.util.tracker,
org.slf4j;version="1.7.2"
org.slf4j
Require-Bundle:
org.eclipse.smarthome.automation.api,
org.eclipse.smarthome.automation.core,
org.eclipse.smarthome.automation.module.core,
org.eclipse.smarthome.automation.module.timer,
org.eclipse.smarthome.automation.parser.gson,
org.eclipse.smarthome.automation.providers,
org.junit;bundle-version="4.0.0"
org.junit
Expand Up @@ -22,4 +22,4 @@ Import-Package:
org.eclipse.smarthome.config.core,
org.eclipse.smarthome.core.scheduler,
org.osgi.framework,
org.slf4j;version="1.7.2"
org.slf4j
Expand Up @@ -91,7 +91,7 @@ public AutomationResourceBundlesEventQueue(AbstractResourceBundleProvider<E> pro
public void run() {
boolean waitForEvents = true;
while (true) {
List<BundleEvent> l_queue = null;
List<BundleEvent> lQueue = null;
synchronized (this) {
if (closed) {
notifyAll();
Expand All @@ -111,10 +111,10 @@ public void run() {
notifyAll();
return;
}
l_queue = queue;
lQueue = queue;
shared = true;
}
Iterator<BundleEvent> events = l_queue.iterator();
Iterator<BundleEvent> events = lQueue.iterator();
while (events.hasNext()) {
BundleEvent event = events.next();
try {
Expand Down
@@ -1,6 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse SmartHome Automation Sample Extension Java - Welcome Home Application
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.eclipse.smarthome.automation.sample.extension.java
Bundle-Activator: org.eclipse.smarthome.automation.sample.extension.java.internal.Activator
Bundle-Version: 0.10.0.qualifier
Expand Down
Expand Up @@ -20,5 +20,5 @@ Import-Package:
org.eclipse.smarthome.io.console.extensions,
org.osgi.framework,
org.osgi.service.event,
org.osgi.util.tracker;version="1.4.0",
org.osgi.util.tracker,
org.slf4j
Expand Up @@ -3,6 +3,7 @@ Automation-ResourceType: json
Bundle-ClassPath: .
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse SmartHome Automation Json Demo
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.eclipse.smarthome.automation.sample.json.demo
Bundle-Vendor: Bosch Software Innovations GmbH
Bundle-Version: 0.10.0.qualifier
Expand Down
@@ -1,6 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse SmartHome Automation Module Type Demo
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.eclipse.smarthome.automation.sample.moduletype.
demo
Bundle-Vendor: Bosch Software Innovations GmbH
Expand Down
Expand Up @@ -100,8 +100,8 @@ private InputStream createInputStream() throws AudioException {
shoutCastSocket = new Socket(streamUrl.getHost(), port);

OutputStream os = shoutCastSocket.getOutputStream();
String user_agent = "WinampMPEG/5.09";
String req = "GET / HTTP/1.0\r\nuser-agent: " + user_agent
String userAgent = "WinampMPEG/5.09";
String req = "GET / HTTP/1.0\r\nuser-agent: " + userAgent
+ "\r\nIcy-MetaData: 1\r\nConnection: keep-alive\r\n\r\n";
os.write(req.getBytes());
return shoutCastSocket.getInputStream();
Expand Down
Expand Up @@ -56,6 +56,7 @@ Import-Package:
org.eclipse.smarthome.core.thing.link,
org.eclipse.smarthome.core.thing.link.dto,
org.eclipse.smarthome.core.thing.link.events,
org.eclipse.smarthome.core.thing.profiles,
org.eclipse.smarthome.core.thing.type,
org.eclipse.smarthome.core.thing.util,
org.eclipse.smarthome.core.types,
Expand Down
Expand Up @@ -218,7 +218,7 @@ public PercentType[] toRGB() {
BigDecimal h = hue.divide(BigDecimal.valueOf(100), 10, BigDecimal.ROUND_HALF_UP);
BigDecimal s = saturation.divide(BigDecimal.valueOf(100));

int h_int = h.multiply(BigDecimal.valueOf(5)).divide(BigDecimal.valueOf(3), 10, BigDecimal.ROUND_HALF_UP)
int hInt = h.multiply(BigDecimal.valueOf(5)).divide(BigDecimal.valueOf(3), 10, BigDecimal.ROUND_HALF_UP)
.intValue();
BigDecimal f = h.multiply(BigDecimal.valueOf(5)).divide(BigDecimal.valueOf(3), 10, BigDecimal.ROUND_HALF_UP)
.remainder(BigDecimal.ONE);
Expand All @@ -227,32 +227,40 @@ public PercentType[] toRGB() {
PercentType c = new PercentType(
value.multiply(BigDecimal.ONE.subtract((BigDecimal.ONE.subtract(f)).multiply(s))));

if (h_int == 0 || h_int == 6) {
red = getBrightness();
green = c;
blue = a;
} else if (h_int == 1) {
red = b;
green = getBrightness();
blue = a;
} else if (h_int == 2) {
red = a;
green = getBrightness();
blue = c;
} else if (h_int == 3) {
red = a;
green = b;
blue = getBrightness();
} else if (h_int == 4) {
red = c;
green = a;
blue = getBrightness();
} else if (h_int == 5) {
red = getBrightness();
green = a;
blue = b;
} else {
throw new RuntimeException();
switch (hInt) {
case 0:
case 6:
red = getBrightness();
green = c;
blue = a;
break;
case 1:
red = b;
green = getBrightness();
blue = a;
break;
case 2:
red = a;
green = getBrightness();
blue = c;
break;
case 3:
red = a;
green = b;
blue = getBrightness();
break;
case 4:
red = c;
green = a;
blue = getBrightness();
break;
case 5:
red = getBrightness();
green = a;
blue = b;
break;
default:
throw new RuntimeException();
}
return new PercentType[] { red, green, blue };
}
Expand Down
Expand Up @@ -124,14 +124,14 @@ public synchronized void modified(Map<String, Object> config) {
}
final Enumeration<InetAddress> addresses = current.getInetAddresses();
while (addresses.hasMoreElements()) {
final InetAddress current_addr = addresses.nextElement();
if (current_addr.isLoopbackAddress() || (current_addr instanceof Inet6Address)) {
final InetAddress currentAddr = addresses.nextElement();
if (currentAddr.isLoopbackAddress() || (currentAddr instanceof Inet6Address)) {
continue;
}
if (hostAddress != null) {
LOGGER.warn("Found multiple local interfaces - ignoring {}", current_addr.getHostAddress());
LOGGER.warn("Found multiple local interfaces - ignoring {}", currentAddr.getHostAddress());
} else {
hostAddress = current_addr.getHostAddress();
hostAddress = currentAddr.getHostAddress();
}
}
}
Expand All @@ -153,14 +153,14 @@ public synchronized void modified(Map<String, Object> config) {
}
final Enumeration<InetAddress> addresses = current.getInetAddresses();
while (addresses.hasMoreElements()) {
final InetAddress current_addr = addresses.nextElement();
if (current_addr.isLoopbackAddress() || (current_addr instanceof Inet6Address)) {
final InetAddress currentAddr = addresses.nextElement();
if (currentAddr.isLoopbackAddress() || (currentAddr instanceof Inet6Address)) {
continue;
}
if (hostAddress != null) {
LOGGER.warn("Found multiple local interfaces - ignoring {}", current_addr.getHostAddress());
LOGGER.warn("Found multiple local interfaces - ignoring {}", currentAddr.getHostAddress());
} else {
hostAddress = current_addr.getHostAddress();
hostAddress = currentAddr.getHostAddress();
}
}
}
Expand Down
Expand Up @@ -13,4 +13,5 @@ Import-Package:
javax.ws.rs.container,
org.eclipse.jdt.annotation;resolution:=optional,
org.eclipse.smarthome.core.auth,
org.eclipse.smarthome.io.rest.auth,
org.slf4j
Expand Up @@ -59,8 +59,10 @@ Import-Package:
org.eclipse.smarthome.core.transform;resolution:=optional,
org.eclipse.smarthome.core.types,
org.eclipse.smarthome.io.rest,
org.eclipse.smarthome.io.rest.core.config,
org.eclipse.smarthome.io.rest.core.item,
org.eclipse.smarthome.io.rest.core.persistence,
org.eclipse.smarthome.io.rest.core.service,
org.eclipse.smarthome.io.rest.core.thing,
org.osgi.framework,
org.osgi.service.cm,
Expand Down
Expand Up @@ -46,7 +46,6 @@
import org.eclipse.smarthome.io.rest.RESTResource;
import org.eclipse.smarthome.io.rest.Stream2JSONInputStream;
import org.eclipse.smarthome.io.rest.core.config.ConfigurationService;
import org.eclipse.smarthome.io.rest.core.internal.service.ConfigurableServiceResource;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
Expand Down
Expand Up @@ -25,6 +25,7 @@ Import-Package:
org.eclipse.smarthome.core.types,
org.eclipse.smarthome.io.rest,
org.eclipse.smarthome.io.rest.core.item,
org.eclipse.smarthome.io.rest.sitemap,
org.eclipse.smarthome.model.core,
org.eclipse.smarthome.model.sitemap,
org.eclipse.smarthome.ui.items,
Expand Down
Expand Up @@ -15,8 +15,8 @@ Import-Package:
io.swagger.annotations;resolution:=optional,
javax.annotation.security;resolution:=optional,
javax.inject,
javax.servlet.http;version="[2.4.0,4.0.0)",
javax.servlet;version="[2.4.0,4.0.0)",
javax.servlet.http,
javax.servlet,
javax.ws.rs,
javax.ws.rs.core,
javax.ws.rs.ext,
Expand Down
Expand Up @@ -14,6 +14,12 @@ Export-Package:
org.freedesktop.dbus,
org.freedesktop.dbus.exceptions
Import-Package:
cx.ath.matthew.debug,
cx.ath.matthew.unix,
cx.ath.matthew.utils,
org.apache.commons.lang,
org.eclipse.jdt.annotation;resolution:=optional,
org.freedesktop,
org.freedesktop.dbus,
org.freedesktop.dbus.exceptions,
org.slf4j
Expand Up @@ -24,6 +24,8 @@ Import-Package:
org.eclipse.paho.client.mqttv3.util,
org.eclipse.smarthome.core.events,
org.eclipse.smarthome.io.transport.mqtt,
org.eclipse.smarthome.io.transport.mqtt.reconnect,
org.eclipse.smarthome.io.transport.mqtt.sslcontext,
org.osgi.service.cm,
org.osgi.service.component,
org.slf4j
Expand Down
Expand Up @@ -16,6 +16,8 @@ Import-Package:
org.apache.commons.lang.reflect,
org.apache.commons.lang.time,
org.eclipse.jdt.annotation;resolution:=optional,
org.eclipse.smarthome.binding.astro,
org.eclipse.smarthome.binding.astro.handler,
org.eclipse.smarthome.config.core,
org.eclipse.smarthome.config.discovery,
org.eclipse.smarthome.core.i18n,
Expand Down
Expand Up @@ -14,23 +14,17 @@

import static org.eclipse.smarthome.binding.astro.AstroBindingConstants.*;

import java.time.ZoneId;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.eclipse.smarthome.binding.astro.handler.AstroThingHandler;
import org.eclipse.smarthome.binding.astro.handler.MoonHandler;
import org.eclipse.smarthome.binding.astro.handler.SunHandler;
import org.eclipse.smarthome.binding.astro.internal.util.PropertyUtils;
import org.eclipse.smarthome.core.i18n.LocationProvider;
import org.eclipse.smarthome.core.i18n.TimeZoneProvider;
import org.eclipse.smarthome.core.library.types.PointType;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.ThingTypeUID;
import org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory;
Expand Down

0 comments on commit 3f65c8a

Please sign in to comment.