[Effective Dart] Disallow single line if statements without braces #5580
Labels
a.effective-dart
Relates to the best practices explained in Effective Dart
e2-days
Can complete in < 5 days of normal, not dedicated, work
p2-medium
Necessary but not urgent concern. Resolve when possible.
st.triage.ltw
Indicates Lead Tech Writer has triaged
t.diagnostics
Relates to diagnostics, analysis, or linting of code
Today, the curly_braces_in_control_flow_structures lint does not lint on the following statement
if (arg == null) return defaultValue;
Per the style guide, this is due to an exception to the rule:
However, in code review, I have had to enforce that all control flow statements (regardless of line length for the full statement) have braces.
Thus, in my opinion, the statement "DO use curly braces for all flow control structures." is not correct, due to this exception.
Perhaps we can either change the
curly_braces_in_flow_control_structures
lint (and remove the exception to the rule in Effective Dart),or add a new lint that lints specifically for the single line
ìf (condition) <body>;
Context: dart-lang/linter#4870 (comment)
The text was updated successfully, but these errors were encountered: