Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce SAT warnings #4567

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,38 +89,22 @@ public boolean isSatisfied(Map<String, @Nullable Object> context) {
case "GT":
case ">":
// Greater
if (toCompare == null) {
return false;
} else {
return compare(toCompare, rightValue) > 0;
}
return (toCompare != null) && (compare(toCompare, rightValue) > 0);
case "gte":
case "GTE":
case ">=":
case "=>":
// Greater or equal
if (toCompare == null) {
return false;
} else {
return compare(toCompare, rightValue) >= 0;
}
return (toCompare != null) && (compare(toCompare, rightValue) >= 0);
case "lt":
case "LT":
case "<":
if (toCompare == null) {
return false;
} else {
return compare(toCompare, rightValue) < 0;
}
return (toCompare != null) && (compare(toCompare, rightValue) < 0);
case "lte":
case "LTE":
case "<=":
case "=<":
if (toCompare == null) {
return false;
} else {
return compare(toCompare, rightValue) <= 0;
}
return (toCompare != null) && (compare(toCompare, rightValue) <= 0);
case "matches":
// Matcher...
if (toCompare instanceof String string1 && rightValue instanceof String string2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.time.Instant;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.thing.profiles.ProfileCallback;
import org.openhab.core.thing.profiles.ProfileContext;
Expand Down Expand Up @@ -63,10 +62,6 @@ public TimestampOffsetProfile(ProfileCallback callback, ProfileContext context)
}
}

private @Nullable String toStringOrNull(@Nullable Object value) {
return value == null ? null : value.toString();
}

@Override
public ProfileTypeUID getProfileTypeUID() {
return SystemProfiles.TIMESTAMP_OFFSET;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class ThreadedEventHandler implements Closeable {
logger.trace("inspect event: {}", event);
if (event == null) {
logger.debug("Hey, you have really very few events.");
} else if (event.equals(notifyEvent)) {
} else if (event.equals(notifyEvent)) { // NOPMD
// received an internal notification
} else {
worker.handleEvent(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ public AssertingThread(Runnable runnable) {
@Override
public void run() {
try {
super.run();
super.run(); // NOPMD
} catch (AssertionError e) {
AssertingThread.this.assertionError = e;
} catch (RuntimeException e) {
Expand Down
7 changes: 2 additions & 5 deletions tools/static-code-analysis/pmd/suppressions.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
org.openhab.core.common.registry.AbstractRegistry=AvoidCatchingThrowable
org.openhab.core.internal.common.SafeCallManagerImpl=CompareObjectsWithEquals
org.openhab.core.internal.events.ThreadedEventHandler=CompareObjectsWithEquals
org.openhab.core.internal.events.ThreadedEventHandler=EmptyIfStmt
org.openhab.core.thing.internal.ChannelItemProvider=CompareObjectsWithEquals
org.openhab.core.thing.internal.ThingManager=CompareObjectsWithEquals
org.openhab.core.io.console.karaf.internal.OSGiConsole=SystemPrintln
org.openhab.core.io.console.rfc147.internal.CommandWrapper=SystemPrintln
org.openhab.core.io.console.rfc147.internal.OSGiConsole=SystemPrintln
org.openhab.core.io.net.http.internal.SecureHttpClientFactory=AvoidThrowingRawExceptionTypes
org.openhab.core.io.transport.modbus.internal.ModbusManagerImpl=MoreThanOneLogger
org.openhab.core.model.core.internal.ModelRepositoryImpl=AvoidCatchingNPE
org.openhab.core.model.script.interpreter.ScriptInterpreter=AvoidCatchingThrowable
org.openhab.core.ui.internal.proxy.ProxyServletService=AvoidCatchingThrowable
Expand All @@ -16,3 +12,4 @@ org.openhab.core.automation.internal.RuleRegistryImpl=CompareObjectsWithEquals
org.openhab.core.automation.internal.provider.AutomationResourceBundlesEventQueue=AvoidCatchingThrowable
org.openhab.core.io.console.karaf.internal.InstallServiceCommand=SystemPrintln
org.openhab.core.common.PoolBasedSequentialScheduledExecutorService=CompareObjectsWithEquals
org.openhab.core.tools.UpgradeTool=SystemPrintln