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
Analyze your changeset in a branch before git p...
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Janos Gyerik
November 23, 2016
Technology
370
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Analyze your changeset in a branch before git push using SonarLint + Git hooks
Janos Gyerik
November 23, 2016
More Decks by Janos Gyerik
See All by Janos Gyerik
Capture The Flag at SonarSource 2019
janosgyerik
1
45
Keyboard shortcuts
janosgyerik
0
150
Analyze your changeset in a branch before git push using SonarLint + Git hooks; Round #2
janosgyerik
0
660
Unwatch GitHub repos
janosgyerik
0
320
Code Reviews
janosgyerik
0
160
Playing with Yahoo! Pipes
janosgyerik
0
270
Cool features of GitHub
janosgyerik
0
1.4k
Time-saving tricks on the command line
janosgyerik
1
4.4k
Other Decks in Technology
See All in Technology
なぜ人は自分のプロジェクトを 「なんちゃってアジャイル」と 自嘲するのか
kozotaira
0
280
LLMやAIエージェントをソフトウェアに組み込むプラクティス
shibuiwilliam
1
300
依頼文化をやめる日 EM視点で語るPlatform EngineeringとInclusive SRE / Discussing Platform Engineering and Inclusive SRE from an EM's Perspective
shin1988
4
5k
Terraform共通モジュールをチーム横断で“変えられる”運用へ ― リリースと適用の分離
kekke_n
1
2.5k
事業価値を⽣み出すSREへ SREが担うべき意思決定の5層
kenta_hi
2
3.2k
ruby.wasmとPicoRuby.wasmに対応した仮想DOMライブラリを作ってる話 #kaigieffect_kaigi
sue445
PRO
0
130
FinOps X 2026 Recap from Engineer Side #JapanFinOps
chacco38
0
270
テスト設計の本質を改めて考えてみる~生成AIを活用する時代だからこそ、作ったテストの説明性を高めよう~
yamasaki696
1
460
プロンプト_きのこカンファレンス2026_LT
yurufuwahealer
0
150
GuardrailからGovernanceへ~AIエージェント運用の次の課題~
sbspsy
1
260
CIで使うClaude
iwatatomoya
0
220
Docker Desktop不要の時代が来る? WSL標準の「wslc」で Linuxコンテナを動かしてみた.
ueponx
0
890
Featured
See All Featured
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Faster Mobile Websites
deanohume
310
32k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
190
First, design no harm
axbom
PRO
2
1.2k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6k
The Curse of the Amulet
leimatthew05
2
13k
Designing Powerful Visuals for Engaging Learning
tmiket
1
450
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
260
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Being A Developer After 40
akosma
91
590k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
180
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
Transcript
ANALYZE YOUR CHANGESET IN A BRANCH BEFORE GIT PUSH WITH
SONARLINT + GIT HOOKS https://speakerdeck.com/janosgyerik/sonarlint-before-git-push
Let’s talk about SonarTech… (aka sonar-github) SonarTech
SonarTech
SonarTech
SonarTech
SonarTech
None
You think you coded a great branch… You think “there
should be no more issues”… … sorry bud, you thought wrong!
Delay to generate comments git push fixes -> more delays
-> -> more issues -> git push fixes ->
Don’t get me wrong This is absolutely necessary But would
you push a branch if you *knew* it has 10+ issues? (-> no)
Let’s talk about
SonarLint helps, but you have to look… …it’s harder than
it sounds
Example * Open SonarLint view * Build gets broken *
(SonarLint view gone…)
build broken
Example * Open SonarLint view * Run unit tests *
(SonarLint view gone…)
run unit tests
SonarLint can help, but you have to look! Sooner or
later you cannot help and lose sight of the SonarLint view, and SonarLint just cannot force you to look, not all the time, that’s just the way it is
+ = cli hooks
$ sonarlint --src path/to/file1 --tests path/to/file2
$ ls -1 .git/hooks/ applypatch-msg.sample commit-msg.sample post-update.sample pre-applypatch.sample pre-commit.sample pre-push.sample
pre-rebase.sample prepare-commit-msg.sample update.sample
Let’s see it in action
$ git push origin HEAD info: source files to analyze:
info: src/main/java/example/HelloWorld.java info: src/main/java/example/Two.java info: analyzing... ------------- SonarLint Report ------------- 3 issues (2 files analyzed) 2 major 1 info ------------------------------------------- INFO: SonarLint HTML Report generated: /Users/janos/dev/git/github/java-maven-simple/.sonarlint/ sonarlint-report.html fatal: hook abort: some analyses have failed error: failed to push some refs to '
[email protected]
:janosgyerik/java-maven-simple.git' (push rejected if issues exist)
$ git push origin HEAD info: source files to analyze:
info: src/main/java/example/HelloWorld.java info: src/main/java/example/Two.java info: analyzing... ------------- SonarLint Report ------------- No issues to display (2 files analyzed) ------------------------------------------- INFO: SonarLint HTML Report generated: /Users/janos/dev/git/github/java-maven-simple/.sonarlint/sonarlint- report.html Counting objects: 42, done. Delta compression using up to 8 threads. Compressing objects: 100% (24/24), done. Writing objects: 100% (42/42), 2.84 KiB | 0 bytes/s, done. Total 42 (delta 11), reused 0 (delta 0) remote: Resolving deltas: 100% (11/11), completed with 2 local objects. To
[email protected]
:janosgyerik/java-maven-simple.git * [new branch] HEAD -> demo (no issues -> push OK)
git clone https://github.com/janosgyerik/sonarlint-git-hooks cd sonarlint-git-hooks ./get-and-setup-sonarlint.sh hooks=$PWD cd /path/to/your/project $hooks/install.sh
cd /path/to/another/project $hooks/install.sh
https://github.com/janosgyerik/sonarlint-git-hooks/issues Problems? Ideas? Feature requests?