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
Quick introduction to scalafix
Search
Rikito Taniguchi
January 19, 2019
Technology
1
190
Quick introduction to scalafix
Scala fukuoka 2019 LT
Rikito Taniguchi
January 19, 2019
Tweet
Share
More Decks by Rikito Taniguchi
See All by Rikito Taniguchi
Why Wasm+WASI for Scala
tanishiking
0
84
Scala to WebAssembly: Exploring the How and Why
tanishiking
0
1.5k
Scala to WebAssembly #scala_waiwai
tanishiking
0
1.4k
Scala Days Madrid 2023 参加レポート
tanishiking
0
70
Tooling for Scala3
tanishiking
0
380
API-Based Code Search
tanishiking
0
43
Things happening before start coding with Metals ~behind the curtain of daily coding~
tanishiking
0
580
How we replaced a 10-year-old Perl product using Scala
tanishiking
14
33k
Format things with scalafmt
tanishiking
1
2k
Other Decks in Technology
See All in Technology
わたしのOSS活動
kazupon
2
340
AIエージェント入門
minorun365
PRO
30
16k
PHPで印刷所に入稿できる名札データを作る / Generating Print-Ready Name Tag Data with PHP
tomzoh
0
180
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
18k
EDRの検知の仕組みと検知回避について
chayakonanaika
11
4.5k
ディスプレイ広告(Yahoo!広告・LINE広告)におけるバックエンド開発
lycorptech_jp
PRO
0
280
1行のコードから社会課題の解決へ: EMの探究、事業・技術・組織を紡ぐ実践知 / EM Conf 2025
9ma3r
8
3.3k
Apache Iceberg Case Study in LY Corporation
lycorptech_jp
PRO
0
280
あなたが人生で成功するための5つの普遍的法則 #jawsug #jawsdays2025 / 20250301 HEROZ
yoshidashingo
2
240
NFV基盤のOpenStack更新 ~9世代バージョンアップへの挑戦~
vtj
0
340
データエンジニアリング領域におけるDuckDBのユースケース
chanyou0311
8
2.1k
データマネジメントのトレードオフに立ち向かう
ikkimiyazaki
6
1.2k
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
328
21k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
Building Adaptive Systems
keathley
40
2.4k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
4
360
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
100
18k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
Git: the NoSQL Database
bkeepers
PRO
427
65k
Building an army of robots
kneath
303
45k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3k
The World Runs on Bad Software
bkeepers
PRO
67
11k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Transcript
Quick introduction to scalafix Scala福岡 2019
About me - 谷口 力斗 / @tanishiking - 株式会社はてな -
Scala / TypeScript / Go / Perl - 高校生までは福岡に住んでました
Scalafix - https://scalacenter.github.io/scalafix/ - Refactoring and linting tool for Scala
- scala.meta - Builtin Rules / Suppressing Rules - Linter - 独自ルールを作ろう
Scala.meta
Scala.meta - https://scalameta.org/ - Scala compiler とは独立した Scala プログラム 解析のためのライブラリ
- Syntactic API - Semantic API
Scala.meta - Syntactic API - Scalaプログラムをパースしトークン列や構文木 を返すAPI println("function(argument)".parse[Stat].get.struct ure) //
Term.Apply(Term.Name("function"), List(Term.Name("argument")))
Scala.meta - Semantic API - 型情報やシンボルの情報を提供するAPI - compiler plugin を使って
typer phase の後に SemanticDB を生成 - SemanticDB - protobuf で定められたスキーマに従ってシリ アライズされたバイナリ
Builtin Rules / Supressing Rules
Builtin Rules - https://scalacenter.github.io/scalafix/docs/rul es/overview.html // .scalafix.conf rules = [
DisableSyntax, RemoveUnused ]
Suppressing Rules @SuppressWarnings(Array("all")) def foo = ??? List("", null) //
scalafix: ok // scalafix: off foo(null) // scalafix: on
Linter
Linter - v0.5 から linter としての機能が豊富に - 将来的に metals (scala.meta
ベースの Language Server 実装) から scalafix を使った refactoring や lint の提供も
Lint (vs wartremover) - (+) Lintに加えて自動修正もできる - (+) syntactic rulesの実行にコンパイルは不要
なので高速 - (+) 独自ルールの実装が容易(wart実装も難しくないけど) - (-) Builtin rule が少ない - (-) scala compiler と比べて SemanticDB から取 得できる情報は制限される
独自ルールを 作ろう
独自ルールを作ろう https://scalacenter.git hub.io/scalafix/docs/d evelopers/setup.html
独自ルールを作ろう - 作ってみた https://github.com/tanishiking/scalafix-check-scaladoc - publicなAPIにscaladocが書かれてなかったら 怒ってくれるルール - golintとかにあるやつ
まとめ - scalafix は refactoring ツールとしてだけでなく linter としても使える - scala.metaのAPIを使って簡単に独自ルールが
作れる