Repository navigation
Commit ea4c6df
Avoid calling
`SuggestedFixes.compilesWithFix` re-parses and re-attributes the entire compilation unit for each candidate field, which can be slow on large files with many candidate fields that are conditionally initialized.
Instead, check that blank candidate fields are initialized once in straight-line code (including plain blocks and `catch`-less `try` blocks) in the class or instance initializer or in every non-delegating constructor, before any reads of the field or `return` statements. Fields initialized across branching control flow (such as `if`/`else`) are no longer matched.
PiperOrigin-RevId: 1012050702SuggestedFixes.compilesWithFix in FieldCanBeFinal
1 parent 04640b8 commit ea4c6df
2 files changed
Lines changed: 868 additions & 30 deletions
File tree
- core/src
- main/java/com/google/errorprone/bugpatterns
- test/java/com/google/errorprone/bugpatterns
0 commit comments