Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
3d9ada76
Unverified
Commit
3d9ada76
authored
Oct 08, 2023
by
James Lamb
Committed by
GitHub
Oct 08, 2023
Browse files
[ci] [R-package] enforce more {lintr} checks (#6130)
parent
b793cd82
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
23 additions
and
13 deletions
+23
-13
.ci/lint_r_code.R
.ci/lint_r_code.R
+10
-4
R-package/demo/basic_walkthrough.R
R-package/demo/basic_walkthrough.R
+0
-1
R-package/demo/boost_from_prediction.R
R-package/demo/boost_from_prediction.R
+0
-1
R-package/demo/early_stopping.R
R-package/demo/early_stopping.R
+0
-1
R-package/tests/testthat.R
R-package/tests/testthat.R
+1
-1
R-package/tests/testthat/test_dataset.R
R-package/tests/testthat/test_dataset.R
+3
-1
R-package/tests/testthat/test_learning_to_rank.R
R-package/tests/testthat/test_learning_to_rank.R
+6
-3
R-package/tests/testthat/test_lgb.Booster.R
R-package/tests/testthat/test_lgb.Booster.R
+3
-1
No files found.
.ci/lint_r_code.R
View file @
3d9ada76
l
ibrary
(
lintr
)
l
oadNamespace
(
"
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
()
)
...
...
R-package/demo/basic_walkthrough.R
View file @
3d9ada76
library
(
lightgbm
)
library
(
methods
)
# We load in the agaricus dataset
# In this example, we are aiming to predict whether a mushroom is edible
...
...
R-package/demo/boost_from_prediction.R
View file @
3d9ada76
library
(
lightgbm
)
library
(
methods
)
# Load in the agaricus dataset
data
(
agaricus.train
,
package
=
"lightgbm"
)
...
...
R-package/demo/early_stopping.R
View file @
3d9ada76
library
(
lightgbm
)
library
(
methods
)
# Load in the agaricus dataset
data
(
agaricus.train
,
package
=
"lightgbm"
)
...
...
R-package/tests/testthat.R
View file @
3d9ada76
library
(
testthat
)
library
(
lightgbm
)
library
(
lightgbm
)
# nolint: [unused_import]
test_check
(
package
=
"lightgbm"
...
...
R-package/tests/testthat/test_dataset.R
View file @
3d9ada76
...
...
@@ -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
)
})
...
...
R-package/tests/testthat/test_learning_to_rank.R
View file @
3d9ada76
...
...
@@ -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
...
...
R-package/tests/testthat/test_lgb.Booster.R
View file @
3d9ada76
...
...
@@ -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
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment