sonar优化

This commit is contained in:
redkale
2023-11-13 11:48:51 +08:00
parent ea91894cec
commit af45c451a3
10 changed files with 24 additions and 24 deletions

View File

@@ -46,7 +46,7 @@ public class NodeHttpServer extends NodeServer {
public NodeHttpServer(Application application, AnyValue serconf) {
super(application, createServer(application, serconf));
this.httpServer = (HttpServer) server;
this.rest = serconf == null ? false : serconf.getAnyValue("rest") != null;
this.rest = serconf != null && serconf.getAnyValue("rest") != null;
}

View File

@@ -243,7 +243,7 @@ public class ProtobufWriter extends Writer implements ByteTuple {
}
} else if (type == Boolean[].class) {
for (Boolean item : (Boolean[]) obj) {
tmp.writeBoolean(item == null ? false : item);
tmp.writeBoolean(item != null && item);
}
} else if (type == short[].class) {
for (short item : (short[]) obj) {

View File

@@ -191,7 +191,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
this.defaultAddHeaders = config == null ? null : config.defaultAddHeaders;
this.defaultSetHeaders = config == null ? null : config.defaultSetHeaders;
this.defaultCookie = config == null ? null : config.defaultCookie;
this.autoOptions = config == null ? false : config.autoOptions;
this.autoOptions = config != null && config.autoOptions;
this.dateSupplier = config == null ? null : config.dateSupplier;
this.httpRender = config == null ? null : config.httpRender;

View File

@@ -426,7 +426,7 @@ public final class Rest {
break;
}
}
namePresent = m0 == null ? true : m0.getParameters()[0].isNamePresent();
namePresent = m0 == null || m0.getParameters()[0].isNamePresent();
} catch (Exception e) {
//do nothing
}
@@ -1588,7 +1588,7 @@ public final class Rest {
String urlpath = "";
final String defmodulename = getWebModuleNameLowerCase(serviceType);
final int moduleid = controller == null ? 0 : controller.moduleid();
boolean repair = controller == null ? true : controller.repair();
boolean repair = controller == null || controller.repair();
final String catalog = controller == null ? "" : controller.catalog();
boolean pound = false;
@@ -1651,7 +1651,7 @@ public final class Rest {
tmpEntrysField.set(obj, innerEntryMap);
Field nonblockField = Servlet.class.getDeclaredField("_nonBlocking");
nonblockField.setAccessible(true);
nonblockField.set(obj, parentNonBlocking == null ? true : parentNonBlocking);
nonblockField.set(obj, parentNonBlocking == null || parentNonBlocking);
return obj;
} catch (ClassNotFoundException e) {
//do nothing
@@ -1783,7 +1783,7 @@ public final class Rest {
final int moduleid = controller == null ? 0 : controller.moduleid();
{ //注入 @WebServlet 注解
String urlpath = "";
boolean repair = controller == null ? true : controller.repair();
boolean repair = controller == null || controller.repair();
String comment = controller == null ? "" : controller.comment();
av0 = cw.visitAnnotation(webServletDesc, true);
{
@@ -1886,7 +1886,7 @@ public final class Rest {
break;
}
}
namePresent = m0 == null ? true : m0.getParameters()[0].isNamePresent();
namePresent = m0 == null || m0.getParameters()[0].isNamePresent();
} catch (Exception e) {
//do nothing
}
@@ -3608,7 +3608,7 @@ public final class Rest {
Field nonblockField = Servlet.class.getDeclaredField("_nonBlocking");
nonblockField.setAccessible(true);
nonblockField.set(obj, parentNonBlocking == null ? true : parentNonBlocking);
nonblockField.set(obj, parentNonBlocking == null || parentNonBlocking);
RedkaleClassLoader.putReflectionField(Servlet.class.getName(), nonblockField);
return obj;
} catch (Throwable e) {
@@ -3786,7 +3786,7 @@ public final class Rest {
}
}
}
this.nonBlocking = nonFlag == null ? false : nonFlag;
this.nonBlocking = nonFlag != null && nonFlag;
}
public final int methodIdx; // _paramtypes 的下标从0开始

View File

@@ -36,7 +36,7 @@ public class WebSocketRange implements Serializable {
}
public boolean containsAttach(String key) {
return this.attach == null ? false : this.attach.containsKey(key);
return this.attach != null && this.attach.containsKey(key);
}
public String getAttach(String key) {

View File

@@ -78,7 +78,7 @@ public class SncpRpcGroups {
if (group == null) {
throw new SncpException("Not found group(" + entry.getGroup() + ")");
} else {
return sncpAddress == null ? false : group.containsAddress(sncpAddress);
return sncpAddress != null && group.containsAddress(sncpAddress);
}
}
}

View File

@@ -1677,7 +1677,7 @@ public class DataJdbcSource extends AbstractDataSqlSource {
stmt = conn.createQueryStatement();
ResultSet set = stmt.executeQuery(sql);
ResultSetMetaData rsd = set.getMetaData();
boolean smallint = rsd == null ? false : rsd.getColumnType(1) == Types.SMALLINT;
boolean smallint = rsd != null && rsd.getColumnType(1) == Types.SMALLINT;
while (set.next()) {
rs.put((K) (smallint ? set.getShort(1) : set.getObject(1)), (N) set.getObject(2));
}
@@ -1727,7 +1727,7 @@ public class DataJdbcSource extends AbstractDataSqlSource {
stmt = conn.createQueryStatement();
ResultSet set = stmt.executeQuery(sql);
ResultSetMetaData rsd = set.getMetaData();
boolean smallint = rsd == null ? false : rsd.getColumnType(1) == Types.SMALLINT;
boolean smallint = rsd != null && rsd.getColumnType(1) == Types.SMALLINT;
while (set.next()) {
rs.put((K) (smallint ? set.getShort(1) : set.getObject(1)), (N) set.getObject(2));
}
@@ -1772,7 +1772,7 @@ public class DataJdbcSource extends AbstractDataSqlSource {
if (smallints == null) {
smallints = new boolean[keys.length];
for (int i = 0; i < keys.length; i++) {
smallints[i] = rsd == null ? false : rsd.getColumnType(i + 1) == Types.SMALLINT;
smallints[i] = rsd != null && rsd.getColumnType(i + 1) == Types.SMALLINT;
}
}
for (int i = 0; i < keys.length; i++) {
@@ -1830,7 +1830,7 @@ public class DataJdbcSource extends AbstractDataSqlSource {
stmt = conn.createQueryStatement();
ResultSet set = stmt.executeQuery(sql);
ResultSetMetaData rsd = set.getMetaData();
boolean smallint = rsd == null ? false : rsd.getColumnType(1) == Types.SMALLINT;
boolean smallint = rsd != null && rsd.getColumnType(1) == Types.SMALLINT;
while (set.next()) {
rs.put((K) (smallint ? set.getShort(1) : set.getObject(1)), (N) set.getObject(2));
}

View File

@@ -687,7 +687,7 @@ public final class EntityInfo<T> {
Cacheable c1 = type.getAnnotation(Cacheable.class);
javax.persistence.Cacheable c2 = type.getAnnotation(javax.persistence.Cacheable.class);
if (this.table == null || (!cacheForbidden && c1 != null && c1.value()) || (!cacheForbidden && c2 != null && c2.value())) {
this.cache = new EntityCache<>(this, c1 == null ? (c2 == null ? 0 : c2.interval()) : c1.interval(), c1 == null ? (c2 == null ? false : c2.direct()) : c1.direct());
this.cache = new EntityCache<>(this, c1 == null ? (c2 == null ? 0 : c2.interval()) : c1.interval(), c1 == null ? (c2 != null && c2.direct()) : c1.direct());
} else {
this.cache = null;
}
@@ -1617,7 +1617,7 @@ public final class EntityInfo<T> {
}
public boolean isNotNullable(Attribute<T, Serializable> attr) {
return attr == null ? false : notNullColumns.contains(attr.field());
return attr != null && notNullColumns.contains(attr.field());
}
public boolean isNotNullJson(Attribute<T, Serializable> attr) {
@@ -1743,8 +1743,8 @@ public final class EntityInfo<T> {
this.column = col == null || col.name().isEmpty() ? name : col.name();
this.type = type;
this.comment = (col == null || col.comment().isEmpty()) && comment != null && !comment.value().isEmpty() ? comment.value() : (col == null ? "" : col.comment());
this.nullable = col == null ? false : col.nullable();
this.unique = col == null ? false : col.unique();
this.nullable = col != null && col.nullable();
this.unique = col != null && col.unique();
this.length = col == null ? 255 : col.length();
this.precision = col == null ? 0 : col.precision();
this.scale = col == null ? 0 : col.scale();

View File

@@ -57,9 +57,9 @@ public final class FilterNodeBean<T extends FilterBean> implements Comparable<Fi
this.joinClass = bean == null ? null : bean.joinClass;
this.joinColumns = bean == null ? null : bean.joinColumns;
this.least = bean == null ? 1 : bean.least;
this.string = bean == null ? false : bean.string;
this.number = bean == null ? false : bean.number;
this.or = bean == null ? false : bean.or;
this.string = bean != null && bean.string;
this.number = bean != null && bean.number;
this.or = bean != null && bean.or;
this.nodeBeans = bean == null ? null : bean.nodeBeans;
}

View File

@@ -995,7 +995,7 @@ public final class Utility {
}
boolean[] rs = new boolean[array.length];
for (int i = 0; i < rs.length; i++) {
rs[i] = array[i] == null ? false : array[i];
rs[i] = array[i] != null && array[i];
}
return rs;
}