Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
自動で //nolint を挿入する取り組み / Gopher's Gathering
Search
utagawa kiki
January 18, 2025
Programming
3.5k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
自動で //nolint を挿入する取り組み / Gopher's Gathering
https://connpass.com/event/329963/
utagawa kiki
January 18, 2025
More Decks by utagawa kiki
See All by utagawa kiki
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
2
1.6k
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
4.7k
tparseでgo testの出力を見やすくする
utgwkk
2
2.3k
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
4
2.8k
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
4.6k
君たちはどうコードをレビューする (される) か / 大吉祥寺.pm
utgwkk
21
17k
Dive into gomock / Go Conference 2024
utgwkk
14
8.8k
Goでリフレクションする、その前に / Kansai.go #1
utgwkk
4
3.8k
Go製Webアプリケーションのエラーとの向き合い方大全、あるいはやっぱりスタックトレース欲しいやん / Kyoto.go #50
utgwkk
7
4.4k
Other Decks in Programming
See All in Programming
一人だけ、Kiroが静止する日
hideg
0
120
スマートフォンでモールス信号を送受信する 〜スマートフォンのLEDとカメラで作る光通信の設計と実装〜
atsuki_seo
0
160
Jetpack Compose メカニズム
skydoves
0
450
Security issues being discussed on Web Platforms
petamoriken
0
980
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
3
360
cdk deploy JawsSonic #MARATHONしながらAWSリソースをデプロイしてみよう
akihisaikeda
2
140
What We Talk About When We Talk About XP
m_seki
2
660
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
4
2.8k
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
7.6k
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
4.8k
XHTMLが残したもの
yosuke_furukawa
PRO
2
820
XP祭りでしか伝わらないフリップネタ #xpjug
murabayashi
0
150
Featured
See All Featured
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
480
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
420
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
SEO for Brand Visibility & Recognition
aleyda
0
4.7k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
460
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
Done Done
chrislema
186
16k
The SEO Collaboration Effect
kristinabergwall1
1
570
Faster Mobile Websites
deanohume
310
32k
The Language of Interfaces
destraynor
162
27k
Code Review Best Practice
trishagee
74
20k
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