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
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.6k
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
Outline View in SwiftUI
1024jp
1
330
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
as(型アサーション)を書く前にできること
marokanatani
10
2.7k
C++でシェーダを書く
fadis
6
4.1k
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
330
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
Featured
See All Featured
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
130
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Designing for Performance
lara
604
68k
Making Projects Easy
brettharned
115
5.9k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Docker and Python
trallard
40
3.1k
Why Our Code Smells
bkeepers
PRO
334
57k
Typedesign – Prime Four
hannesfritz
40
2.4k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
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/