-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathfilter_rcmdcheck.R
85 lines (70 loc) · 2.54 KB
/
filter_rcmdcheck.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
## This script can be used to parse R CMD check and evaluate a list of ignore rules.
## Known notes/warnings/errors which are fine, has a defined rule to filter them out.
## Remaining notes/errors/warnings will be raised as an concatenated error. Error does not
## have to be pretty. Developer shoud go read rcmdcheck report instead.
library(rcmdcheck)
print(R.version)
print(Sys.info())
print(getwd())
#define ignore rules for notes, warnings and errors
ignore_rules = list(
notes = list(
#if note contains this phrase then skip it by returning TRUE.
#yes rpolars is huge way above 10Mb nothing to do about that
ignore_lib_size = function(msg) {
isTRUE(grepl("checking installed package size ... NOTE",msg))
},
#check warnings/notes appear since main polars commit from and after
#" feat(rust, python): The 1 billion row sort (#6156) "
# 1a51f9e55196f69fb59e44d497de4f0e6685640d
# don't know how to fix it for now, just ignore unit tests passes just fine
ignore_macos_dll_error = function(msg) {
isTRUE(Sys.info()["sysname"]=="Darwin") &&
isTRUE(grepl("_IOBSDNameMatching",msg))
}
),
warnings = list(
#see above both warnings and a note
ignore_macos_dll_error = function(msg) {
isTRUE(grepl("darwin",R.version$os)[1]) &&
isTRUE(grepl("_IOBSDNameMatching",msg))
},
ignore_lengths_ns_collision = function(msg) {
isTRUE(
grepl("Functions or methods with usage in documentation object 'ExprStr_lengths'",
msg)
)
}
),
errors = list(
)
)
#helper function
#iterate a msg_set, as notes, warnings, errors and drop those where an ignore rule returns TRUE
drop_ignored = function(msg_set, rule_list) {
ignore_these = sapply(msg_set, function(note){
any(sapply(rule_list,function(f) isTRUE(f(note))))
}) |> as.logical()
msg_set[!ignore_these]
}
#parse check report to object
check_report_path = c(
Sys.getenv("rcmdcheck_path"),
"./check/rpolars.Rcheck/"
) |> (\(x) {x[nzchar(x)]})()
check_obj = rcmdcheck::parse_check(check_report_path)
#filter remaining not-ignored msgs
remaining_erros = unlist(lapply(
c(notes = "notes", warnings = "warnings", errors = "errors"),
function(msg_type) {
drop_ignored(check_obj[[msg_type]], ignore_rules[[msg_type]])
}
))
#raise any remaining errors
if( length(remaining_erros)) {
stop(remaining_erros)
print("some errors where not ignored, and will be raised right now!")
} else {
print(ignore_rules)
print("Hey you deserve a Gold Medal!! No msgs from rcmdcheck you're not ignoring anyways")
}