File tree 4 files changed +30
-15
lines changed
4 files changed +30
-15
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ linters: linters_with_tags(
10
10
object_usage_linter = NULL,
11
11
commented_code_linter = NULL,
12
12
indentation_linter = NULL,
13
- nonportable_path_linter = NULL
13
+ nonportable_path_linter = NULL,
14
+ endian_linter = lightr:::endian_linter()
14
15
)
15
16
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ Imports:
27
27
Suggests:
28
28
digest,
29
29
knitr,
30
+ lintr,
30
31
pavo,
31
32
rmarkdown,
32
33
spelling,
Original file line number Diff line number Diff line change
1
+ endian_linter <- function () {
2
+ xpath <- "
3
+ //SYMBOL_FUNCTION_CALL[text() = 'readBin' or text() = 'writeBin']
4
+ /parent::expr
5
+ /parent::expr[not(SYMBOL_SUB[text() = 'endian'])]
6
+ "
7
+
8
+ lintr :: Linter(function (source_expression ) {
9
+ if (! lintr :: is_lint_level(source_expression , " expression" )) {
10
+ return (list ())
11
+ }
12
+
13
+ xml <- source_expression $ xml_parsed_content
14
+
15
+ bad_expr <- xml2 :: xml_find_all(xml , xpath )
16
+
17
+ lintr :: xml_nodes_to_lints(
18
+ bad_expr ,
19
+ source_expression = source_expression ,
20
+ lint_message = paste(
21
+ xml2 :: xml_find_first(bad_expr , " string(.//SYMBOL_FUNCTION_CALL)" ),
22
+ " should always include a value for 'endian'"
23
+ ),
24
+ type = " warning"
25
+ )
26
+ })
27
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments