Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to automatically fix all of the possible lint warnings in the whole project in Android Studio?

Imagine you have a project with thousands of lint warnings after you set up analysis_options.yaml file properly. And now you need to fix all of the mess you have. Doing it all by hand can cost you a lot of time, while most of the issues are very simple like "var" instead of "final", double quotes instead of single, etc.

Is there any way to make Android Studio automatically fix all of the easiest lint warnings like "Prefer const with constant constructors", etc. in terminal or by running any specific command?

like image 227
Thomas Avatar asked Jul 08 '20 19:07

Thomas


2 Answers

first within the project do : dart fix --dry-run then after it finish use : dart fix --apply

like image 156
bkmtech Avatar answered Oct 16 '22 15:10

bkmtech


In Android Studio in the top Menu use

"Analyze" -> "Code Cleanup"

If that doesn't fix it you have to go manually through the result of

"Analyze" -> "inspect code"

See https://developer.android.com/studio/write/lint#manuallyRunInspections

like image 43
rubo77 Avatar answered Oct 16 '22 16:10

rubo77