minor code improvement based on sonarcloud reports (#10364)

This commit is contained in:
William Cheng 2021-09-10 18:12:23 +08:00 committed by GitHub
parent 9464999d9c
commit 592cb64465
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 8 deletions

View File

@ -2834,7 +2834,7 @@ public class DefaultCodegen implements CodegenConfig {
"'{}' defines discriminator '{}', but the referenced OneOf schema '{}' is missing {}",
composedSchemaName, discPropName, modelName, discPropName);
}
if (cp.dataType == null) {
if (cp != null && cp.dataType == null) {
cp = thisCp;
continue;
}

View File

@ -350,7 +350,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
} else {
typDecl = "interface{}";
}
if (Boolean.TRUE.equals(inner.getNullable())) {
if (inner != null && Boolean.TRUE.equals(inner.getNullable())) {
typDecl = "*" + typDecl;
}
return "[]" + typDecl;

View File

@ -71,10 +71,9 @@ public class CppTinyClientCodegen extends AbstractCppCodegen implements CodegenC
}
public void addControllerToAdditionalProperties() {
Map<String, String> supportedControllers = new HashMap<String, String>() {{
put("esp32", "isESP32");
put("esp8266", "isESP8266");
}};
Map<String, String> supportedControllers = new HashMap<String, String>();
supportedControllers.put("esp32", "isESP32");
supportedControllers.put("esp8266", "isESP8266");
if (supportedControllers.containsKey(controller)) {
additionalProperties.put(supportedControllers.get(controller), true);
} else {

View File

@ -1195,7 +1195,11 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
// this seed makes it so if we have [a-z] we pick a
Random random = new Random(18);
example = rgxGen.generate(random);
if (rgxGen != null) {
example = rgxGen.generate(random);
} else {
throw new RuntimeException("rgxGen cannot be null. Please open an issue in the openapi-generator github repo.");
}
} else if (schema.getMinLength() != null) {
example = "";
int len = schema.getMinLength().intValue();

View File

@ -1180,7 +1180,11 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
// this seed makes it so if we have [a-z] we pick a
Random random = new Random(18);
example = rgxGen.generate(random);
if (rgxGen != null){
example = rgxGen.generate(random);
} else {
throw new RuntimeException("rgxGen cannot be null. Please open an issue in the openapi-generator github repo.");
}
} else if (schema.getMinLength() != null) {
example = "";
int len = schema.getMinLength().intValue();