зеркало из https://github.com/microsoft/LightGBM.git
[ci] [R-package] enforce more {lintr} checks (#6130)
This commit is contained in:
Родитель
b793cd821c
Коммит
3d9ada7657
|
@ -1,5 +1,5 @@
|
|||
|
||||
library(lintr)
|
||||
loadNamespace("lintr")
|
||||
|
||||
args <- commandArgs(
|
||||
trailingOnly = TRUE
|
||||
|
@ -33,30 +33,34 @@ LINTERS_TO_USE <- list(
|
|||
, "any_duplicated" = lintr::any_duplicated_linter()
|
||||
, "any_is_na" = lintr::any_is_na_linter()
|
||||
, "assignment" = lintr::assignment_linter()
|
||||
, "backport" = lintr::backport_linter()
|
||||
, "boolean_arithmetic" = lintr::boolean_arithmetic_linter()
|
||||
, "braces" = lintr::brace_linter()
|
||||
, "class_equals" = lintr::class_equals_linter()
|
||||
, "commas" = lintr::commas_linter()
|
||||
, "conjunct_test" = lintr::conjunct_test_linter()
|
||||
, "duplicate_argument" = lintr::duplicate_argument_linter()
|
||||
, "empty_assignment" = lintr::empty_assignment_linter()
|
||||
, "equals_na" = lintr::equals_na_linter()
|
||||
, "fixed_regex" = lintr::fixed_regex_linter()
|
||||
, "for_loop_index" = lintr::for_loop_index_linter()
|
||||
, "function_left" = lintr::function_left_parentheses_linter()
|
||||
, "function_return" = lintr::function_return_linter()
|
||||
, "implicit_assignment" = lintr::implicit_assignment_linter()
|
||||
, "implicit_integers" = lintr::implicit_integer_linter()
|
||||
, "infix_spaces" = lintr::infix_spaces_linter()
|
||||
, "inner_combine" = lintr::inner_combine_linter()
|
||||
, "is_numeric" = lintr::is_numeric_linter()
|
||||
, "fixed_regex" = lintr::fixed_regex_linter()
|
||||
, "function_return" = lintr::function_return_linter()
|
||||
, "lengths" = lintr::lengths_linter()
|
||||
, "line_length" = lintr::line_length_linter(length = 120L)
|
||||
, "literal_coercion" = lintr::literal_coercion_linter()
|
||||
, "long_lines" = lintr::line_length_linter(length = 120L)
|
||||
, "matrix" = lintr::matrix_apply_linter()
|
||||
, "missing_argument" = lintr::missing_argument_linter()
|
||||
, "non_portable_path" = lintr::nonportable_path_linter()
|
||||
, "numeric_leading_zero" = lintr::numeric_leading_zero_linter()
|
||||
, "outer_negation" = lintr::outer_negation_linter()
|
||||
, "package_hooks" = lintr::package_hooks_linter()
|
||||
, "paren_body" = lintr::paren_body_linter()
|
||||
, "paste" = lintr::paste_linter()
|
||||
, "quotes" = lintr::quotes_linter()
|
||||
, "redundant_equals" = lintr::redundant_equals_linter()
|
||||
|
@ -100,6 +104,7 @@ LINTERS_TO_USE <- list(
|
|||
"%>%" = pipe_text
|
||||
, "%.%" = pipe_text
|
||||
, "%..%" = pipe_text
|
||||
, "|>" = pipe_text
|
||||
, "?" = interactive_text
|
||||
, "??" = interactive_text
|
||||
)
|
||||
|
@ -107,6 +112,7 @@ LINTERS_TO_USE <- list(
|
|||
, "unnecessary_concatenation" = lintr::unnecessary_concatenation_linter()
|
||||
, "unnecessary_lambda" = lintr::unnecessary_lambda_linter()
|
||||
, "unreachable_code" = lintr::unreachable_code_linter()
|
||||
, "unused_import" = lintr::unused_import_linter()
|
||||
, "vector_logic" = lintr::vector_logic_linter()
|
||||
, "whitespace" = lintr::whitespace_linter()
|
||||
)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
library(lightgbm)
|
||||
library(methods)
|
||||
|
||||
# We load in the agaricus dataset
|
||||
# In this example, we are aiming to predict whether a mushroom is edible
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
library(lightgbm)
|
||||
library(methods)
|
||||
|
||||
# Load in the agaricus dataset
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
library(lightgbm)
|
||||
library(methods)
|
||||
|
||||
# Load in the agaricus dataset
|
||||
data(agaricus.train, package = "lightgbm")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
library(testthat)
|
||||
library(lightgbm)
|
||||
library(lightgbm) # nolint: [unused_import]
|
||||
|
||||
test_check(
|
||||
package = "lightgbm"
|
||||
|
|
|
@ -183,7 +183,9 @@ test_that("lgb.Dataset: colnames", {
|
|||
colnames(dtest) <- "asdf"
|
||||
})
|
||||
new_names <- make.names(seq_len(ncol(test_data)))
|
||||
expect_silent(colnames(dtest) <- new_names)
|
||||
expect_silent({
|
||||
colnames(dtest) <- new_names
|
||||
})
|
||||
expect_equal(colnames(dtest), new_names)
|
||||
})
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ test_that("learning-to-rank with lgb.train() works as expected", {
|
|||
eval_results <- model$eval_train()
|
||||
expect_equal(length(eval_results), length(eval_names))
|
||||
for (result in eval_results) {
|
||||
expect_true(result[["value"]] > 0.0 && result[["value"]] < 1.0)
|
||||
expect_true(result[["value"]] > 0.0)
|
||||
expect_true(result[["value"]] < 1.0)
|
||||
expect_true(result[["higher_better"]])
|
||||
expect_identical(result[["data_name"]], "training")
|
||||
}
|
||||
|
@ -104,8 +105,10 @@ test_that("learning-to-rank with lgb.cv() works as expected", {
|
|||
# check that best score and iter make sense (0.0 < nDCG < 1.0)
|
||||
best_iter <- cv_bst$best_iter
|
||||
best_score <- cv_bst$best_score
|
||||
expect_true(best_iter > 0L && best_iter <= nrounds)
|
||||
expect_true(best_score > 0.0 && best_score < 1.0)
|
||||
expect_true(best_iter > 0L)
|
||||
expect_true(best_iter <= nrounds)
|
||||
expect_true(best_score > 0.0)
|
||||
expect_true(best_score < 1.0)
|
||||
expect_true(abs(best_score - 0.75) < .LGB_NUMERIC_TOLERANCE)
|
||||
|
||||
# best_score should be set for the first metric
|
||||
|
|
|
@ -1275,7 +1275,9 @@ test_that("params (including dataset params) should be stored in .rds file for B
|
|||
bst_file <- tempfile(fileext = ".rds")
|
||||
expect_warning(saveRDS.lgb.Booster(bst, file = bst_file))
|
||||
|
||||
expect_warning(bst_from_file <- readRDS.lgb.Booster(file = bst_file))
|
||||
expect_warning({
|
||||
bst_from_file <- readRDS.lgb.Booster(file = bst_file)
|
||||
})
|
||||
expect_identical(
|
||||
bst_from_file$params
|
||||
, list(
|
||||
|
|
Загрузка…
Ссылка в новой задаче