@@ -27,7 +27,7 @@ patrick::with_parameters_test_that(
27
27
" equals_na_linter blocks disallowed usages for all combinations of operators and types of NAs" ,
28
28
expect_lint(
29
29
paste(" x" , operation , type_na ),
30
- rex :: rex(" Use is.na for comparisons to NA (not == or != or %in%) " ),
30
+ rex :: rex(" Use is.na() instead of x " , operation , " NA " ),
31
31
equals_na_linter()
32
32
),
33
33
.cases = tibble :: tribble(
@@ -52,15 +52,31 @@ patrick::with_parameters_test_that(
52
52
53
53
test_that(" equals_na_linter blocks disallowed usages in edge cases" , {
54
54
linter <- equals_na_linter()
55
- lint_msg <- rex :: rex( " Use is.na for comparisons to NA (not == or != or %in%) " )
55
+ lint_msg_part <- " Use is.na() instead of x "
56
56
57
57
# missing spaces around operators
58
- expect_lint(" x==NA" , list (message = lint_msg , line_number = 1L , column_number = 1L ), linter )
59
- expect_lint(" x!=NA" , list (message = lint_msg , line_number = 1L , column_number = 1L ), linter )
58
+ expect_lint(
59
+ " x==NA" ,
60
+ list (message = rex :: rex(lint_msg_part , " == NA" ), line_number = 1L , column_number = 1L ),
61
+ linter
62
+ )
63
+ expect_lint(
64
+ " x!=NA" ,
65
+ list (message = rex :: rex(lint_msg_part , " != NA" ), line_number = 1L , column_number = 1L ),
66
+ linter
67
+ )
60
68
61
69
# order doesn't matter
62
- expect_lint(" NA == x" , list (message = lint_msg , line_number = 1L , column_number = 1L ), linter )
70
+ expect_lint(
71
+ " NA == x" ,
72
+ list (message = rex :: rex(lint_msg_part , " == NA" ), line_number = 1L , column_number = 1L ),
73
+ linter
74
+ )
63
75
64
76
# correct line number for multiline code
65
- expect_lint(" x ==\n NA" , list (line_number = 1L , column_number = 1L , ranges = list (c(1L , 4L ))), linter )
77
+ expect_lint(
78
+ " x ==\n NA" ,
79
+ list (line_number = 1L , column_number = 1L , ranges = list (c(1L , 4L ))),
80
+ linter
81
+ )
66
82
})
0 commit comments