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
140
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
Scala to WebAssembly #scala_waiwai
tanishiking
0
710
Scala Days Madrid 2023 参加レポート
tanishiking
0
32
Tooling for Scala3
tanishiking
0
310
API-Based Code Search
tanishiking
0
34
Things happening before start coding with Metals ~behind the curtain of daily coding~
tanishiking
0
510
How we replaced a 10-year-old Perl product using Scala
tanishiking
14
32k
Format things with scalafmt
tanishiking
1
1.7k
トランザクション技術入門
tanishiking
0
120
Scala製インタプリタをブラウザで動かす3分クッキング
tanishiking
1
180
Other Decks in Technology
See All in Technology
技術広報経験0のEMがエンジニアブランディングをはじめてみた
coconala_engineer
1
130
大規模データとの戦い方
knih
1
470
オーティファイ会社紹介資料 / Autify Company Deck
autifyhq
7
100k
初心者が行く!サーバレスWebアプリ開発の道
nagaharutogawa
0
440
HoneycombとOpenTelemetryでオブザーバビリティに入門してみる
sumiren
2
160
複数の LLM モデルを扱う上で直面した辛みまとめ
kazuyaseki
1
250
Getting started with controlling LEGO using Swift
hcrane
0
130
データ化エンジニアとしての1年を振り返る
sansantech
PRO
3
260
継続的テストモデルを実現するためにスリーアミーゴスを用いた10Xでのシフトレフトの事例
nihonbuson
3
230
Autify Company Deck
autifyhq
1
30k
統計的学習理論読み Chapter 1
kmatsui
3
910
GitHub最新情報キャッチアップ 2024年3月
dzeyelid
17
3.2k
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
14
2k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
58
14k
Automating Front-end Workflow
addyosmani
1353
200k
Learning to Love Humans: Emotional Interface Design
aarron
266
39k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
34
8.8k
Bash Introduction
62gerente
604
210k
We Have a Design System, Now What?
morganepeng
42
6.7k
Clear Off the Table
cherdarchuk
82
310k
Writing Fast Ruby
sferik
619
59k
How To Stay Up To Date on Web Technology
chriscoyier
781
250k
Unsuck your backbone
ammeep
661
56k
Code Reviewing Like a Champion
maltzj
512
39k
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を使って簡単に独自ルールが
作れる