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
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
340
return文におけるstd::moveについて
onihusube
1
1.2k
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
210
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
3
490
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
280
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
useSyncExternalStoreを使いまくる
ssssota
6
1.2k
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
610
Zoneless Testing
rainerhahnekamp
0
120
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
160
Featured
See All Featured
Making Projects Easy
brettharned
116
6k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
Navigating Team Friction
lara
183
15k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Building Adaptive Systems
keathley
38
2.3k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Unsuck your backbone
ammeep
669
57k
Designing for Performance
lara
604
68k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
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/