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
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
[しろおび夏祭り2026] チャットするAIから、作業するAIへ - 使われ方の変化と、その裏側で起きていること
kk0n
0
1.5k
【CEDEC2026】『Relink』を拡張せよ - 『GRANBLUE FANTASY: Relink - Endless Ragnarok』の開発速度と品質を守るCI運用
cygames
PRO
0
110
モダンフロントエンド 開発研修
recruitengineers
PRO
1
130
20260801_スクフェス大阪
kgnkhkr
1
1.1k
【CEDEC2026】コードレビュー支援ツール開発から学ぶ:LLMを用いた業務システムの実践的な運用設計と誤出力対策
cygames
PRO
0
510
toio・myCobotでフィジカルAIっぽいことを行うための検討(とりあえず調査) / フィジカルAI LT(IoTLTによる開催)
you
PRO
0
280
え?フロントエンドエンジニアの ワイがインフラも!?
puku0x
0
230
Digitization部 紹介資料
sansan33
PRO
2
7.7k
Forza Horizon 6 のテレメトリ機能で 自動運転に使えそうな学習データを集める話
henjin0
0
120
事業価値と Engineering 2026年度版
recruitengineers
PRO
19
8.2k
攻撃と防御で学ぶAI時代のプロダクトセキュリティ演習
recruitengineers
PRO
1
140
『三匹の子ぶた』から学ぶネットワークセキュリティの昔と今 / Network Security: Then and Now Through the Lens of The Three Little Pigs
nttcom
1
1.6k
Featured
See All Featured
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
320
Building Applications with DynamoDB
mza
96
7.2k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
480
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
680
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.5k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
190
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
290
Into the Great Unknown - MozCon
thekraken
41
2.7k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
66
57k
How to build a perfect <img>
jonoalderson
1
5.8k
Designing for humans not robots
tammielis
254
26k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
360
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?