Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ミスを少なくする明日からのCustom Lint Rules
Search
Yuki Mima
January 20, 2017
Programming
0
1.9k
ミスを少なくする明日からのCustom Lint Rules
kyobashi.dex #4
https://rmp-quipper.connpass.com/event/47555/
Yuki Mima
January 20, 2017
Tweet
Share
More Decks by Yuki Mima
See All by Yuki Mima
スタディサプリENGLISHの今と攻めの開発 ~MotionLayout入れてみた~
amyu
0
1.6k
RecyclerViewで 折れ線グラフを作る
amyu
2
410
Sliceのアレコレ
amyu
1
150
ビルド時間を1分短くするためにやったこと
amyu
0
780
Other Decks in Programming
See All in Programming
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
たのしいparse.y
ydah
3
120
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
Spatial Rendering for Apple Vision Pro
warrenm
0
110
Haze - Real time background blurring
chrisbanes
1
520
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
850
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
260
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
940
これでLambdaが不要に?!Step FunctionsのJSONata対応について
iwatatomoya
2
3.7k
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
280
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
40
2.4k
Thoughts on Productivity
jonyablonski
67
4.4k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Building an army of robots
kneath
302
44k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
99
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
450
A Modern Web Designer's Workflow
chriscoyier
693
190k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
520
Transcript
ϛεΛগͳ͘͢Δ໌͔Βͷ Custom Lint Rules kyobashi.dex #4 @amyu_san
About me ▸ Name : Yuki Mima ▸ Twitter :
@amyu_san
Lint Rulesͱ ▸ ੩తղੳπʔϧ ▸ ./gradlew lint Ͱ࣮ߦͰ͖Δ ▸ ࣮ߦ݁ՌDefaultͰ
/app/build/outputs/lint-results-yourFlavor.xml /app/build/outputs/lint-results-yourFlavor.html
TEXT Custom Lint Ruleͷ࡞खॱ ▸ Detector : ΦϦδφϧͷ੩తղੳΛߦ͏߲ͷࢦఆ ▸ DetectorTest
: DetectorͷTest ▸ Registry : DetectorΛొ?͢Δ
Detector ▸ LayoutDetector ▸ app/src/hoge/res/layout Λର ▸ JavaScanner ▸ Java
Code Λର ▸ ClassScanner ▸ Java class files Λର
AccessibilityDetector ▸ layout xmlʹ͋ΔTag໊͕ImageView·ͨImageButton͕ଘࡏ͢ΔTag͕ ੩తղੳର ▸ contentDescriptionଐੑͷValue͕ۭจࣈ͔”TODO”ͷΈࢦఆ͞Ε͍ͯΔ ߹ʹܯࠂ͞ΕΔ ▸ contentDescriptionଐੑͱimportantForAccessibilityଐੑ͕྆ํଘࡏ͠
ͳ͍߹ʹܯࠂ͞ΕΔ ▸ android:contentDescriptionଐੑ͕ଘࡏ͢ΔTag͕੩తղੳର ▸ contentDescriptionଐੑͱhintଐੑ͕ಉ࣌ʹҰͭͷTagʹଘࡏ͢Δͱ͖ ܯࠂ͞ΕΔ
None
getApplicableElementsʹ͍ࠪͨ͠Tag(View)໊Λฦ ͢ visitElements(…)ʹTagใ͕ؼͬͯ͘Δ ImageView·ͨImageButtonͷTag໊Λ࣋ͭTag͕ ࠪͷରʹͳΔ
getApplicableAttributesʹ͍ࠪͨ͠ଐੑΛฦ͢ visitAttributes(…)ʹTagใ͕ؼͬͯ͘Δ android:contentDescriptionଐੑΛ࣋ͭTag͕ࠪͷର ʹͳΔ
Tag(View)ʹcontentDescriptionଐੑ͕ଘࡏ͢Δͱ͖ android:hintଐੑಉ࣌ʹએݴ͍ͯͨ͠߹ܯࠂΛग़ ͢ getApplicableAttributesʹࢦఆ͍ͨࠪͨ͠͠Tag͕ Callback͞ΕΔ contentDescriptionଐੑΛ࣋ͭTagͷใ͕ೖͬͯΔ ↓
getApplicableElementsʹࢦఆ͍ͨࠪͨ͠͠ Tag͕Callback͞ΕΔ Tag(View)໊͕ImageView·ͨImageButtonͷͱ͖ - android:contentDescriptionଐੑͱandroid:importantForAccessibilityଐੑ͕ͳ͍߹ܯࠂΛग़͢ - android:contentDescriptionଐੑ͕ଘࡏ͠Ŋvalueʹۭจࣈ·ͨTODOͱ͍͏จࣈͷ߹ܯࠂΛग़͢ ↑ | |
ImageView·ͨImageButtonͷTagΛ࣋ͭTagͷใ͕ೖͬͯΔ
Tag໊Λࢦఆ͠੩తղੳ
ଐੑΛࢦఆ͠੩తղੳ
ݟʹͳΔLint ▸ DeprecationDetector https://android.googlesource.com/platform/tools/base/+/master/lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/DeprecationDetector.java?autodive=0%2F ▸ editableଐੑͳͲDeprecatedʹͳͬͨଐੑΛ༻͢Δͱ ܯࠂग़ͯ͘͠ΕΔ ▸ ToastDetector https://android.googlesource.com/platform/tools/base/+/master/lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/ToastDetector.java?autodive=0%2F
▸ ToastΛ༻࣌ʹshow͕ݺΕ͍ͯͳ͍ͱܯࠂͯ͘͠ΕΔ
Ͱ͖ͳ͔ͬͨ͜ͱ ࠔͬͯΔ͜ͱ ▸ ͳΜ͔KotlinͰॻ͜͏ͱͨ͠ΒΤϥʔग़ͯॻ͚ͳ͔ͬͨ ▸ ୭͔Γํڭ͍͑ͯͩ͘͞ ▸ CircleCIͰ./gradlew lint Λ࣮ߦ͕ͨ͠ŊSeverity͕Errorͳ
ͷΛWarningʹมߋ͞ΕͯΔΑ͏ͳؾ͕ͨ͠ ▸ ୭͔ڭ͍͑ͯͩ͘͞ ▸ ࠓ࣮ߦ݁ՌͷxmlΛParseͯ͠CIΛFailͤͯ͞Δ
ࢀߟࢿྉ ▸ Custom Lint Rules ▸ http://qiita.com/hotchemi/items/9364d54a0e024a5e6275 ▸ ϛεΛগͳ͘͢Δ໌͔ΒͷCustom Lint
Rules ▸ http://qiita.com/amyu_san/items/b6b674693eefaae2b4bc ▸ طଘͷιʔε ▸ https://android.googlesource.com/platform/tools/base/+/ master/lint/libs/lint-checks/src/main/java/com/android/tools/ lint/checks?autodive=0/