-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Labels
Description
Currently, the multi-line conditional expressions don't have the same indentation.
E.g., the following code, when styled with {styler} remains unchanged:
communicate_warning <- function(changed, transformers) {
if (any(changed, na.rm = TRUE) &&
!parse_tree_must_be_identical(transformers) &&
!getOption("styler.quiet", FALSE)
) {
cat("Please review the changes carefully!", fill = TRUE)
}
}Shouldn't it instead be styled to the following?
communicate_warning <- function(changed, transformers) {
if (any(changed, na.rm = TRUE) &&
!parse_tree_must_be_identical(transformers) &&
!getOption("styler.quiet", FALSE)
) {
cat("Please review the changes carefully!", fill = TRUE)
}
}As an aside, the current behaviour in {styler} conflicts with {lintr}, which produces lint for the styled code (cc @AshesITR):
library(lintr)
code <- 'communicate_warning <- function(changed, transformers) {
if (any(changed, na.rm = TRUE) &&
!parse_tree_must_be_identical(transformers) &&
!getOption("styler.quiet", FALSE)
) {
cat("Please review the changes carefully!", fill = TRUE)
}
}'
lint(
text = code,
linters = indentation_linter()
)
#> <text>:3:4: style: [indentation_linter] Indentation should be 6 spaces but is 4 spaces.
#> !parse_tree_must_be_identical(transformers) &&
#> ^~~Created on 2022-11-21 with reprex v2.0.2