Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sonar][ci] Fixes some new recommended "bug" fixes found via Sonar #7508

Merged
merged 2 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -623,14 +623,16 @@ private void appendRandomDate(StringBuilder buffer, CodegenOperation op, Codegen
// the OpenAPI 2.0/3.0 specs, which mandates the ISO-8601 full-date or date-time formats. Accordingly, date
// and date-time fields are annotated with @JsonFormat to specify the appropriate ISO format.
if (loadTestDataFromFile) {
Date randomDate = new Date(randomDateLong);
switch (var.dataFormat) {
case "date":
var.addTestData(ISO8601_DATE_FORMAT.get().format(randomDate));
break;
case "date-time":
var.addTestData(ISO8601_DATETIME_FORMAT.get().format(randomDate));
break;
if (var != null) {
Date randomDate = new Date(randomDateLong);
switch (var.dataFormat) {
case "date":
var.addTestData(ISO8601_DATE_FORMAT.get().format(randomDate));
break;
case "date-time":
var.addTestData(ISO8601_DATETIME_FORMAT.get().format(randomDate));
break;
}
}
} else {
buffer.append("new Date(").append(randomDateLong).append(')');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,20 @@ public static List<String> getUnusedSchemas(OpenAPI openAPI) {
childrenMap = tmpChildrenMap;
List<String> unusedSchemas = new ArrayList<String>();

Map<String, Schema> schemas = getSchemas(openAPI);
unusedSchemas.addAll(schemas.keySet());

visitOpenAPI(openAPI, (s, t) -> {
if (s.get$ref() != null) {
String ref = getSimpleRef(s.get$ref());
unusedSchemas.remove(ref);
if (childrenMap.containsKey(ref)) {
unusedSchemas.removeAll(childrenMap.get(ref));
if (openAPI != null) {
Map<String, Schema> schemas = getSchemas(openAPI);
unusedSchemas.addAll(schemas.keySet());

visitOpenAPI(openAPI, (s, t) -> {
if (s.get$ref() != null) {
String ref = getSimpleRef(s.get$ref());
unusedSchemas.remove(ref);
if (childrenMap.containsKey(ref)) {
unusedSchemas.removeAll(childrenMap.get(ref));
}
}
}
});
});
}
return unusedSchemas;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ def custom_server_with_http_info(opts = {})
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:body]
post_body = opts[:debug_body]

# return_type
return_type = opts[:return_type] || 'Object'
return_type = opts[:debug_return_type] || 'Object'

# auth_names
auth_names = opts[:auth_names] || []
auth_names = opts[:debug_auth_names] || []

new_options = opts.merge(
:operation => :"UsageApi.custom_server",
Expand Down Expand Up @@ -108,13 +108,13 @@ def default_server_with_http_info(opts = {})
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:body]
post_body = opts[:debug_body]

# return_type
return_type = opts[:return_type] || 'Object'
return_type = opts[:debug_return_type] || 'Object'

# auth_names
auth_names = opts[:auth_names] || []
auth_names = opts[:debug_auth_names] || []

new_options = opts.merge(
:operation => :"UsageApi.default_server",
Expand Down