Every time I finish a release and go live, I review the code again to see what I can improve. But their level is limited, there are problems often do not see, this time I was thinking, if there can be a god to guide me, tell me what can be done better, it should have much good. The company has no code review, colleagues are busy, do not know the Internet, this kind of time, can only Google. I was pleasantly surprised to find that Google engineers had already taken the newbie situation into account and provided Lint tools in Studio to help scan code and suggest changes. Know such a good tool, quickly learn.

What help can the Lint tool provide?

Post an official paragraph about Lint

How to use Lint

Toolbar -> Analyze -> Inspect Code… Click Inspect Code to bring up the following pop-up box



Step to find useless files: Select the content you want to examine (folder, a file, moudle, etc.) right click -> Analyze -> Run Inspection By Name.. Enter Unused, select Unused resources, and Lint will start checking. On success, Unused files will be displayed.

That’s how simple it is to use Lint, but we need to figure out what general problems the tool can solve. Generally speaking, the Error flag is the need to pay attention to the existence of serious errors, such as the possibility of memory leaks, static references. Warning Is a warning, and most of the checked information is a warning. Lint can give a lot of advice on how to improve code, just a few examples I’ve come across myself in my modifications.

  1. Typo: Don’t underestimate spelling mistakes. Too many can make people look overwhelmed and unprofessional.
  2. Code that is redundant, such as int A = 0, prompts you for Declaration redundancy
  3. The Field can be converted to a local variable in ___
  4. Change the modifier, for example, pubLic suggests changing to private :Can be private
  5. Unused: Unused declaration
  6. The package Unused import is referenced
  7. Probable places for bugs: Probable bugs (such as null Pointers)…… Lint comes with a lot of rules to check, one by one is not realistic, encounter a word you don’t understand, just search for it. Lint is not always correct. Lint is not always correct.

Lint is just a few steps away from using it to make your code more formal. When you see those prompts, you’ll be glad you have this tool. It will help you catch bugs and remind you that the more details you have, the more you can’t ignore them.

In the process of learning, found a more comprehensive article, certainly better than I write, ha ha, it is worth a look. Link: blog.csdn.net/u011240877/…