"Add curly braces" does not appear as a Quick-fix for always_put_control_body_on_new_line
See original GitHub issueDescribe the bug
Single quick fixes don’t always appear. In this case, for always_put_control_body_on_new_line
.
✅ Inline lightbulb ✅ <kbd>cmd</kbd><kbd>.</kbd> ❌ Hovercard ⇒ click “Quick fix”
https://user-images.githubusercontent.com/6655696/169700652-c421d922-da30-47fe-a2e1-61cd0ef09cb7.mp4
❌ lightbulb in Problems panel
- VS Code version: Version: 1.67.2 (Universal)
- Dart Code extension: 3.40.0
- Flutter extension: 3.41.20220516 (activated)
There seems to be a separate issue for multi-fixes (“everywhere in this file”) that also applies to Android Studio, so filed https://github.com/dart-lang/sdk/issues/49079.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Using StandardJS, getting error for curly brace on wrong line ...
Like the error says, you need to put the closing curly brace on the same line as the subsequent block after the else...
Read more >IDE0011: Add braces - .NET - Microsoft Learn
Use the following option to specify whether curly braces are preferred or not, and if preferred, whether only for multi-line code blocks.
Read more >Code Syntax Style: Braces for Single Nested Statements
JetBrains Rider highlights code that do not comply with your preferences and suggests the corresponding quick-fix or fix in scope.
Read more >curly brackets in GUID - Esri Community
Hi, When importing data from a PostgreSQL database into ArcGIS Pro, the UUID from PostgreSQL are transformed into GUIDs, and for some reason ......
Read more >Direct Query adding curly brackets to Test GUID Field
Direct Query adding curly brackets to Test GUID Field ... When I go to Edit Query I dont see the Brackets. But in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
With https://github.com/dart-lang/sdk/commit/20b7de7b570afd582f8c7d3a58d182acfb01bda6, the “Add Curly Braces” fix will now show up as a fix for this lint:
It won’t be applied by
dart fix
(because I don’t think it’s clearly the correct fix for this lint, which is about newlines and not braces).Although, while testing this I realised that
curly_braces_in_flow_control_structures
doesn’t cover things on a single line, so if your code is:Then enabling both lints still won’t get
dart fix
to do what you want. I think the solution to that is probably a new fix foralways_put_control_body_on_new_line
that inserts a newline, then the example above could bedart fix
able, without conflating the lints (eg. not assuming people withalways_put_control_body_on_new_line
want braces, or people withcurly_braces_in_flow_control_structures
want everything split across lines).There’s already an issue covering this at https://github.com/dart-lang/sdk/issues/47956, although there’s a slight complication because of conflicts with the formatter.
Re-reading this lint, I’m now wondering whether the “Add curly braces” fix is the obvious fix here. The lint isn’t about using curly braces, but rather about having the code on a new line.
If you’re using the formatter, then these things are quite tied together, but if you’re not using the formatter you might expect a fix for “move the body to a new line” rather than adding curly braces.
There is another lint named
curly_braces_in_flow_control_structures
that I believe does what you want - it generates a similar warning but it does provide “add curly braces” as a fix.Does it make more sense for you to enable
curly_braces_in_flow_control_structures
is curly braces is what you really want?(cc @bwilkerson for his thoughts on whether “Use curly braces” is a reasonable fix also for “always_put_control_body_on_new_line”)