Skip to content

Commit 3cbc5a8

Browse files
authored
[cleanup] erefactor/AutoRefactor - Log parameters rather than log message (#9133)
AutoRefactor cleanup 'LogParametersRatherThanLogMessage' applied by erefactor: Replaces a string concatenation as parameter of a logger method by a string template followed by objects. For AutoRefactor see https://github.com/JnRouvignac/AutoRefactor For erefactor see https://github.com/cal101/erefactor
1 parent 19f5718 commit 3cbc5a8

20 files changed

+152
-97
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerDeprecatedCodegen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public void processOpts() {
183183
if (StringUtils.isEmpty(library)) {
184184
this.setLibrary(DEFAULT_LIBRARY);
185185
additionalProperties.put(CodegenConstants.LIBRARY, DEFAULT_LIBRARY);
186-
LOGGER.info("`library` option is empty. Default to " + DEFAULT_LIBRARY);
186+
LOGGER.info("`library` option is empty. Default to {}", DEFAULT_LIBRARY);
187187
}
188188

189189
if (additionalProperties.containsKey(Constants.AUTOMATIC_HEAD_REQUESTS)) {

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public void processOpts() {
303303
this.setBasePackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
304304
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
305305
additionalProperties.put(BASE_PACKAGE, basePackage);
306-
LOGGER.info("Set base package to invoker package (" + basePackage + ")");
306+
LOGGER.info("Set base package to invoker package ({})", basePackage);
307307
}
308308

309309
if (additionalProperties.containsKey(BASE_PACKAGE)) {

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KtormSchemaCodegen.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
301301

302302
if (modelVendorExtensions.containsKey(VENDOR_EXTENSION_SCHEMA)) {
303303
// user already specified schema values
304-
LOGGER.info("Found vendor extension in '" + modelName + "' model, autogeneration skipped");
304+
LOGGER.info("Found vendor extension in '{}' model, autogeneration skipped", modelName);
305305
} else {
306306
modelVendorExtensions.put(VENDOR_EXTENSION_SCHEMA, ktormSchema);
307307
ktormSchema.put("tableDefinition", tableDefinition);
@@ -359,7 +359,7 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert
359359

360360
if (vendorExtensions.containsKey(VENDOR_EXTENSION_SCHEMA)) {
361361
// user already specified schema values
362-
LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
362+
LOGGER.info("Found vendor extension in '{}' property, autogeneration skipped", baseName);
363363
return;
364364
}
365365

@@ -688,7 +688,8 @@ public void processNullAndDefault(CodegenModel model, CodegenProperty property,
688688
try {
689689
columnDefinition.put("colDefault", toColumnTypeDefault(defaultValue, dataType, dataFormat));
690690
} catch (RuntimeException exception) {
691-
LOGGER.warn("Property '" + baseName + "' of model '" + model.getName() + "' mapped to data type which doesn't support default value");
691+
LOGGER.warn("Property '{}' of model '{}' mapped to data type which doesn't support default value",
692+
baseName, model.getName());
692693
columnDefinition.put("colDefault", null);
693694
}
694695
}
@@ -985,7 +986,7 @@ private Map<String, Object> toColumnTypeDefault(String defaultValue, String data
985986
public String toDatabaseName(String name) {
986987
String identifier = toIdentifier(name, databaseNamePrefix, databaseNameSuffix);
987988
if (identifier.length() > IDENTIFIER_MAX_LENGTH) {
988-
LOGGER.warn("Database name too long. Name '" + name + "' will be truncated");
989+
LOGGER.warn("Database name too long. Name '{}' will be truncated", name);
989990
identifier = identifier.substring(0, IDENTIFIER_MAX_LENGTH);
990991
}
991992
return identifier;
@@ -1004,7 +1005,7 @@ public String toTableName(String name) {
10041005
identifier = underscore(identifier);
10051006
}
10061007
if (identifier.length() > IDENTIFIER_MAX_LENGTH) {
1007-
LOGGER.warn("Table name too long. Name '" + name + "' will be truncated");
1008+
LOGGER.warn("Table name too long. Name '{}' will be truncated", name);
10081009
identifier = identifier.substring(0, IDENTIFIER_MAX_LENGTH);
10091010
}
10101011
return identifier;
@@ -1023,7 +1024,7 @@ public String toColumnName(String name) {
10231024
identifier = underscore(identifier);
10241025
}
10251026
if (identifier.length() > IDENTIFIER_MAX_LENGTH) {
1026-
LOGGER.warn("Column name too long. Name '" + name + "' will be truncated");
1027+
LOGGER.warn("Column name too long. Name '{}' will be truncated", name);
10271028
identifier = identifier.substring(0, IDENTIFIER_MAX_LENGTH);
10281029
}
10291030
return identifier;
@@ -1042,13 +1043,13 @@ public String toIdentifier(String name, String prefix, String suffix) {
10421043
String escapedName = escapeQuotedIdentifier(name);
10431044
// Database, table, and column names cannot end with space characters.
10441045
if (escapedName.matches(".*\\s$")) {
1045-
LOGGER.warn("Database, table, and column names cannot end with space characters. Check '" + name + "' name");
1046+
LOGGER.warn("Database, table, and column names cannot end with space characters. Check '{}' name", name);
10461047
escapedName = escapedName.replaceAll("\\s+$", "");
10471048
}
10481049

10491050
// Identifiers may begin with a digit but unless quoted may not consist solely of digits.
10501051
if (escapedName.matches("^\\d+$")) {
1051-
LOGGER.warn("Database, table, and column names cannot consist solely of digits. Check '" + name + "' name");
1052+
LOGGER.warn("Database, table, and column names cannot consist solely of digits. Check '{}' name", name);
10521053
escapedName = prefix + escapedName + suffix;
10531054
}
10541055

@@ -1074,7 +1075,8 @@ public String escapeQuotedIdentifier(String identifier) {
10741075
Pattern regexp = Pattern.compile("[^0-9a-zA-z$_\\x0080-\\xFFFF]");
10751076
Matcher matcher = regexp.matcher(identifier);
10761077
if (matcher.find()) {
1077-
LOGGER.warn("Identifier '" + identifier + "' contains unsafe characters out of [0-9,a-z,A-Z$_] and U+0080..U+FFFF range");
1078+
LOGGER.warn("Identifier '{}' contains unsafe characters out of [0-9,a-z,A-Z$_] and U+0080..U+FFFF range",
1079+
identifier);
10781080
identifier = identifier.replaceAll("[^0-9a-zA-z$_\\x0080-\\xFFFF]", "");
10791081
}
10801082
return identifier;
@@ -1106,7 +1108,9 @@ public String escapeUnsafeCharacters(String input) {
11061108
public void setDefaultDatabaseName(String databaseName) {
11071109
String escapedName = toDatabaseName(databaseName);
11081110
if (!escapedName.equals(databaseName)) {
1109-
LOGGER.error("Invalid database name. '" + databaseName + "' cannot be used as identifier. Escaped value '" + escapedName + "' will be used instead.");
1111+
LOGGER.error(
1112+
"Invalid database name. '{}' cannot be used as identifier. Escaped value '{}' will be used instead.",
1113+
databaseName, escapedName);
11101114
}
11111115
this.defaultDatabaseName = escapedName;
11121116
}
@@ -1152,7 +1156,8 @@ public void setIdentifierNamingConvention(String naming) {
11521156
this.identifierNamingConvention = naming;
11531157
break;
11541158
default:
1155-
LOGGER.warn("\"" + naming + "\" is invalid \"identifierNamingConvention\" argument. Current \"" + this.identifierNamingConvention + "\" used instead.");
1159+
LOGGER.warn("\"{}\" is invalid \"identifierNamingConvention\" argument. Current \"{}\" used instead.",
1160+
naming, this.identifierNamingConvention);
11561161
}
11571162
}
11581163

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/LuaClientCodegen.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,14 @@ public String toModelFilename(String name) {
281281

282282
// model name cannot use reserved keyword, e.g. return
283283
if (isReservedWord(name)) {
284-
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + ("model_" + name));
284+
LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, "model_" + name);
285285
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
286286
}
287287

288288
// model name starts with number
289289
if (name.matches("^\\d.*")) {
290-
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + ("model_" + name));
290+
LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
291+
"model_" + name);
291292
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
292293
}
293294

@@ -409,7 +410,7 @@ public String toOperationId(String operationId) {
409410

410411
// method name cannot use reserved keyword, e.g. return
411412
if (isReservedWord(sanitizedOperationId)) {
412-
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore("call_" + operationId));
413+
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, underscore("call_" + operationId));
413414
sanitizedOperationId = "call_" + sanitizedOperationId;
414415
}
415416

0 commit comments

Comments
 (0)