Skip to content

Commit

Permalink
FINERACT-2036: Fix code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
vidakovic committed Jan 7, 2024
1 parent 314929e commit 478fb55
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class EmailService {
if(params.bcc) {
msg.setRecipients(Message.RecipientType.BCC, InternetAddress.parse(params.bcc))
}
msg.setSubject(params.subject)
msg.setText(params.message);
msg.setSubject(params.subject, "UTF-8")
msg.setText(params.message, "UTF-8");

Transport.send(msg);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import org.apache.fineract.gradle.FineractPluginExtension
import org.slf4j.Logger
import org.slf4j.LoggerFactory

import java.nio.charset.Charset

class TemplateService {
private static final Logger log = LoggerFactory.getLogger(TemplateService.class)

Expand All @@ -35,7 +37,7 @@ class TemplateService {
TemplateService(FineractPluginExtension.FineractPluginConfigTemplate config) {
def dir = new File(config.templateDir);

this.config = new Configuration(Configuration.VERSION_2_3_31);
this.config = new Configuration(Configuration.VERSION_2_3_32);
this.config.setDirectoryForTemplateLoading(dir)
this.config.setDefaultEncoding("UTF-8");
this.config.setLogTemplateExceptions(false);
Expand All @@ -58,7 +60,7 @@ class TemplateService {
Template template = null;

if(params.templateFile) {
template = new Template("template", new FileReader(new File(params.templateFile)), this.config)
template = new Template("template", new FileReader(new File(params.templateFile), Charset.forName("UTF-8")), this.config)
}
if(params.template) {
template = new Template("template", new StringReader(params.template), this.config)
Expand All @@ -69,7 +71,7 @@ class TemplateService {
def output = new File(params.outputFile)
output.createNewFile()

template.process(data, new FileWriter(output, false))
template.process(data, new FileWriter(output, Charset.forName("UTF-8"), false))
} else {
def output = new StringWriter()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ ${project['fineract.config.name']}



🎉 Powered by Fineract Release Plugin 🎊
🎉 Powered by Fineract Release Plugin 🎊
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
under the License.
-->
[FINERACT] [PROPOSAL] 📦 New release ${project['fineract.release.version']}
[FINERACT] [PROPOSAL] 📦 New release ${project['fineract.release.version']}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
under the License.
-->
[FINERACT] [ANNOUNCE] 🔀 ${project['fineract.release.version']} release branch
[FINERACT] [ANNOUNCE] 🔀 ${project['fineract.release.version']} release branch
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
under the License.
-->
[FINERACT] [VOTE] 🗳️ ${project['fineract.release.version']} for release
[FINERACT] [VOTE] 🗳️ ${project['fineract.release.version']} for release
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
under the License.
-->
[FINERACT] [VOTE] [RESULT] 🧾️ ${project['fineract.release.version']} for release
[FINERACT] [VOTE] [RESULT] 🧾️ ${project['fineract.release.version']} for release
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ https://issues.apache.org/jira/secure/ReleaseNote.jspa?version=${project['finera
For more information on Apache Fineract please visit
project home page: https://fineract.apache.org

The Apache Fineract Team
The Apache Fineract Team
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
under the License.
-->
[ANNOUNCE] Apache Fineract ${project['fineract.release.version']} Release
[ANNOUNCE] Apache Fineract ${project['fineract.release.version']} Release
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
under the License.
-->
Fineract ${project['fineract.release.version']} release
Fineract ${project['fineract.release.version']} release
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public List<JsonObject> queryDataTable(@NotNull String datatable, @NotNull Strin
Object columnValue = SearchUtil.parseJdbcColumnValue(column, columnValueString, null, null, null, false, sqlGenerator);
String sql = sqlGenerator.buildSelect(selectColumns, null, false) + " " + sqlGenerator.buildFrom(datatable, null, false) + " WHERE "
+ EQ.formatPlaceholder(sqlGenerator, column.getColumnName(), 1, null);
SqlRowSet rowSet = jdbcTemplate.queryForRowSet(sql, columnValue);
SqlRowSet rowSet = jdbcTemplate.queryForRowSet(sql, columnValue); // NOSONAR

List<JsonObject> results = new ArrayList<>();
while (rowSet.next()) {
Expand Down Expand Up @@ -279,7 +279,7 @@ public Page<JsonObject> queryDataTableAdvanced(@NotNull String datatable, @NotNu

// Execute the count Query
String countQuery = "SELECT COUNT(*)" + from + where;
Integer totalElements = jdbcTemplate.queryForObject(countQuery, Integer.class, args);
Integer totalElements = jdbcTemplate.queryForObject(countQuery, Integer.class, args); // NOSONAR
if (totalElements == null || totalElements == 0) {
return PageableExecutionUtils.getPage(results, pageable, () -> 0);
}
Expand Down Expand Up @@ -1012,7 +1012,7 @@ private void parseDatatableColumnForDrop(final JsonObject column, StringBuilder
String findFKSql = "SELECT count(*) FROM information_schema.TABLE_CONSTRAINTS i" + " WHERE i.CONSTRAINT_TYPE = 'FOREIGN KEY' AND "
+ schemaSql + " AND i.TABLE_NAME = '" + datatableName + "' AND i.CONSTRAINT_NAME = '" + fkName + "' ";

final Integer count = this.jdbcTemplate.queryForObject(findFKSql, Integer.class);
final Integer count = this.jdbcTemplate.queryForObject(findFKSql, Integer.class); // NOSONAR
if (count != null && count > 0) {
codeMappings.add(datatableAlias + "_" + name);
constrainBuilder.append(", DROP FOREIGN KEY ").append(sqlGenerator.escape(fkName)).append(" ");
Expand Down Expand Up @@ -1076,7 +1076,7 @@ private void removeNullValuesFromStringColumn(final String datatableName, final
if (type != null && mandatory && type.isStringType()) {
String sql = "UPDATE " + sqlGenerator.escape(datatableName) + " SET " + sqlGenerator.escape(name) + " = '' WHERE "
+ sqlGenerator.escape(name) + " IS NULL";
this.jdbcTemplate.update(sql);
this.jdbcTemplate.update(sql); // NOSONAR
}
}

Expand Down Expand Up @@ -1141,12 +1141,12 @@ private void checkColumnRenameAndModifyUniqueConstraint(String datatableName, St
private void createUniqueConstraint(String datatableName, String columnName, String uniqueKeyName) {
String sql = "ALTER TABLE " + sqlGenerator.escape(datatableName) + " ADD CONSTRAINT " + sqlGenerator.escape(uniqueKeyName)
+ " UNIQUE (" + sqlGenerator.escape(columnName) + ");";
this.jdbcTemplate.execute(sql);
this.jdbcTemplate.execute(sql); // NOSONAR
}

private void dropUniqueConstraint(String datatableName, String uniqueKeyName) {
String sql = "ALTER TABLE " + sqlGenerator.escape(datatableName) + " DROP CONSTRAINT " + sqlGenerator.escape(uniqueKeyName) + ";";
this.jdbcTemplate.execute(sql);
this.jdbcTemplate.execute(sql); // NOSONAR
}

private void updateIndexesForTable(String datatableName, JsonArray changeColumns,
Expand Down Expand Up @@ -1430,7 +1430,7 @@ private CommandProcessingResult updateDatatableEntry(final String dataTableName,
params.add(primaryKey);
final String sql = sqlGenerator.buildUpdate(dataTableName, updateColumns, headersByName) + " WHERE " + pkColumn.getColumnName()
+ " = ?";
int updated = jdbcTemplate.update(sql, params.toArray(Object[]::new));
int updated = jdbcTemplate.update(sql, params.toArray(Object[]::new)); // NOSONAR
if (updated != 1) {
throw new PlatformDataIntegrityException("error.msg.invalid.update", "Expected one updated row.");
}
Expand Down Expand Up @@ -1486,7 +1486,7 @@ private CommandProcessingResult deleteDatatableEntries(final String dataTableNam
String sql = "DELETE FROM " + sqlGenerator.escape(dataTableName) + " WHERE " + sqlGenerator.escape(whereColumn) + " = "
+ whereValue;

this.jdbcTemplate.update(sql);
this.jdbcTemplate.update(sql); // NOSONAR
return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
.withEntityId(whereValue) //
Expand Down Expand Up @@ -1643,7 +1643,7 @@ public boolean isDatatableAttachedToEntityDatatableCheck(final String datatableN
String sql = "SELECT COUNT(edc.x_registered_table_name) FROM x_registered_table xrt"
+ " JOIN m_entity_datatable_check edc ON edc.x_registered_table_name = xrt.registered_table_name"
+ " WHERE edc.x_registered_table_name = '" + datatableName + "'";
final Long count = this.jdbcTemplate.queryForObject(sql, Long.class);
final Long count = this.jdbcTemplate.queryForObject(sql, Long.class); // NOSONAR
return count != null && count > 0;
}

Expand Down Expand Up @@ -1682,7 +1682,7 @@ private boolean isRegisteredDataTable(final String datatable) {
private void validateDataTableExists(final String datatableName) {
final String sql = "select (CASE WHEN exists (select 1 from information_schema.tables where table_schema = "
+ sqlGenerator.currentSchema() + " and table_name = ?) THEN 'true' ELSE 'false' END)";
final boolean dataTableExists = Boolean.parseBoolean(this.jdbcTemplate.queryForObject(sql, String.class, datatableName));
final boolean dataTableExists = Boolean.parseBoolean(this.jdbcTemplate.queryForObject(sql, String.class, datatableName)); // NOSONAR
if (!dataTableExists) {
throw new PlatformDataIntegrityException("error.msg.invalid.datatable", "Invalid Data Table: " + datatableName, API_FIELD_NAME,
datatableName);
Expand Down Expand Up @@ -1716,7 +1716,7 @@ private String mapApiTypeToDbType(String apiType, Integer length) {

private int getDatatableRowCount(final String datatableName) {
final String sql = "select count(*) from " + sqlGenerator.escape(datatableName);
Integer count = this.jdbcTemplate.queryForObject(sql, Integer.class);
Integer count = this.jdbcTemplate.queryForObject(sql, Integer.class); // NOSONAR
return count == null ? 0 : count;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public Page<SavingsAccountTransactionData> searchTransactions(@NotNull Long savi
Object[] args = params.toArray();

String countQuery = "SELECT COUNT(*) " + tm.from() + where;
Integer totalElements = jdbcTemplate.queryForObject(countQuery, Integer.class, args);
Integer totalElements = jdbcTemplate.queryForObject(countQuery, Integer.class, args); // NOSONAR
if (totalElements == null || totalElements == 0) {
return emptyResult;
}
Expand Down Expand Up @@ -266,7 +266,7 @@ public Page<JsonObject> queryAdvanced(@NotNull Long savingsId, @NotNull PagedLoc

// Execute the count Query
String countQuery = "SELECT COUNT(*)" + from + where;
Integer totalElements = jdbcTemplate.queryForObject(countQuery, Integer.class, args);
Integer totalElements = jdbcTemplate.queryForObject(countQuery, Integer.class, args); // NOSONAR
if (totalElements == null || totalElements == 0) {
return PageableExecutionUtils.getPage(results, pageable, () -> 0);
}
Expand Down

0 comments on commit 478fb55

Please sign in to comment.