-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Description
I just reformatted some written-long-ago code frequently included if/else statements without braces. Those statements are reformatted into a shape that leads to a less readable result (to my eye).
These examples show the spirit of what happened:
Input:
foo <- function() {
if (first_long_variable && second_long_variable)
cat("ahoy there mates!")
else
cat("arr! i be shivering.")
}Formatted:
foo <- function() {
if (first_long_variable && second_long_variable) cat("ahoy there mates!") else
cat("arr! i be shivering.")
}The input form made it obvious that this was an if/else statement. The reformatted form makes it less clear.
Things are also complicated with if/else-if chains.
Input:
foo <- function() {
if (first)
cat("first")
else if (second)
cat("second")
else if (third)
cat("third")
else
cat("last")
}Formatted:
foo <- function() {
if (first) cat("first") else if (second) cat("second") else if (third)
cat("third") else cat("last")
}The formatted form is much more challenging to skim to see the different expressions.
In each of these examples, I introduced braces in order to avoid letting air collapse them.
Using air 0.4.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels