@@ -57,36 +57,36 @@ brace_linter <- function(allow_single_line = FALSE) {
57
57
},
58
58
# double curly
59
59
" not(
60
- (@line1 = parent::expr/preceding-sibling::OP-LEFT-BRACE/@line1) or
61
- (@line1 = following-sibling::expr/OP-LEFT-BRACE/@line1)
60
+ (@line1 = parent::expr/preceding-sibling::OP-LEFT-BRACE/@line1)
61
+ or (@line1 = following-sibling::expr/OP-LEFT-BRACE/@line1)
62
62
)" ,
63
63
# allow `(`, `,` and `%>%` on preceding line
64
64
#
65
65
# note that '{' is not supported in RHS call of base-R's native pipe (`|>`),
66
66
# so no exception needs to be made for this operator
67
67
" not(
68
68
@line1 > parent::expr/preceding-sibling::*[not(self::COMMENT)][1][
69
- self::OP-LEFT-PAREN or
70
- self::OP-COMMA or
71
- (self::SPECIAL and text() = '%>%')
69
+ self::OP-LEFT-PAREN
70
+ or self::OP-COMMA
71
+ or (self::SPECIAL and text() = '%>%')
72
72
]/@line2
73
73
)"
74
74
))
75
75
76
76
# TODO (AshesITR): if c_style_braces is TRUE, invert the preceding-sibling condition
77
77
xp_open_curly <- glue :: glue(" //OP-LEFT-BRACE[
78
- { xp_cond_open } and (
79
- not(@line1 = parent::expr/preceding-sibling::*/@line2) or
80
- @line1 = following-sibling::*[1][not(self::COMMENT)]/@line1
78
+ { xp_cond_open }
79
+ and (
80
+ not(@line1 = parent::expr/preceding-sibling::*/@line2)
81
+ or @line1 = following-sibling::*[1][not(self::COMMENT or self::OP-RIGHT-BRACE)]/@line1
81
82
)
82
83
]" )
83
84
84
85
xp_open_preceding <- " parent::expr/preceding-sibling::*[1][self::OP-RIGHT-PAREN or self::ELSE or self::REPEAT]"
85
86
86
87
xp_paren_brace <- glue :: glue(" //OP-LEFT-BRACE[
87
88
@line1 = { xp_open_preceding }/@line1
88
- and
89
- @col1 = { xp_open_preceding }/@col2 + 1
89
+ and @col1 = { xp_open_preceding }/@col2 + 1
90
90
]" )
91
91
92
92
xp_cond_closed <- xp_and(c(
@@ -98,20 +98,22 @@ brace_linter <- function(allow_single_line = FALSE) {
98
98
" not(
99
99
@line1 = ancestor::expr/following-sibling::*[1][
100
100
self::OP-COMMA or self::OP-RIGHT-BRACKET or self::OP-RIGHT-PAREN
101
- ]/@line1
101
+ ]
102
+ /@line1
102
103
)" ,
103
104
# double curly
104
105
" not(
105
- (@line1 = parent::expr/following-sibling::OP-RIGHT-BRACE/@line1) or
106
- (@line1 = preceding-sibling::expr/OP-RIGHT-BRACE/@line1)
106
+ (@line1 = parent::expr/following-sibling::OP-RIGHT-BRACE/@line1)
107
+ or (@line1 = preceding-sibling::expr/OP-RIGHT-BRACE/@line1)
107
108
)"
108
109
))
109
110
110
111
# TODO (AshesITR): if c_style_braces is TRUE, skip the not(ELSE) condition
111
112
xp_closed_curly <- glue :: glue(" //OP-RIGHT-BRACE[
112
- { xp_cond_closed } and (
113
- (@line1 = preceding-sibling::*[1]/@line2) or
114
- (@line1 = parent::expr/following-sibling::*[1][not(self::ELSE)]/@line1)
113
+ { xp_cond_closed }
114
+ and (
115
+ (@line1 = preceding-sibling::*[1][not(self::OP-LEFT-BRACE)]/@line2)
116
+ or (@line1 = parent::expr/following-sibling::*[1][not(self::ELSE)]/@line1)
115
117
)
116
118
]" )
117
119
0 commit comments