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
Analyze your changeset in a branch before git p...
Search
Janos Gyerik
November 23, 2016
Technology
390
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
Transcript
25 slides
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?
More Decks by Janos Gyerik
See All by Janos Gyerik
Capture The Flag at SonarSource 2019
janosgyerik
1
50
Keyboard shortcuts
janosgyerik
0
160
Analyze your changeset in a branch before git push using SonarLint + Git hooks; Round #2
janosgyerik
0
660
Unwatch GitHub repos
janosgyerik
0
330
Code Reviews
janosgyerik
0
170
Playing with Yahoo! Pipes
janosgyerik
0
300
Cool features of GitHub
janosgyerik
0
1.4k
Time-saving tricks on the command line
janosgyerik
1
4.5k
Other Decks in Technology
See All in Technology
gradle-best-practices 使ってみた
mikanichinose
0
230
信頼性を犠牲にせず、PR マージからデプロイまで人の介入を完全にゼロにするまでの道のり
knwoop
4
2.1k
社内アプリ基盤「Quartz」による、 非エンジニアとAIに本番デプロイを 任せても壊れないプラットフォームの設計
staka121
PRO
1
230
Agent Routerで作るマルチテナント 推論基盤 #CNDW2026 / Building Multi-Tenant Inference Platform with Agent Router #CNDW2026
everpeace
5
610
Terraform 0 to 100:100個以上のリポジトリを常に最新にし続けるための自動化
sue445
3
1.4k
コピーオンライト型ファイルシステムと ランダム書き込み
sat
PRO
2
140
[DBRE Summit 26] DBRE はデータベース運用をどう変えたのか
_awache
0
130
【Oracle AI SPOTLIGHT ウェビナー】AI時代、狙われるデータと止められない業務をどう守るか?
oracle4engineer
PRO
1
140
成長するID管理基盤における運用もコストも犠牲にしないオブザーバビリティ向上の実践 / Improving Observability for a Growing Identity Platform Without Adding Operational Burden or Cost
kaminashi
1
130
Context parameters で作る!はじめての型クラス
kworkdev
PRO
1
180
ワークフローからハーネスへ — Web フレームワークの作者たちが AI エージェントに向かう理由
azukiazusa1
4
1.9k
Libérez Firefox et Thunderbird avec nos astuces
hellosct1
0
120
Featured
See All Featured
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
370
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
61k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.5k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k
Typedesign – Prime Four
hannesfritz
42
3.2k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.4k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
1
320
Raft: Consensus for Rubyists
vanstee
143
7.9k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
570
Producing Creativity
orderedlist
PRO
348
41k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.3k