xref: /aosp_15_r20/frameworks/base/tools/lint/fix/README.md (revision d57664e9bc4670b3ecf6748a746a57c557b6bc9e)
1*d57664e9SAndroid Build Coastguard Worker# Refactoring the platform with lint
2*d57664e9SAndroid Build Coastguard WorkerInspiration: go/refactor-the-platform-with-lint\
3*d57664e9SAndroid Build Coastguard Worker**Special Thanks: brufino@, azharaa@, for the prior work that made this all possible**
4*d57664e9SAndroid Build Coastguard Worker
5*d57664e9SAndroid Build Coastguard Worker## What is this?
6*d57664e9SAndroid Build Coastguard Worker
7*d57664e9SAndroid Build Coastguard WorkerIt's a python script that runs the framework linter,
8*d57664e9SAndroid Build Coastguard Workerand then (optionally) copies modified files back into the source tree.\
9*d57664e9SAndroid Build Coastguard WorkerWhy python, you ask? Because python is cool ¯\\\_(ツ)\_/¯.
10*d57664e9SAndroid Build Coastguard Worker
11*d57664e9SAndroid Build Coastguard WorkerIncidentally, this exposes a much simpler way to run individual lint checks
12*d57664e9SAndroid Build Coastguard Workeragainst individual modules, so it's useful beyond applying fixes.
13*d57664e9SAndroid Build Coastguard Worker
14*d57664e9SAndroid Build Coastguard Worker## Why?
15*d57664e9SAndroid Build Coastguard Worker
16*d57664e9SAndroid Build Coastguard WorkerLint is not allowed to modify source files directly via lint's `--apply-suggestions` flag.
17*d57664e9SAndroid Build Coastguard WorkerAs a compromise, soong zips up the (potentially) modified sources and leaves them in an intermediate
18*d57664e9SAndroid Build Coastguard Workerdirectory. This script runs the lint, unpacks those files, and copies them back into the tree.
19*d57664e9SAndroid Build Coastguard Worker
20*d57664e9SAndroid Build Coastguard Worker## How do I run it?
21*d57664e9SAndroid Build Coastguard Worker**WARNING: You probably want to commit/stash any changes to your working tree before doing this...**
22*d57664e9SAndroid Build Coastguard Worker
23*d57664e9SAndroid Build Coastguard Worker```
24*d57664e9SAndroid Build Coastguard Workersource build/envsetup.sh
25*d57664e9SAndroid Build Coastguard Workerlunch cf_x86_64_phone-userdebug # or any lunch target
26*d57664e9SAndroid Build Coastguard Workerm lint_fix
27*d57664e9SAndroid Build Coastguard Workerlint_fix -h
28*d57664e9SAndroid Build Coastguard Worker```
29*d57664e9SAndroid Build Coastguard Worker
30*d57664e9SAndroid Build Coastguard WorkerThe script's help output explains things that are omitted here.
31