Skip to content

Multiline logical comparison indentation error #2857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
DavZim opened this issue May 9, 2025 · 1 comment
Open

Multiline logical comparison indentation error #2857

DavZim opened this issue May 9, 2025 · 1 comment

Comments

@DavZim
Copy link

DavZim commented May 9, 2025

When I use multiline logical conditions such as the following, lintr throws an error but this is the format that is automatically indented by RStudio (Ctrl + I) or by air.

is.null(a) ||
  length(a) == 1 &&
  is.na(a)

A full reprex is here:

code_lines <- "is.null(a) ||
  length(a) == 1 &&
  is.na(a)

writeLines(code_lines)
#> is.null(a) ||
#>   length(a) == 1 &&
#>   is.na(a)

lintr::lint(
  text = code_lines,
  linters = lintr::indentation_linter()
)
#> '<text>:3:2': style: [indentation_linter] Indentation should be 4 spaces but is 2 spaces.
#>   is.na(a)
#>  ^~~

I would expect this to pass as I "feel" it is indented correctly.

packageVersion("lintr")
#> [1] ‘3.2.0’
@MichaelChirico
Copy link
Collaborator

I agree. See also #2007, #2034

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants