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
浅沼もっちゃん / Motoharu Asanuma
June 15, 2024
Programming
250
0
Share
Custom Lint Rules で独自のリントルールを作成する
浅沼もっちゃん / Motoharu Asanuma
June 15, 2024
Other Decks in Programming
See All in Programming
10年分の技術的負債、完済へ ― Claude Code主導のAI駆動開発でスポーツブルを丸ごとリプレイスした話
takuya_houshima
0
2.2k
夢の無限スパゲッティ製造機 -実装篇- #phpstudy
o0h
PRO
0
200
Radical Imagining - LIFT 2025-2027 Policy Agenda
lift1998
0
250
의존성 주입과 모듈화
fornewid
0
120
PHPのバージョンアップ時にも役立ったAST(2026年版)
matsuo_atsushi
0
300
まかせられるPM・まかせられないPM / DevTech GUILD Meetup
yusukemukoyama
0
110
飯MCP
yusukebe
0
490
AIエージェントで業務改善してみた
taku271
0
500
存在論的プログラミング: 時間と存在を記述する
koriym
5
850
Swift Concurrency Type System
inamiy
0
420
Offline should be the norm: building local-first apps with CRDTs & Kotlin Multiplatform
renaudmathieu
0
180
「接続」—パフォーマンスチューニングの最後の一手 〜点と点を結ぶ、その一瞬のために〜
kentaroutakeda
5
2.5k
Featured
See All Featured
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
110
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
96
The Curse of the Amulet
leimatthew05
1
11k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
680
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.8k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
160
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
Balancing Empowerment & Direction
lara
5
1k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
330
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
110
Transcript
Custom Lint Rulesで 独自のリントルールを作成する ※このページは削除して構いません Click 浅沼もっちゃん@momomomo111
・自己紹介 ・Custom Lint Rulesについて ・実装方法 ・まとめ
浅沼もっちゃん / momomomo111 株式会社AbemaTV / Android Based TVのアプリを作ってます。 自己紹介
そもそもLintとは、 Androidプロジェクト のソースファイルを チェックする静的解析 ツール Custom Lint Rulesについて ↑の例だと定義されて いるけどどこからも呼
び出されていないこと について警告 https://android.googlesource.com/platform/frameworks/support/+/HEAD/ docs/lint_guide.md#getting-started
Q. 警告が出て、なにが嬉しいのか? A. 警告が出ないようにコーディングすることで プロジェクトの保守性を高めるため (想定外のことや推奨を開発者に知らせてくれるええやつ) Custom Lint Rulesについて
自分で、「ええやつ」作ってみたくない?
今回つくるええやつ フィーチャーフラグの 期限の形式が ”yyyy-mm-dd”の 形式になってなかったら エラーにしたい 実装方法 https://github.com/abema/flagfit
実装方法 下準備 ・リント用のモジュールの作成 ・Issue作成、IssueRegistryの実装 ・テストを書く ・Detector()の実装
実装方法 リント用のモジュールの作成 プロジェクトのルートから モジュールを作成
依存関係追加 Lintモジュールの build.gradleへ追記 実装方法
Issue作成 警告で出したい文言や プライオリティなどを定義 実装方法
IssueRegistryの実装 先ほど登録したIssueを登録 実装方法
IssueRegistryの実装 com.android.tools.lint.cli ent.api.IssueRegistryに IssueRegistryのフルパス を追加 実装方法
IssueRegistryの実装 Lintモジュールの build.gradleへの 追記も忘れずに 実装方法
Q. なぜテストから書くか? A. 正しくリントが動くかの動作の保証がシンプル ・Lintのライブラリ内で完結 ・差分が明確で、軽量 実装方法
テストを書く testモジュールを切る 実装方法
テストを書く ・LintDetectorTestを継承 して実装 ・DetectorとIssueを設定 実装方法
テストを書く ・独自クラスもここで定義 しなければならない ・expectは一旦適当wipで OK 実装方法
テストを書く ・量が多くなったら TestFileで他のobjectに 書き出してテスト関数は シンプルにできる 実装方法
Detector()の実装 ・ここで構文解析。一致す る条件の場合にメッセージ と一緒にレポート ・終わったらテストを実行 して調整 実装方法
使用するプロジェクト のbuild.gradle ファイルから呼び出し 使用方法
動作確認 ちゃんと期待通りの結果が 出ていることを確認 使用方法
・Custom Lint Rulesを実装することで柔軟にLint を設定できる ・テストから書いて土台を作る方が検証しやすい ・今日話した実装内容は下記リポジトリにあります →https://github.com/abema/flagfit まとめ