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
生成 AI を活用した toitta 切片分類機能の裏側 / Inside toitta's AI-Based Factoid Clustering
pokutuna
0
570
カスタムしながら理解するGraphQL Connection
yanagii
1
1.2k
Vitest Browser Mode への期待 / Vitest Browser Mode
odanado
PRO
2
1.7k
Pinia Colada が実現するスマートな非同期処理
naokihaba
2
150
のびしろを広げる巻き込まれ力:偶然を活かすキャリアの作り方/oso2024
takahashiikki
1
410
hotwire_or_react
harunatsujita
8
4k
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
150
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
430
外部システム連携先が10を超えるシステムでのアーキテクチャ設計・実装事例
kiwasaki
1
220
Golang と Erlang
taiyow
8
1.9k
Honoの来た道とこれから
yusukebe
19
3k
Realtime API 入門
riofujimon
0
110
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
72
5.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
Documentation Writing (for coders)
carmenintech
65
4.4k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
231
17k
Designing for Performance
lara
604
68k
Automating Front-end Workflow
addyosmani
1365
200k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Six Lessons from altMBA
skipperchong
26
3.5k
The Language of Interfaces
destraynor
154
24k
KATA
mclloyd
29
13k
The Art of Programming - Codeland 2020
erikaheidi
51
13k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
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/