Search code examples
javaandroidfinallint

Android Lint: mark variables as final whenever applicable in Java


Is there any Lint check to enforce declaring every variable (local or class), parameter final if they really are?


Solution

  • No there's no check for that. Checkstyle or PMD can do this for you. Note that both won't work with Kotlin though.

    You could also write your own lint check for that. I've written a blog post about it that goes into detail - https://medium.com/@vanniktech/writing-your-first-lint-check-39ad0e90b9e6