Refactoring to extract final variable
See original GitHub issueIn our code base we prefer to have all variables with final
modifier.
It would be super helpful if Extract local variable
would add final
with every refactoring.
- Add vscode preference for
Extract local variable
or - Add separate refactoring
Extract final variable
Thought I am not sure how to achieve this in most elegant way without overfilling refactoring menu with similar options or adding very rarely used preference. 😃
In Intellij it is possible to add options for refactoring 😃
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Extract Variable - Refactoring.Guru
How to Refactor · Insert a new line before the relevant expression and declare a new variable there. Assign part of the complex...
Read more >Refactoring: Extract Variable in IntelliJ IDEA - The JetBrains Blog
The Extract Variable refactoring lets you simplify an expression and remove its redundant parts. If an expression is hard to understand or it...
Read more >Refactoring: Extract a local variable Be careful!
Choose menu item Refactor -> Extract local variable. This causes this window to pop up: We already typed in a name for the...
Read more >Extract Variable - Refactoring
const basePrice = order.quantity * order.itemPrice; const quantityDiscount = Math.max(0, order.quantity - 500) * order.itemPrice * 0.05; const shipping ...
Read more >Refactoring source code in Visual Studio Code
Source code fragments can be extracted into a new method, or into a new function at various different scopes. During the extract refactoring,...
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
The SDK was updated to use
final
when theprefer_final_locals
lint is enabled so this should just start working for you in an upcoming release 👍That’s actually already implemented! (see: prefer_final_locals.)
As for the initial ask, we could accomplish this if we considered project lint settings when doing refactorings. I’m not sure there’s a precedent but definitely worth discussing.
Opened https://github.com/dart-lang/sdk/issues/38081 to track. 👍