Skip to content

Commit

Permalink
dbeaver#22963 Fix Codacy Static Code Analysis suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
longhaseng52 committed Apr 2, 2024
1 parent b3fa7bd commit 303be27
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ protected void appendTableModifiers(
CubridTable table = (CubridTable) genericTable;
String suffix = alter ? "," : "\n";
query.append("\n");
if (table.isReuseOID() == false && alter == false) {
if (!table.isReuseOID() && !alter) {
query.append("DONT_REUSE_OID").append(suffix);
}
if ((command.getProperty("charset") != null || command.getProperty("collation") != null) && table.getCollation().getName() != null) {
if (command.getProperty("charset") != null || command.getProperty("collation") != null) {
query.append("COLLATE ").append(table.getCollation().getName()).append(suffix);
}
if (command.getProperty("autoIncrement") != null && table.getAutoIncrement() != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,9 @@ public List<CubridCollation> getCollations() {
return collations;
}

@Nullable
@NotNull
public CubridCollation getDefaultCollation() {
for (CubridCollation collation : collations) {
return collation;
}
return null;
return collations.get(0);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public CubridProcedure(
@NotNull String procedureName,
@Nullable String description,
@NotNull DBSProcedureType procedureType,
@NotNull String target,
@NotNull String returnType) {
super(container, procedureName, description, procedureType, null, true);
this.returnType = returnType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,9 @@ protected GenericTableColumn fetchChild(
try (JDBCPreparedStatement dbStat = session.prepareStatement(sql)) {
dbStat.setString(1, columnName);
try (JDBCResultSet result = dbStat.executeQuery()) {
while (result.next()) {
if (result.next()) {
dataType = JDBCUtils.safeGetString(result, "Type");
autoIncrement = JDBCUtils.safeGetString(result, "Extra").equals("auto_increment");
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ public void loadProcedures(
String procedureName = JDBCUtils.safeGetString(dbResult, "sp_name");
String description = JDBCUtils.safeGetString(dbResult, CubridConstants.COMMENT);
String type = JDBCUtils.safeGetString(dbResult, "sp_type");
String target = JDBCUtils.safeGetString(dbResult, "target");
String returnType = JDBCUtils.safeGetString(dbResult, "return_type");
DBSProcedureType procedureType;
if (type.equalsIgnoreCase(CubridConstants.TERM_PROCEDURE)) {
Expand All @@ -380,7 +379,7 @@ public void loadProcedures(
} else {
procedureType = DBSProcedureType.UNKNOWN;
}
container.addProcedure(new CubridProcedure(container, procedureName, description, procedureType, target, returnType));
container.addProcedure(new CubridProcedure(container, procedureName, description, procedureType, returnType));
}
}
}
Expand All @@ -395,11 +394,11 @@ public String getViewDDL(@NotNull DBRProgressMonitor monitor, @Nullable GenericV
String ddl = "-- View definition not available";
try (JDBCSession session = DBUtils.openMetaSession(monitor, object, "Load view ddl")) {
String sql = String.format("show create view %s", ((CubridView) object).getUniqueName());
try(JDBCPreparedStatement dbStat = session.prepareStatement(sql)) {
try (JDBCPreparedStatement dbStat = session.prepareStatement(sql)) {
try (JDBCResultSet dbResult = dbStat.executeQuery()) {
while(dbResult.next()) {
if (dbResult.next()) {
ddl = "create or replace view \"" + dbResult.getString("View") + "\" as " + dbResult.getString("Create View");
return SQLFormatUtils.formatSQL(object.getDataSource(), ddl);
ddl = SQLFormatUtils.formatSQL(object.getDataSource(), ddl);
}
}
}
Expand Down

0 comments on commit 303be27

Please sign in to comment.