[R] Fix warnings reported by r cmd check (#13205)

* fix warnings reported by r cmd check

* fix assignment
This commit is contained in:
William Cheng 2022-08-17 20:17:30 +08:00 committed by GitHub
parent c135139e3d
commit 9f3fac53c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 61 additions and 46 deletions

View File

@ -288,7 +288,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("description.mustache", "", "DESCRIPTION"));
supportingFiles.add(new SupportingFile("Rbuildignore.mustache", "", ".Rbuildignore"));
supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
supportingFiles.add(new SupportingFile(".travis.yml.mustache", "", ".travis.yml"));
supportingFiles.add(new SupportingFile("ApiResponse.mustache", File.separator + "R", "api_response.R"));
supportingFiles.add(new SupportingFile("api_client.mustache", File.separator + "R", "api_client.R"));
supportingFiles.add(new SupportingFile("NAMESPACE.mustache", "", "NAMESPACE"));
@ -320,6 +320,16 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
}
});
// add lambda for mustache templates to escape %
additionalProperties.put("lambdaRdocEscape", new Mustache.Lambda() {
@Override
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
String content = fragment.execute();
content = content.trim().replace("%", "\\%");
writer.write(content);
}
});
}
@Override

View File

@ -5,7 +5,12 @@ cache:
- /home/travis/R/Library
r_packages:
- jsonlite
{{^isHttr2}}
- httr
{{/isHttr2}}
{{#isHttr2}}
- httr2
{{/isHttr2}}
- testthat
# uncomment below to install deps with devtools
#install:

View File

@ -10,9 +10,9 @@
{{! Adding the below changes for generating documentation for the api methods. }}
#' \describe{
{{#operation}}
#' \strong{ {{operationId}} } \emph{ {{summary}} }
#' \strong{ {{operationId}} } \emph{ {{#lambdaRdocEscape}}{{summary}}{{/lambdaRdocEscape}} }
{{#notes}}
#' {{{.}}}
#' {{#lambdaRdocEscape}}{{{.}}}{{/lambdaRdocEscape}}
{{/notes}}
#'
#' \itemize{

View File

@ -23,10 +23,10 @@
#' Initialize a new {{{classname}}} class.
#'
{{#requiredVars}}
#' @param {{name}} {{{description}}}{{^description}}{{{name}}}{{/description}}
#' @param {{name}} {{#lambdaRdocEscape}}{{{description}}}{{/lambdaRdocEscape}}{{^description}}{{{name}}}{{/description}}
{{/requiredVars}}
{{#optionalVars}}
#' @param {{name}} {{{description}}}{{^description}}{{{name}}}{{/description}}{{#defaultValue}}. Default to {{{.}}}.{{/defaultValue}}
#' @param {{name}} {{#lambdaRdocEscape}}{{{description}}}{{/lambdaRdocEscape}}{{^description}}{{{name}}}{{/description}}{{#defaultValue}}. Default to {{{.}}}.{{/defaultValue}}
{{/optionalVars}}
#' @param ... Other optional arguments.
#' @export
@ -428,7 +428,7 @@
{{#required}}
# check if the required `{{{name}}}` is null
if (is.null(self$`{{{name}}}`)) {
invalid_fields["{{{name}}}"] = "Non-nullable required field `{{{name}}}` cannot be null."
invalid_fields["{{{name}}}"] <- "Non-nullable required field `{{{name}}}` cannot be null."
}
{{/required}}
@ -436,37 +436,37 @@
{{#hasValidation}}
{{#maxLength}}
if (nchar(self$`{{{name}}}`) > {{maxLength}}) {
invalid_fields["{{{name}}}"] = "Invalid length for `{{{name}}}`, must be smaller than or equal to {{maxLength}}."
invalid_fields["{{{name}}}"] <- "Invalid length for `{{{name}}}`, must be smaller than or equal to {{maxLength}}."
}
{{/maxLength}}
{{#minLength}}
if (nchar(self$`{{{name}}}`) < {{minLength}}) {
invalid_fields["{{{name}}}"] = "Invalid length for `{{{name}}}`, must be bigger than or equal to {{minLength}}."
invalid_fields["{{{name}}}"] <- "Invalid length for `{{{name}}}`, must be bigger than or equal to {{minLength}}."
}
{{/minLength}}
{{#maximum}}
if (self$`{{{name}}}` >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}) {
invalid_fields["{{{name}}}"] = "Invalid value for `{{{name}}}`, must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{maximum}}."
invalid_fields["{{{name}}}"] <- "Invalid value for `{{{name}}}`, must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{maximum}}."
}
{{/maximum}}
{{#minimum}}
if (self$`{{{name}}}` <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}) {
invalid_fields["{{{name}}}"] = "Invalid value for `{{{name}}}`, must be bigger than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{minimum}}."
invalid_fields["{{{name}}}"] <- "Invalid value for `{{{name}}}`, must be bigger than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{minimum}}."
}
{{/minimum}}
{{#pattern}}
if (!str_detect(self$`{{{name}}}`, "{{{pattern}}}")) {
invalid_fields["{{{name}}}"] = "Invalid value for `{{{name}}}`, must conform to the pattern {{{pattern}}}."
invalid_fields["{{{name}}}"] <- "Invalid value for `{{{name}}}`, must conform to the pattern {{{pattern}}}."
}
{{/pattern}}
{{#maxItems}}
if (length(self$`{{{name}}}`) > {{maxItems}}) {
invalid_fields["{{{name}}}"] = "Invalid length for `{{{name}}}`, number of items must be less than or equal to {{maxItems}}."
invalid_fields["{{{name}}}"] <- "Invalid length for `{{{name}}}`, number of items must be less than or equal to {{maxItems}}."
}
{{/maxItems}}
{{#minItems}}
if (length(self$`{{{name}}}`) < {{minItems}}) {
invalid_fields["{{{name}}}"] = "Invalid length for `{{{param}}}`, number of items must be greater than or equal to {{minItems}}."
invalid_fields["{{{name}}}"] <- "Invalid length for `{{{param}}}`, number of items must be greater than or equal to {{minItems}}."
}
{{/minItems}}

View File

@ -5,7 +5,7 @@ cache:
- /home/travis/R/Library
r_packages:
- jsonlite
- httr
- httr2
- testthat
# uncomment below to install deps with devtools
#install:

View File

@ -173,7 +173,7 @@ Animal <- R6::R6Class(
invalid_fields <- list()
# check if the required `className` is null
if (is.null(self$`className`)) {
invalid_fields["className"] = "Non-nullable required field `className` cannot be null."
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
}
invalid_fields

View File

@ -184,12 +184,12 @@ BasquePig <- R6::R6Class(
invalid_fields <- list()
# check if the required `className` is null
if (is.null(self$`className`)) {
invalid_fields["className"] = "Non-nullable required field `className` cannot be null."
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
}
# check if the required `color` is null
if (is.null(self$`color`)) {
invalid_fields["color"] = "Non-nullable required field `color` cannot be null."
invalid_fields["color"] <- "Non-nullable required field `color` cannot be null."
}
invalid_fields

View File

@ -197,7 +197,7 @@ Cat <- R6::R6Class(
invalid_fields <- list()
# check if the required `className` is null
if (is.null(self$`className`)) {
invalid_fields["className"] = "Non-nullable required field `className` cannot be null."
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
}
invalid_fields

View File

@ -165,7 +165,7 @@ Category <- R6::R6Class(
getInvalidFields = function() {
invalid_fields <- list()
if (!str_detect(self$`name`, "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")) {
invalid_fields["name"] = "Invalid value for `name`, must conform to the pattern ^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$."
invalid_fields["name"] <- "Invalid value for `name`, must conform to the pattern ^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$."
}
invalid_fields

View File

@ -184,12 +184,12 @@ DanishPig <- R6::R6Class(
invalid_fields <- list()
# check if the required `className` is null
if (is.null(self$`className`)) {
invalid_fields["className"] = "Non-nullable required field `className` cannot be null."
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
}
# check if the required `size` is null
if (is.null(self$`size`)) {
invalid_fields["size"] = "Non-nullable required field `size` cannot be null."
invalid_fields["size"] <- "Non-nullable required field `size` cannot be null."
}
invalid_fields

View File

@ -197,7 +197,7 @@ Dog <- R6::R6Class(
invalid_fields <- list()
# check if the required `className` is null
if (is.null(self$`className`)) {
invalid_fields["className"] = "Non-nullable required field `className` cannot be null."
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
}
invalid_fields

View File

@ -281,12 +281,12 @@ Pet <- R6::R6Class(
invalid_fields <- list()
# check if the required `name` is null
if (is.null(self$`name`)) {
invalid_fields["name"] = "Non-nullable required field `name` cannot be null."
invalid_fields["name"] <- "Non-nullable required field `name` cannot be null."
}
# check if the required `photoUrls` is null
if (is.null(self$`photoUrls`)) {
invalid_fields["photoUrls"] = "Non-nullable required field `photoUrls` cannot be null."
invalid_fields["photoUrls"] <- "Non-nullable required field `photoUrls` cannot be null."
}
invalid_fields

View File

@ -5,7 +5,7 @@ cache:
- /home/travis/R/Library
r_packages:
- jsonlite
- httr
- httr2
- testthat
# uncomment below to install deps with devtools
#install:

View File

@ -173,7 +173,7 @@ Animal <- R6::R6Class(
invalid_fields <- list()
# check if the required `className` is null
if (is.null(self$`className`)) {
invalid_fields["className"] = "Non-nullable required field `className` cannot be null."
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
}
invalid_fields

View File

@ -184,12 +184,12 @@ BasquePig <- R6::R6Class(
invalid_fields <- list()
# check if the required `className` is null
if (is.null(self$`className`)) {
invalid_fields["className"] = "Non-nullable required field `className` cannot be null."
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
}
# check if the required `color` is null
if (is.null(self$`color`)) {
invalid_fields["color"] = "Non-nullable required field `color` cannot be null."
invalid_fields["color"] <- "Non-nullable required field `color` cannot be null."
}
invalid_fields

View File

@ -197,7 +197,7 @@ Cat <- R6::R6Class(
invalid_fields <- list()
# check if the required `className` is null
if (is.null(self$`className`)) {
invalid_fields["className"] = "Non-nullable required field `className` cannot be null."
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
}
invalid_fields

View File

@ -165,7 +165,7 @@ Category <- R6::R6Class(
getInvalidFields = function() {
invalid_fields <- list()
if (!str_detect(self$`name`, "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")) {
invalid_fields["name"] = "Invalid value for `name`, must conform to the pattern ^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$."
invalid_fields["name"] <- "Invalid value for `name`, must conform to the pattern ^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$."
}
invalid_fields

View File

@ -184,12 +184,12 @@ DanishPig <- R6::R6Class(
invalid_fields <- list()
# check if the required `className` is null
if (is.null(self$`className`)) {
invalid_fields["className"] = "Non-nullable required field `className` cannot be null."
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
}
# check if the required `size` is null
if (is.null(self$`size`)) {
invalid_fields["size"] = "Non-nullable required field `size` cannot be null."
invalid_fields["size"] <- "Non-nullable required field `size` cannot be null."
}
invalid_fields

View File

@ -197,7 +197,7 @@ Dog <- R6::R6Class(
invalid_fields <- list()
# check if the required `className` is null
if (is.null(self$`className`)) {
invalid_fields["className"] = "Non-nullable required field `className` cannot be null."
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
}
invalid_fields

View File

@ -281,12 +281,12 @@ Pet <- R6::R6Class(
invalid_fields <- list()
# check if the required `name` is null
if (is.null(self$`name`)) {
invalid_fields["name"] = "Non-nullable required field `name` cannot be null."
invalid_fields["name"] <- "Non-nullable required field `name` cannot be null."
}
# check if the required `photoUrls` is null
if (is.null(self$`photoUrls`)) {
invalid_fields["photoUrls"] = "Non-nullable required field `photoUrls` cannot be null."
invalid_fields["photoUrls"] <- "Non-nullable required field `photoUrls` cannot be null."
}
invalid_fields

View File

@ -173,7 +173,7 @@ Animal <- R6::R6Class(
invalid_fields <- list()
# check if the required `className` is null
if (is.null(self$`className`)) {
invalid_fields["className"] = "Non-nullable required field `className` cannot be null."
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
}
invalid_fields

View File

@ -184,12 +184,12 @@ BasquePig <- R6::R6Class(
invalid_fields <- list()
# check if the required `className` is null
if (is.null(self$`className`)) {
invalid_fields["className"] = "Non-nullable required field `className` cannot be null."
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
}
# check if the required `color` is null
if (is.null(self$`color`)) {
invalid_fields["color"] = "Non-nullable required field `color` cannot be null."
invalid_fields["color"] <- "Non-nullable required field `color` cannot be null."
}
invalid_fields

View File

@ -197,7 +197,7 @@ Cat <- R6::R6Class(
invalid_fields <- list()
# check if the required `className` is null
if (is.null(self$`className`)) {
invalid_fields["className"] = "Non-nullable required field `className` cannot be null."
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
}
invalid_fields

View File

@ -165,7 +165,7 @@ Category <- R6::R6Class(
getInvalidFields = function() {
invalid_fields <- list()
if (!str_detect(self$`name`, "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")) {
invalid_fields["name"] = "Invalid value for `name`, must conform to the pattern ^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$."
invalid_fields["name"] <- "Invalid value for `name`, must conform to the pattern ^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$."
}
invalid_fields

View File

@ -184,12 +184,12 @@ DanishPig <- R6::R6Class(
invalid_fields <- list()
# check if the required `className` is null
if (is.null(self$`className`)) {
invalid_fields["className"] = "Non-nullable required field `className` cannot be null."
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
}
# check if the required `size` is null
if (is.null(self$`size`)) {
invalid_fields["size"] = "Non-nullable required field `size` cannot be null."
invalid_fields["size"] <- "Non-nullable required field `size` cannot be null."
}
invalid_fields

View File

@ -197,7 +197,7 @@ Dog <- R6::R6Class(
invalid_fields <- list()
# check if the required `className` is null
if (is.null(self$`className`)) {
invalid_fields["className"] = "Non-nullable required field `className` cannot be null."
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
}
invalid_fields

View File

@ -281,12 +281,12 @@ Pet <- R6::R6Class(
invalid_fields <- list()
# check if the required `name` is null
if (is.null(self$`name`)) {
invalid_fields["name"] = "Non-nullable required field `name` cannot be null."
invalid_fields["name"] <- "Non-nullable required field `name` cannot be null."
}
# check if the required `photoUrls` is null
if (is.null(self$`photoUrls`)) {
invalid_fields["photoUrls"] = "Non-nullable required field `photoUrls` cannot be null."
invalid_fields["photoUrls"] <- "Non-nullable required field `photoUrls` cannot be null."
}
invalid_fields