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
中期計画、2回作ってみた ~業務委託と正社員、両方の視点から~
demaecan
1
920
AmazonRoute 53ではじめてのドメイン取得!HTTPS化までの道のりを整理してみた
usanchuu
3
150
SONiCの統計情報を取得したい
sonic
0
190
気軽に使える"情報のハブ"としてのNotion活用 〜フロー情報の集積点 と、 Claude Code × Notion AI〜
syucream
1
150
機械学習を「社会実装」するということ 2026年夏版 / Social Implementation of Machine Learning June 2026 Version
moepy_stats
6
2.5k
AIっぽい文章を採点して人間らしく直すアプリを作ってみた
yama3133
2
210
脱SaaS!FDEを支えるプロビジョニングと分離設計
knih
0
140
日本 Fintech 未来予測レポート 2027〜2028年(オリジナル版)
8maki
0
2.3k
やさしいA2A入門
minorun365
PRO
12
1.9k
自律型AIエージェントは何を破壊するのか
kojira
0
160
いまさら聞けない「仕様駆動開発入門」 〜AI活用時代の開発プロセスを考える〜
findy_eventslides
2
150
iAEONの段階的リアーキテクト戦略 / iAEON's_Gradual_Re-architecture_Strategy
aeonpeople
0
220
Featured
See All Featured
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
210
Six Lessons from altMBA
skipperchong
29
4.3k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
600
Game over? The fight for quality and originality in the time of robots
wayneb77
1
200
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
150
Building an army of robots
kneath
306
46k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.5k
AI: The stuff that nobody shows you
jnunemaker
PRO
8
720
A better future with KSS
kneath
240
18k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
330
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?