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.8k
ミスを少なくする明日からの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.5k
RecyclerViewで 折れ線グラフを作る
amyu
2
400
Sliceのアレコレ
amyu
1
150
ビルド時間を1分短くするためにやったこと
amyu
0
780
Other Decks in Programming
See All in Programming
Better Code Design in PHP
afilina
PRO
0
130
受け取る人から提供する人になるということ
little_rubyist
0
250
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
110
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
Functional Event Sourcing using Sekiban
tomohisa
0
100
最新TCAキャッチアップ
0si43
0
190
イベント駆動で成長して委員会
happymana
1
340
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.3k
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
540
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
1k
cmp.Or に感動した
otakakot
3
200
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
31
6.3k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
How GitHub (no longer) Works
holman
310
140k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
For a Future-Friendly Web
brad_frost
175
9.4k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Rails Girls Zürich Keynote
gr2m
94
13k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
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/