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
83
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
第13回 Data-Centric AI勉強会, 画像認識におけるData-centric AI
ksaito_osx
0
370
データマネジメントのトレードオフに立ち向かう
ikkimiyazaki
6
950
Nekko Cloud、 これまでとこれから ~学生サークルが作る、 小さなクラウド
logica0419
2
960
人はなぜISUCONに夢中になるのか
kakehashi
PRO
6
1.6k
プロダクトエンジニア構想を立ち上げ、プロダクト志向な組織への成長を続けている話 / grow into a product-oriented organization
hiro_torii
0
120
ユーザーストーリーマッピングから始めるアジャイルチームと並走するQA / Starting QA with User Story Mapping
katawara
0
200
Data-centric AI入門第6章:Data-centric AIの実践例
x_ttyszk
1
400
2/18/25: Java meets AI: Build LLM-Powered Apps with LangChain4j
edeandrea
PRO
0
110
Moved to https://speakerdeck.com/toshihue/presales-engineer-career-bridging-tech-biz-ja
toshihue
2
740
次世代KYC活動報告 / 20250219-BizDay17-KYC-nextgen
oidfj
0
250
技術負債の「予兆検知」と「状況異変」のススメ / Technology Dept
i35_267
1
1.1k
Tech Blogを書きやすい環境づくり
lycorptech_jp
PRO
1
240
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Mobile First: as difficult as doing things right
swwweet
223
9.3k
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.5k
Speed Design
sergeychernyshev
27
790
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.2k
Side Projects
sachag
452
42k
Done Done
chrislema
182
16k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
46
2.3k
The Invisible Side of Design
smashingmag
299
50k
Bash Introduction
62gerente
611
210k
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を使って簡単に独自ルールが
作れる