Skip to content

Commit

Permalink
Fix SAT NoEmptyLineSeparatorCheck findings (openhab#7296)
Browse files Browse the repository at this point in the history
* Fix SAT NoEmptyLineSeparatorCheck findings
* Fix sloppy coding and fragile comment

Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: CSchlipp <christian@schlipp.de>
  • Loading branch information
wborn authored and CSchlipp committed Jul 26, 2020
1 parent d0e2c00 commit 162fac0
Show file tree
Hide file tree
Showing 251 changed files with 281 additions and 730 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ private void msgLoop() {
cancelCommands();
hubControllerConnected.cancel(false);
logger.info("Exiting hub controller");

}

private boolean shouldStop() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ private AirQualityJsonResponse getAirQualityData() {
errorMsg = "missing data sub-object";
logger.warn("Error in aqicn.org (Air Quality) response: {}", errorMsg);
}

} catch (MalformedURLException e) {
errorMsg = e.getMessage();
logger.warn("Constructed url is not valid: {}", errorMsg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public class AllPlayBindingProperties {
private static final String ZONE_MEMBER_SEPARATOR_DEFAULT_VALUE = ",";

public AllPlayBindingProperties(Dictionary<String, Object> properties) {

rewindSkipTimeInSec = getIntegerProperty(properties, REWIND_SKIP_TIME_PROPERTY, REWIND_SKIP_TIME_DEFAULT_VALUE);
fastForwardSkipTimeInSec = getIntegerProperty(properties, FAST_FORWARD_SKIP_TIME_PROPERTY,
FAST_FORWARD_SKIP_TIME_DEFAULT_VALUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ protected void doGet(@Nullable HttpServletRequest req, @Nullable HttpServletResp
try {
Connection connection = this.connectionToInitialize;
if (uri.startsWith(FORWARD_URI_PART) && connection != null) {

String getUrl = "https://www." + connection.getAmazonSite() + "/"
+ uri.substring(FORWARD_URI_PART.length());

Expand All @@ -271,7 +270,6 @@ protected void doGet(@Nullable HttpServletRequest req, @Nullable HttpServletResp
}

if (connection != null && connection.verifyLogin()) {

// handle commands
if (baseUrl.equals("/logout") || baseUrl.equals("/logout/")) {
this.connectionToInitialize = reCreateConnection();
Expand Down Expand Up @@ -633,7 +631,6 @@ void handleProxyRequest(Connection connection, HttpServletResponse resp, String
{
String location = urlConnection.getHeaderField("location");
if (location.contains("/ap/maplanding")) {

try {
connection.registerConnectionAsApp(location);
account.setConnection(connection);
Expand All @@ -646,7 +643,6 @@ void handleProxyRequest(Connection connection, HttpServletResponse resp, String
this.connectionToInitialize = null;
return;
}

}

String startString = "https://www." + connection.getAmazonSite() + "/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ public boolean tryRestoreLogin(@Nullable String data, @Nullable String overloade
} catch (IOException e) {
return false;
} catch (URISyntaxException e) {

}
}
return false;
Expand Down Expand Up @@ -539,7 +538,6 @@ public HttpsURLConnection makeRequest(String verb, String url, @Nullable String
URI uri = connection.getURL().toURI();

if (customHeaders == null || !customHeaders.containsKey("Cookie")) {

StringBuilder cookieHeaderBuilder = new StringBuilder();
for (HttpCookie cookie : cookieManager.getCookieStore().get(uri)) {
if (cookieHeaderBuilder.length() > 0) {
Expand All @@ -559,7 +557,6 @@ public HttpsURLConnection makeRequest(String verb, String url, @Nullable String
}
}
if (postData != null) {

logger.debug("{}: {}", verb, postData);
// post data
byte[] postDataBytes = postData.getBytes(StandardCharsets.UTF_8);
Expand Down Expand Up @@ -595,7 +592,6 @@ public HttpsURLConnection makeRequest(String verb, String url, @Nullable String
// store cookie
for (String cookieHeader : header.getValue()) {
if (StringUtils.isNotEmpty(cookieHeader)) {

List<HttpCookie> cookies = HttpCookie.parse(cookieHeader);
for (HttpCookie cookie : cookies) {
cookieManager.getCookieStore().add(uri, cookie);
Expand Down Expand Up @@ -646,9 +642,7 @@ public HttpsURLConnection makeRequest(String verb, String url, @Nullable String
return connection;
}
throw new HttpException(code, verb + " url '" + url + "' failed: " + connection.getResponseMessage());

} catch (IOException e) {

if (connection != null) {
connection.disconnect();
}
Expand Down Expand Up @@ -753,7 +747,6 @@ public String registerConnectionAsApp(String oAutRedirectUrl)
}

private void exchangeToken() throws IOException, URISyntaxException {

this.renewTime = 0;
String cookiesJson = "{\"cookies\":{\"." + getAmazonSite() + "\":[]}}";
String cookiesBase64 = Base64.getEncoder().encodeToString(cookiesJson.getBytes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ public void onWebSocketBinary(byte @Nullable [] data, int offset, int len) {
sendMessage(
"0xa6f6a951 0x0000009c {\"protocolName\":\"A:H\",\"parameters\":{\"AlphaProtocolHandler.receiveWindowSize\":\"16\",\"AlphaProtocolHandler.maxFragmentSize\":\"16000\"}}TUNE");
sendMessage(encodeGWHandshake());

} else if (this.msgCounter == 1) {
sendMessage(encodeGWRegister());
sendPing();
Expand All @@ -395,7 +394,6 @@ public void onWebSocketBinary(byte @Nullable [] data, int offset, int len) {
Message message = parseIncomingMessage(buffer);
if (message.service.equals("FABE") && message.content.messageType.equals("PON")
&& message.content.payloadData.length > 0) {

logger.debug("Pong received");
WebSocketConnection.this.clearPongTimeoutTimer();
return;
Expand All @@ -416,7 +414,6 @@ public void onWebSocketBinary(byte @Nullable [] data, int offset, int len) {

@Override
public void onWebSocketText(@Nullable String message) {

}

@Override
Expand Down Expand Up @@ -464,7 +461,6 @@ long computeBits(long input, long len) {
}

long toUnsignedInt(long value) {

long result = value;
if (0 > value) {
result = 4294967295L + value + 1;
Expand Down Expand Up @@ -559,7 +555,6 @@ void encode(byte[] data, long b, int offset, int len) {
}

byte[] encodePing() {

// MSG 0x00000065 0x0e414e47 f 0x00000001 0xbc2fbb5f 0x00000062 PIN� ��� ��RegularFABE
this.messageId++;
String msg = "MSG 0x00000065 "; // Message-type and Channel = CHANNEL_FOR_HEARTBEAT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ public synchronized void discoverFlashBriefingProfiles(String currentFlashBriefi
}

if (!discoverdFlashBriefings.contains(currentFlashBriefingJson)) {

ThingUID freeThingUID = null;
int freeIndex = 0;
for (int i = 1; i < 1000; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ private void checkLogin() {
setConnection(currentConnection);
}
} else {

// read session data from property
String sessionStore = this.stateStorage.get("sessionStorage");

Expand Down Expand Up @@ -582,7 +581,6 @@ private void refreshData() {
}

public List<Device> updateDeviceList() {

Connection currentConnection = connection;
if (currentConnection == null) {
return new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ public void handleCommand(ChannelUID channelUID, Command command) {
// Media progress commands
Long mediaPosition = null;
if (channelId.equals(CHANNEL_MEDIA_PROGRESS)) {

if (command instanceof PercentType) {
PercentType value = (PercentType) command;
int percent = value.intValue();
Expand Down Expand Up @@ -356,18 +355,15 @@ public void handleCommand(ChannelUID channelUID, Command command) {
mediaStartMs = System.currentTimeMillis() - this.mediaProgressMs;
updateMediaProgress(false);
}

}
// Volume commands
if (channelId.equals(CHANNEL_VOLUME)) {
Integer volume = null;
if (command instanceof PercentType) {
PercentType value = (PercentType) command;
volume = value.intValue();

} else if (command == OnOffType.OFF) {
volume = 0;

} else if (command == OnOffType.ON) {
volume = lastKnownVolume;
} else if (command == IncreaseDecreaseType.INCREASE) {
Expand All @@ -385,7 +381,6 @@ public void handleCommand(ChannelUID channelUID, Command command) {
if (StringUtils.equals(device.deviceFamily, "WHA")) {
connection.command(device, "{\"type\":\"VolumeLevelCommand\",\"volumeLevel\":" + volume
+ ",\"contentFocusClientId\":\"Default\"}");

} else {
Map<String, Object> parameters = new HashMap<>();
parameters.put("value", volume);
Expand All @@ -395,7 +390,6 @@ public void handleCommand(ChannelUID channelUID, Command command) {
updateState(CHANNEL_VOLUME, new PercentType(lastKnownVolume));
waitForUpdate = -1;
}

}
// equalizer commands
if (channelId.equals(CHANNEL_EQUALIZER_BASS) || channelId.equals(CHANNEL_EQUALIZER_MIDRANGE)
Expand Down Expand Up @@ -427,7 +421,6 @@ public void handleCommand(ChannelUID channelUID, Command command) {
waitForUpdate = 3000;
}
}

}
}
if (channelId.equals(CHANNEL_PLAY_MUSIC_VOICE_COMMAND)) {
Expand Down Expand Up @@ -485,28 +478,23 @@ public void handleCommand(ChannelUID channelUID, Command command) {
// amazon music commands
if (channelId.equals(CHANNEL_AMAZON_MUSIC_TRACK_ID)) {
if (command instanceof StringType) {

String trackId = ((StringType) command).toFullString();
if (StringUtils.isNotEmpty(trackId)) {
waitForUpdate = 3000;
}
connection.playAmazonMusicTrack(device, trackId);

}
}
if (channelId.equals(CHANNEL_AMAZON_MUSIC_PLAY_LIST_ID)) {
if (command instanceof StringType) {

String playListId = ((StringType) command).toFullString();
if (StringUtils.isNotEmpty(playListId)) {
waitForUpdate = 3000;
}
connection.playAmazonMusicPlayList(device, playListId);

}
}
if (channelId.equals(CHANNEL_AMAZON_MUSIC)) {

if (command == OnOffType.ON) {
String lastKnownAmazonMusicId = this.lastKnownAmazonMusicId;
if (StringUtils.isNotEmpty(lastKnownAmazonMusicId)) {
Expand Down Expand Up @@ -575,7 +563,6 @@ public void handleCommand(ChannelUID channelUID, Command command) {
currentNotifcationUpdateTimer = scheduler.scheduleWithFixedDelay(() -> {
updateNotificationTimerState();
}, 1, 1, TimeUnit.SECONDS);

}
}
}
Expand Down Expand Up @@ -718,7 +705,6 @@ private boolean handleEqualizerCommands(String channelId, Command command, Conne
logger.debug("Update equalizer failed", e);
this.lastKnownEqualizer = null;
}

}
}
return false;
Expand Down Expand Up @@ -935,7 +921,6 @@ public void updateState(AccountHandler accountHandler, @Nullable Device device,
} else {
stopProgressTimer();
}

} else {
stopProgressTimer();
mediaProgressMs = 0;
Expand All @@ -947,17 +932,13 @@ public void updateState(AccountHandler accountHandler, @Nullable Device device,

JsonMediaState mediaState = null;
try {

if (StringUtils.equalsIgnoreCase(musicProviderId, "AMAZON_MUSIC")
|| StringUtils.equalsIgnoreCase(musicProviderId, "TUNEIN")) {
mediaState = connection.getMediaState(device);
}

} catch (HttpException e) {
if (e.getCode() == 400) {

updateState(CHANNEL_RADIO_STATION_ID, new StringType(""));

} else {
logger.info("getMediaState fails", e);
}
Expand Down Expand Up @@ -1053,7 +1034,6 @@ public void updateState(AccountHandler accountHandler, @Nullable Device device,
if (queueEntries != null && queueEntries.length > 0) {
QueueEntry entry = queueEntries[0];
if (entry != null) {

if (isRadio) {
if (StringUtils.isEmpty(imageUrl) && entry.imageURL != null) {
imageUrl = entry.imageURL;
Expand Down Expand Up @@ -1087,7 +1067,6 @@ public void updateState(AccountHandler accountHandler, @Nullable Device device,
volume = mediaState.volume;
}
if (playerInfo != null && volume == null) {

Volume volumnInfo = playerInfo.volume;
if (volumnInfo != null) {
volume = volumnInfo.volume;
Expand Down Expand Up @@ -1155,7 +1134,6 @@ public void updateState(AccountHandler accountHandler, @Nullable Device device,
} else {
updateState(CHANNEL_NOTIFICATION_VOLUME, UnDefType.UNDEF);
}

} catch (Exception e) {
this.logger.debug("Handle updateState {} failed: {}", this.getThing().getUID(), e.getMessage(), e);

Expand Down Expand Up @@ -1199,7 +1177,6 @@ private void updateEqualizerState() {
if (treble != null) {
updateState(CHANNEL_EQUALIZER_TREBLE, new DecimalType(treble));
}

}

private void updateMediaProgress() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public void statusChanged(ThingStatus status, ThingStatusDetail detail, String m
}
// If we got this far - call the underlying one
wrappedCallback.statusChanged(status, detail, msg);

}

/**
Expand Down Expand Up @@ -108,7 +107,6 @@ public void stateChanged(String channelId, State state) {
// Something changed - save the new state and call the underlying wrapped
this.state.put(channelId, state);
wrappedCallback.stateChanged(channelId, state);

}

/**
Expand All @@ -133,7 +131,6 @@ public void removeState(String channelId) {
@Override
public void setProperty(String propertyName, String propertyValue) {
wrappedCallback.setProperty(propertyName, propertyValue);

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,16 @@ private enum BlueGigaProcedure {
private @Nullable ScheduledFuture<?> procedureTimer;

private Runnable connectTimeoutTask = new Runnable() {

@Override
public void run() {
if (connectionState == ConnectionState.CONNECTING) {
logger.debug("Connection timeout for device {}", address);
connectionState = ConnectionState.DISCONNECTED;
}

}
};

private Runnable procedureTimeoutTask = new Runnable() {

@Override
public void run() {
logger.debug("Procedure {} timeout for device {}", procedureProgress, address);
Expand Down Expand Up @@ -248,7 +245,6 @@ else if (event instanceof BlueGigaAttributeValueEvent) {
}

private void handleScanEvent(BlueGigaScanResponseEvent event) {

// Check if this is addressed to this device
if (!address.equals(new BluetoothAddress(event.getSender()))) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,6 @@ private boolean bgStartScanning(boolean active, int interval, int window) {
*/
private <T extends BlueGigaResponse> T sendCommand(BlueGigaCommand command, Class<T> expectedResponse,
boolean schedulePassiveScan) throws BlueGigaException {

if (!initComplete) {
throw new BlueGigaException("BlueGiga not initialized");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,6 @@ public boolean hasListeners() {
*
*/
protected void dispose() {

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ public boolean equals(@Nullable Object obj) {
* @return true if this snapshot changed as a result of this operation
*/
public void merge(BluetoothDevice device) {

Integer txPower = device.getTxPower();
Integer manufacturer = device.getManufacturerId();
String name = device.getName();
Expand Down
Loading

0 comments on commit 162fac0

Please sign in to comment.