[R] [CI] add more linting checks (#8624)
This commit is contained in:
parent
b05abfc494
commit
9a98c3726c
@ -328,7 +328,6 @@ setinfo.xgb.DMatrix <- function(object, name, info, ...) {
|
||||
return(TRUE)
|
||||
}
|
||||
stop("setinfo: unknown info name ", name)
|
||||
return(FALSE)
|
||||
}
|
||||
|
||||
|
||||
@ -418,7 +417,7 @@ print.xgb.DMatrix <- function(x, verbose = FALSE, ...) {
|
||||
cat(infos)
|
||||
cnames <- colnames(x)
|
||||
cat(' colnames:')
|
||||
if (verbose & !is.null(cnames)) {
|
||||
if (verbose && !is.null(cnames)) {
|
||||
cat("\n'")
|
||||
cat(cnames, sep = "','")
|
||||
cat("'")
|
||||
|
||||
@ -143,7 +143,7 @@ xgb.plot.shap <- function(data, shap_contrib = NULL, features = NULL, top_n = 1,
|
||||
y <- shap_contrib[, f][ord]
|
||||
x_lim <- range(x, na.rm = TRUE)
|
||||
y_lim <- range(y, na.rm = TRUE)
|
||||
do_na <- plot_NA && any(is.na(x))
|
||||
do_na <- plot_NA && anyNA(x)
|
||||
if (do_na) {
|
||||
x_range <- diff(x_lim)
|
||||
loc_na <- min(x, na.rm = TRUE) + x_range * pos_NA
|
||||
@ -272,7 +272,7 @@ xgb.shap.data <- function(data, shap_contrib = NULL, features = NULL, top_n = 1,
|
||||
imp <- xgb.importance(model = model, trees = trees, feature_names = colnames(data))
|
||||
}
|
||||
top_n <- top_n[1]
|
||||
if (top_n < 1 | top_n > 100) stop("top_n: must be an integer within [1, 100]")
|
||||
if (top_n < 1 || top_n > 100) stop("top_n: must be an integer within [1, 100]")
|
||||
features <- imp$Feature[seq_len(min(top_n, NROW(imp)))]
|
||||
}
|
||||
if (is.character(features)) {
|
||||
|
||||
@ -17,6 +17,8 @@ FILES_TO_LINT <- list.files(
|
||||
|
||||
my_linters <- list(
|
||||
absolute_path_linter = lintr::absolute_path_linter(),
|
||||
any_duplicated = lintr::any_duplicated_linter(),
|
||||
any_is_na = lintr::any_is_na_linter(),
|
||||
assignment_linter = lintr::assignment_linter(),
|
||||
brace_linter = lintr::brace_linter(),
|
||||
commas_linter = lintr::commas_linter(),
|
||||
@ -30,10 +32,13 @@ my_linters <- list(
|
||||
seq = lintr::seq_linter(),
|
||||
spaces_inside_linter = lintr::spaces_inside_linter(),
|
||||
spaces_left_parentheses_linter = lintr::spaces_left_parentheses_linter(),
|
||||
sprintf = lintr::sprintf_linter(),
|
||||
trailing_blank_lines_linter = lintr::trailing_blank_lines_linter(),
|
||||
trailing_whitespace_linter = lintr::trailing_whitespace_linter(),
|
||||
true_false = lintr::T_and_F_symbol_linter(),
|
||||
unneeded_concatenation = lintr::unneeded_concatenation_linter()
|
||||
unneeded_concatenation = lintr::unneeded_concatenation_linter(),
|
||||
unreachable_code = lintr::unreachable_code_linter(),
|
||||
vector_logic = lintr::vector_logic_linter()
|
||||
)
|
||||
|
||||
noquote(paste0(length(FILES_TO_LINT), " R files need linting"))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user