Blog Infos
Author
Published
Topics
Published
Topics

While developing software, we often tend to follow certain architectures, design patterns and best practices. One of the most important practice is to continuously run Lint Checks. Let’s learn about what Lint is and how to effectively apply Android Lint to existing projects.

What is Lint?

Lint, or a linter, is a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs.

Why do Lint checks?
  • Reduce syntax errors
  • Makes code more intuitive
  • Helps get rid of deprecated code practices
  • Reminds for added TODOs
Android Lint —

Gradle Wrapper offers Lint check by a simple command 😁 —

Windows —

gradlew lint

Linux or Mac —

./gradlew lint

These commands do a complete project level check for Lint Issues and create an HTML file providing details about each at the following path —

/app/build/reports/lint-results-debug.html

The generated HTML while when opened in a browser provides lint issues along with their explanations.

This isn’t it, Android Lint not only checks for lint issues but also checks for performance, security, accessibility and much more. ✨

https://developer.android.com/static/studio/images/write/lint.png

lint.png

As the title of the article says — existing project, let’s talk about that. 😅

An existing project probably a few years old will certainly have 1000s of lint issues if never taken into consideration. Thus, it won’t be possible to fix these in one go. But in order to reduce future tech debt, it can be followed that new lint issues are fixed as they are added.

Job Offers

Job Offers

There are currently no vacancies.

OUR VIDEO RECOMMENDATION

,

Custom_lint: write lints and fixes

Warnings, quick fixes, and refactorings are effective tools for making code more maintainable. But the Dart SDK doesn’t always provide one for your use case. In that scenario, you may want to build custom ones.
Watch Video

Custom_lint: write lints and fixes

Remi Rousselet
Open-source software engineer
Invertase

Custom_lint: write lints and fixes

Remi Rousselet
Open-source software ...
Invertase

Custom_lint: write lints and fixes

Remi Rousselet
Open-source software engi ...
Invertase

Jobs

No results found.

Android Lint offers creating a baseline file that stores all lint issues found in first run and then use it for future inspection runs so that only new issues are reported. In order to do this, simply add the below code in your app level build.gradle

android {
    lintOptions {
        baseline file("lint-baseline.xml")
    }
}

In successive runs of the above lint command, only new lint issues will be shown in terminal. This makes lint issues going forward much more identifiable and easy to monitor. 👏

Conclusion —

We saw how easy it is to use Android Lint and maintain the code quality of existing Android Projects, thus reducing future tech debt.

This article was originally published on proandroiddev.com on October 29, 2022

YOU MAY BE INTERESTED IN

YOU MAY BE INTERESTED IN

blog
It’s one of the common UX across apps to provide swipe to dismiss so…
READ MORE
blog
In this part of our series on introducing Jetpack Compose into an existing project,…
READ MORE
blog
This is the second article in an article series that will discuss the dependency…
READ MORE
blog
Let’s suppose that for some reason we are interested in doing some tests with…
READ MORE

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Menu