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
自動で //nolint を挿入する取り組み / Gopher's Gathering
Search
utagawa kiki
January 18, 2025
Programming
1
1k
自動で //nolint を挿入する取り組み / Gopher's Gathering
https://connpass.com/event/329963/
utagawa kiki
January 18, 2025
Tweet
Share
More Decks by utagawa kiki
See All by utagawa kiki
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
1
170
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
2.3k
君たちはどうコードをレビューする (される) か / 大吉祥寺.pm
utgwkk
21
15k
Dive into gomock / Go Conference 2024
utgwkk
14
7.6k
Goでリフレクションする、その前に / Kansai.go #1
utgwkk
4
3.6k
Go製Webアプリケーションのエラーとの向き合い方大全、あるいはやっぱりスタックトレース欲しいやん / Kyoto.go #50
utgwkk
7
4.2k
ありがとう、create-react-app
utgwkk
4
11k
mockgenによるモック生成を高速化するツール bulkmockgenのご紹介 / Kyoto.go #43
utgwkk
2
2.4k
SPAでもデータをURLでシェアしたい / Kyoto.js 19
utgwkk
2
1.9k
Other Decks in Programming
See All in Programming
AIでLINEスタンプを作ってみた
eycjur
1
220
旅行プランAIエージェント開発の裏側
ippo012
1
520
令和最新版手のひらコンピュータ
koba789
14
8.2k
エンジニアのための”最低限いい感じ”デザイン入門
shunshobon
0
130
20250808_AIAgent勉強会_ClaudeCodeデータ分析の実運用〜競馬を題材に回収率100%の先を目指すメソッドとは〜
kkakeru
0
210
AHC051解法紹介
eijirou
0
640
testingを眺める
matumoto
1
130
学習を成果に繋げるための個人開発の考え方 〜 「学習のための個人開発」のすすめ / personal project for leaning
panda_program
1
110
rage against annotate_predecessor
junk0612
0
140
Updates on MLS on Ruby (and maybe more)
sylph01
1
160
サーバーサイドのビルド時間87倍高速化
plaidtech
PRO
0
670
オープンセミナー2025@広島LT技術ブログを続けるには
satoshi256kbyte
0
150
Featured
See All Featured
Designing for humans not robots
tammielis
253
25k
[RailsConf 2023] Rails as a piece of cake
palkan
56
5.8k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
830
Scaling GitHub
holman
463
140k
Faster Mobile Websites
deanohume
309
31k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
284
13k
Rails Girls Zürich Keynote
gr2m
95
14k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
19k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.9k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.5k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.6k
Visualization
eitanlees
147
16k
Transcript
自動で //nolint を 挿入する取り組み id:utgwkk / @utgwkk (うたがわきき) 2025/1/18 Gopher's
Gathering 1
自己紹介 (1) • うたがわきき (@utgwkk) ◦ 京都在住 ◦ 実は福岡出身 •
株式会社はてな ◦ Webアプリケーションエンジニア 2
自己紹介 (2) • 好きなパッケージ ◦ reflect ◦ go/ast 3
推しグルメ (1) 元祖 長浜屋 4
推しグルメ (1) 元祖 長浜屋 5
推しグルメ (2) ビアキチ 6
アジェンダ • golangci-lintの //nolint directiveを自動で 挿入するCLIツール autonolint を作った - 私
が歌川です • https://github.com/utgwkk/autonolint 7
golangci-lintについて • https://golangci-lint.run/ • Goのlinterをまとめて実行するrunner • アンケート: golangci-lintを使っている? 8
あらすじ • ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56 9
立ち位置 10 enable-allして disableする disable-allして enableする
立ち位置 11 enable-allして disableする disable-allして enableする ゆるやかに enableする
モチベーション • golangci-lintで有効にするlinterをあとから 増やしたい • 既存のコードが警告されまくる!!! • たすけて〜〜 12
//nolint:xxx • 指定した行 (ブロック) でだけlinterの警告を 抑制するためのコメント (directive) • これを自動で入れていけば勝てる 13
Q. exclude-rulesじゃダメなの • 同じファイル内でも新しく書くコードでは linterを有効にしたい • あとから直すきっかけを作りやすくする ◦ コメントがoutdatedなら解決できるはず ◦
コロケーション的な思想 14
DEMO VSCode開いてください 15
実装 (1) • golangci-lintの実行結果をパース ◦ 実はJSON形式で出力できる ▪ --out-format=json ◦ 入力を加工する機能を丸投げ
16
実装 (2) • //nolint を挿入すべき行を特定 • 行ごとに書き出しつつ //nolint を挿入 ◦
bufio.NewScanner 便利 17
実装 (3) • テストではgolangci-lintを実際に走らせる • autonolintを適用した後のコードで警告が出 ないことを確かめる • E2Eテストみたいな感じですね 18
今後の課題 • うまく動かないパターンもあるかも ◦ 既に別の //nolint が書いてある行とか ◦ 気づいたときに直します 19
関連研究 • https://github.com/mizdra/eslint-intera ctive ◦ eslint-disable-next-lineするかどうかなどを インタラクティブに指定できる ◦ 丁寧 20
まとめ • golangci-lintの //nolint directiveを自動で 挿入するCLIツール autonolint を作った - 私
が歌川です • https://github.com/utgwkk/autonolint 21