You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Conflicting lintr rules with alist and explicitly missing arguments #540
This is pretty niche but shows up a conflicting pair of rules:
> lintr::lint("alist(a =)\n")
<text>:1:9: style: Put spaces around all infix operators.
alist(a =)
^~
> lintr::lint("alist(a = )\n")
<text>:1:10: style: Do not place spaces around code in parentheses or square brackets.
alist(a = )
^
> lintr::lint("alist(a =, b = NULL)\n")
<text>:1:9: style: Put spaces around all infix operators.
alist(a =, b = NULL)
^~
> lintr::lint("alist(a = , b = NULL)\n")
<text>:1:11: style: Commas should never have a space before.
alist(a = , b = NULL)
So for arguments that are "explicitly missing" there is no way of satisfying the default set of linter rules - we must and cannot have a space following the =, for cases that are within or at the end of an argument list.
The above behaviour is triggered in both the cran version (2.0.1) and current github (2.0.1.9000, eece3c1)
This is basically the same as #708 -- there, we now allow your second usage, but not your first:
lintr::lint("switch(a = , b = 2)\n") # doesn't lintlintr::lint("switch(a =, b = 2)\n")
# <text>:1:10: style: [infix_spaces_linter] Put spaces around all infix operators.# switch(a =, b = 2)# ^
This aligns with {styler}:
styler::style_text("switch(a = , b = 2)\nswitch(a =, b = 2)\nalist(a = )\nalist(a =)")
# switch(a = ,# b = 2# )# switch(a = ,# b = 2# )# alist(a = )# alist(a = )
Activity
AshesITR commentedon Oct 23, 2020
This is related to #532
richfitz commentedon Oct 24, 2020
Ah, I'd looked though for issues about commas but managed to miss that!
AshesITR commentedon Oct 24, 2020
Your examples show that the
commas_lintermust also be fixed, not only thespaces_inside_linterso thanks 👍MichaelChirico commentedon Jan 31, 2021
Is this in fact the same as #532?
AshesITR commentedon Jan 31, 2021
#532 is a special case of this. Closing #532
MichaelChirico commentedon Oct 8, 2022
This is basically the same as #708 -- there, we now allow your second usage, but not your first:
This aligns with {styler}: