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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
utagawa kiki
January 18, 2025
Programming
3.8k
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
Transcript
21 slides
自動で //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
More Decks by utagawa kiki
See All by utagawa kiki
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
2
1.9k
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
5.1k
tparseでgo testの出力を見やすくする
utgwkk
2
2.7k
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
4
3.1k
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
4.7k
君たちはどうコードをレビューする (される) か / 大吉祥寺.pm
utgwkk
21
18k
Dive into gomock / Go Conference 2024
utgwkk
14
8.9k
Goでリフレクションする、その前に / Kansai.go #1
utgwkk
4
3.8k
Go製Webアプリケーションのエラーとの向き合い方大全、あるいはやっぱりスタックトレース欲しいやん / Kyoto.go #50
utgwkk
7
4.5k
Other Decks in Programming
See All in Programming
テストだけで見つかる? Rubyでつくるメソッド発掘器
izawa
0
180
なぜ私たちは「現時点では」KMPの導入を見送ったのか
chigichan24
1
650
Spec-driven Development with AI
simas
PRO
0
2.3k
React Native経験者が Flutterを30⽇間触って驚いたこと
3saito
0
210
imagewebp()の向こう側: WebPはなぜ JPEG・PNGより軽いのか
yuzneri
0
160
Crash Auto Pipelines
veronikapj
1
460
AWS CDKを理解するために公式の定義を深掘って解説してみる / Understanding AWS CDK by Digging into Its Official Definition
akihisaikeda
3
370
ビジネスロジックを堅牢に~Scala 3のドメインプリミティブ~
j5ik2o
0
240
AIエージェントの「テストは通るのに本番で壊れる」を減らす
shibuiwilliam
3
140
protojson における文字化けの扱い
kazuki1023
0
470
地方こそサーバーレス — 10年続けた、顔が見えるチームで確かな基盤を / Serverless Matters Most in Regional Areas — 10 Years of Building Reliable Foundations with Close-Knit Teams
seike460
PRO
2
530
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
1.1k
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.5k
Prompt Engineering for Job Search
mfonobong
0
620
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
700
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.8k
How to train your dragon (web standard)
notwaldorf
96
6.9k
Tell your own story through comics
letsgokoyo
1
1.1k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.3k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
410
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.9k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
370
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
610