-
Notifications
You must be signed in to change notification settings - Fork 170
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
False negative for curly_braces_in_control_flow_structures
#4870
Comments
Work towards dart-lang/linter#4870 Change-Id: I0e52227496d3ea26e498501c59e3b2af0e9c67fa Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352982 Auto-Submit: Samuel Rawlins <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Phil Quitslund <[email protected]>
But what if someone wants to enforce that curly_braces_in_control_flow_structures enforces all control flow to have braces? IMO, the whole point of the lint was to avoid Personally, I'd like to keep the lint strict and keep the old behaviour. If someone wants to allow |
I don't think that's related to this issue... |
With the change proposal above, the statement |
Here's the test case. |
Ah, my mistake. Should I file a new issue for having it linted? |
Yes please :D. Without a backing Effective Dart rule though, we are unlikely to add a style-oriented rule, or change the Effective Dart rule. You can file a request to change the style guide at https://github.com/dart-lang/site-www/issues. |
Agree. The issue here is that the expected exception seems to be implemented by checking that the |
Sorry, forgot to mention I've been working on this and cleaning up the SDK. https://dart-review.googlesource.com/c/sdk/+/353140 But it will take a lot of work to land. Google internal needs a lot of cleanup. |
SGTM, ship it! (But yes, signficant clean-up will likely be needed.) Feel free to take the extra tests I added, if you think they can be useful. |
…same line as if-keyword Fixes dart-lang/linter#4870 Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try Change-Id: Ibd8969afe35f719a020e5aa37efdc1792addac7e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353140 Reviewed-by: Stephen Adams <[email protected]> Reviewed-by: Phil Quitslund <[email protected]> Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
To fix dart-lang/linter#4870, the analyzer is now reporting if-statement bodies without curly braces when the if-statement condition spans multiple lines. This change prepares zulip-flutter for this lint rule change.
To fix dart-lang/linter#4870, the analyzer is now reporting if-statement bodies without curly braces when the if-statement condition spans multiple lines. This change prepares zulip-flutter for this lint rule change.
…same line as if-keyword Fixes dart-lang/linter#4870 Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try Change-Id: Ibd8969afe35f719a020e5aa37efdc1792addac7e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353140 Reviewed-by: Stephen Adams <[email protected]> Reviewed-by: Phil Quitslund <[email protected]> Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
Fixed by FMorschel/sdk@2c6dec6 |
Just to be clear, I've nothing to do with the fix. I'm not sure why, but some of the time when I rebase my fork on GH it keeps warning issues about changes from other people but it is simply because the link is commented on the commit description. Sorry for the confusion! |
The lint
curly_braces_in_control_flow_structures
should warn if anif
statement body has no braces.An exception is granted if the entire
if
statement fits in one line, based on the corresponding Effective Dart rule.No lint warning is given for the
if
statement of this code:The body of this
if
statement fits in one line, but the entire statement does not, so the lint should trigger.It does not.
(Found this by seeing similar code in a code review.)
The text was updated successfully, but these errors were encountered: