lint.xml
파일을 작성하여 warning을 제한하거나, warning의 severity 레벨을 설정할 수 있다. lint.xml
파일은 프로젝트의 root directory에 위치시켜야 한다. lint.xml
파일의 예시는 다음과 같다. 기본 설정된 lint를 이용할 때는 작성하지 않아도 된다.<?xml version="1.0" encoding="UTF-8"?>
<lint>
<!-- Disable the IconMissingDensityFolder check in this project -->
<issue id="IconMissingDensityFolder" severity="ignore" />
<!-- Ignore the ObsoleteLayoutParam issue in the specified files -->
<issue id="ObsoleteLayoutParam">
<ignore path="res/layout/activation.xml" />
<ignore path="res/layout-xlarge/activation.xml" />
</issue>
<!-- Ignore the UselessLeaf issue in the specified file -->
<issue id="UselessLeaf">
<ignore path="res/layout/main.xml" />
</issue>
<!-- Change the severity of hardcoded strings to "error" -->
<issue id="HardcodedText" severity="error" />
</lint>
./gradlew lint
./gradlew lintDebug
./gradlew lintRealease
lint
: 기본 lint 실행lintRelease
: build variants가 있는 경우에 이용.아래와 같이 터미널에 나타난다.
링크를 클릭하면 다음과 같이 Lint Report를 볼 수 있다.
아래와 같이 Problem에 표시된다.
Android Lint
Android Lint는 앱 실행 또는 테스트케이스 작성 없이 코드의 구조적 품질 문제를 감지하고 수정이 가능하다. 만약 안드로이드 스튜디오를 사용할 경우 앱을 빌드할 때마다 Lint 검사가 기본적으로 실행된다.
ktlint
ktlint를 사용하면 코틀린 스타일 가이드에 맞게 코드를 다듬어 줄 수 있다.
detekt
detekt는 코드 포맷팅을 해주기보다 잠재적 버그를 찾아주고 코드 복잡성, 성능 저하 포인트를 집어준다.
REFERENCE
1. 만화경 Android App 설정하고 개발하기 | 우아한 형제들 기술 블로그
2. Kotlin Style Guide | Android Developers
3. square/java-code-styles | Github
4. Improve your code with lint checks | Android Developers
레퍼런스 너무 깔끔하게 정리해두셨네요~ 현지님 블로그는 정말 읽기 편하고 정리가 잘되어 있는 것 같아요! 항상 응원해요 ㅎㅎ