SlideShare a Scribd company logo
Paco van Beckhoven
@DevPaco
Cracking the Code Review:
From Guesswork to Automated Guidance
@DevPaco #SpringIO24
Paco van Beckhoven
- 10+ years of experience
- So3ware engineer
- @ Hexagon’s Innova/on Hub
- I ❤ Code quality
About me
@DevPaco #SpringIO24
$ 316.000.000.000
@DevPaco #SpringIO24
Cost of fixing a bug
h"ps://www.func-onize.com/blog/the-cost-of-finding-bugs-later-in-the-sdlc
@DevPaco #SpringIO24
Cost of fixing a bug
h"ps://www.func-onize.com/blog/the-cost-of-finding-bugs-later-in-the-sdlc
Code reviews
@DevPaco #SpringIO24
Code review
Code review
“A code review is a systematic evaluation of source code by others,
intended to identify errors, foster learning among developers and
improve code quality”
@DevPaco #SpringIO24
Code review
Code review
“A code review is a systemaEc evaluaEon of source code by others,
intended to iden9fy errors, foster learning among developers and
improve code quality”
Code quality
“Code quality refers to the extent to which code is maintainable,
readable, efficient, and robust, following established coding
conven9ons and best prac9ces.”
@DevPaco #SpringIO24
@DevPaco #SpringIO24
Pull requests
h"ps://www.atlassian.com/blog/bitbucket/5-pull-request-must-haves
@DevPaco #SpringIO24
Version Control Systems
@DevPaco #SpringIO24
Problems
@DevPaco #SpringIO24
Problems
@DevPaco #SpringIO24
Problems
@DevPaco #SpringIO24
Problems
@DevPaco #SpringIO24
Review friendly pull requests
Changes are
✅ Concise
✅ Focused
✅ Tested
@DevPaco #SpringIO24
Pull Request
@DevPaco #SpringIO24
What makes a good Atle
h,ps://www.conven3onalcommits.org/
@DevPaco #SpringIO24
The DescripAon
• Context
• What changed
• Why
• Examples
• Keep it concise and readable
@DevPaco #SpringIO24
Templates
@DevPaco #SpringIO24
Review your own code!
• Different perspecEve
• Add context to smaller changes
• Highlight important parts
• Ask specific quesEons
@DevPaco #SpringIO24
Asking for reviews
@DevPaco #SpringIO24
Asking for reviews
• Diffusion of responsibility
• Context
• Deadline
@DevPaco #SpringIO24
• Diffusion of responsibility
• Context
• Deadline
Asking for reviews help
@DevPaco #SpringIO24
Receiving feedback
@DevPaco #SpringIO24
Vague feedback
@DevPaco #SpringIO24
Endless discussions
• Pick your baRles
• Take it offline
• “As discussed offline; we decided to go for soluEon x because of y”
@DevPaco #SpringIO24
Be grateful
🙏
“Fixed” “Thanks, learned something new about the API, it's fixed now”
➡
@DevPaco #SpringIO24
Giving reviews
• Don’t wait too long
• Taking responsibility
@DevPaco #SpringIO24
Giving reviews
• Don’t wait too long
• Taking responsibility
@DevPaco #SpringIO24
Get the context
• Read the description
• Check the spec
• Existing comments
@DevPaco #SpringIO24
How to review?
• Design
• FuncEonality
• Complexity
• Tests
• Style / Documenta/on
@DevPaco #SpringIO24
Tool assisted reviews
@DevPaco #SpringIO24
Use your editor
@DevPaco #SpringIO24
Use your editor
@DevPaco #SpringIO24
Use your editor
@DevPaco #SpringIO24
Use your editor
@DevPaco #SpringIO24
Use your editor
@DevPaco #SpringIO24
Use your editor
@DevPaco #SpringIO24
AI powered tools
CodeRabbit - hLps://coderabbit.ai/
Bito - hLps://bito.ai/
Sourcery - hLps://sourcery.ai/
@DevPaco #SpringIO24
WriAng a good comment
• You -> We
• Statements -> QuesEons
“Why did we chose y? I understood x is more ac/vely maintained”
@DevPaco #SpringIO24
Writing a good comment
• Be specific
• Re-read your comment
• Try to provide an alternaEve/soluEon
@DevPaco #SpringIO24
Use suggesAons
@DevPaco #SpringIO24
ConvenAonal Comments
• <label> [decoraEons]: <subject>
• [discussion]
• hRps://convenEonalcomments.org/
@DevPaco #SpringIO24
Praise
@DevPaco #SpringIO24
@DevPaco #SpringIO24
Bikeshedding
@DevPaco #SpringIO24
Bikeshedding / Law of triviality
“People within an organizaEon commonly give dispropor9onate weight
to trivial issues” – Parkinson, 1957
@DevPaco #SpringIO24
Bikeshedding / Law of triviality
“People within an organizaEon commonly give dispropor9onate weight
to trivial issues” – Parkinson, 1957
@DevPaco #SpringIO24
@DevPaco #SpringIO24
Error-prone
Detects common programming mistakes at compile-9me and provides
automated fixes
❤
@DevPaco #SpringIO24
One way or another
return list.filter(address -> address != null);
Example.java:[22,33] Note: [Refaster Rule] NullRules.NonNullFunc3on: Refactoring opportunity
[ERROR] (see h,ps://error-prone.picnic.tech/refasterrules/NullRules#NonNullFunc3on)
[ERROR] Did you mean ‘list.filter(Objects::nonNull);'?
return BigDecimal.valueOf(0);
[INFO] Example.java:[12,30] [Refaster Rule] BigDecimalRules.BigDecimalZero: Refactoring opportunity
(see https://error-prone.picnic.tech/refasterrules/BigDecimalRules#BigDecimalZero)
Did you mean 'return BigDecimal.ZERO;'?
@DevPaco #SpringIO24
Broken logging/formaQng
Example.java:[21,27] error: [FormatString] extra format arguments: used 0, provided 1
[ERROR] (see h,ps://errorprone.info/bugpa,ern/FormatString)
return "{}".forma,ed("test");
@DevPaco #SpringIO24
Broken asserAons
[ERROR] MyTest.java:[73,14] error: [CheckReturnValue] The result of `assertThat(...)` must be used
[ERROR] (see h,ps://errorprone.info/bugpa,ern/CheckReturnValue)
[ERROR] Did you mean 'assertThat(somePojo.getId().equals("expectedId")).isTrue();'?
assertThat(somePojo.getId().equals(”expectedId"));
@DevPaco #SpringIO24
Improve readability
StripeWebhookController.java:[90,2] Note: [SpringMvcAnnota3on] Prefer the conciseness of
`@{Get,Put,Post,Delete,Patch}Mapping` over `@RequestMapping`
(see h,ps://error-prone.picnic.tech/bugpa,erns/SpringMvcAnnota3on)
Did you mean '@PostMapping(value = URL_WEBHOOK_USER_V1)'?
@RequestMapping(
value = URL_WEBHOOK_USER_V1,
method = RequestMethod.POST
)
@DevPaco #SpringIO24
Tips
• Test the rules on your codebase and choose those that match your
team’s style best
• Some rules might have some issues with tools like lombok
• Make sure to ignore generated code
@DevPaco #SpringIO24
OpenRewrite
• By Moderne
• Large set of recipes
• Migra/ng Java version
• Spring upgrades
• Moving to AssertJ
• Many more….
assertEquals(1, currentSubs.size());
assertThat(currentSubs.size()).isEqualTo(1);
⬇
assertThat(currentSubs).hasSize(1);
⬇
https://www.moderne.io/blog/stop-breaking-ci-annotate-prs-with-openrewrite-recipe-fixes-as-quality-gate
@DevPaco #SpringIO24
FormaQng
• The more opinionated the less room for discussion
• Automatically enforceable
• Don’t deviate too much from industry standards
@DevPaco #SpringIO24
spring-javaformat
• hRps://github.com/spring-io/spring-javaformat
• AutomaEcally format your code from CLI
• It is effecEvely limited to adding or removing whitespace and line
feeds
• AddiEonal Checkstyle plugin
@DevPaco #SpringIO24
google-java-format
• Implements the Google Java Style Guide
• Integrates with most editors
• No formaRer will be perfect
@DevPaco #SpringIO24
fmt-maven-plugin
• AutomaEcally format your code from CLI
• AutomaEcally fail on formaing issues
@DevPaco #SpringIO24
Configure code style
• formatting issues
• coding rule violations
• Integrates with most editors
Example.java:[22,5] (naming)
ConstantName: Name ‘defaultExtension'
must match pa,ern '^[A-Z][A-Z0-9]*(_[A-Z0-
9]+)*$’.
Example.java:[59,3] (coding)
Declara3onOrder: Sta3c variable defini3on
in wrong order.
@DevPaco #SpringIO24
• Enforcing Architecture guidelines and naming convenEons
• Also used for Spring Modulith
@DevPaco #SpringIO24
Architecture checks
@ArchTest
sta3c final ArchRule layer_dependencies_are_respected =
layeredArchitecture().consideringAllDependencies()
.layer("Controllers").definedBy("com.tngtech.archunit.example.layers.controller..")
.layer("Services").definedBy("com.tngtech.archunit.example.layers.service..")
.layer("Persistence").definedBy("com.tngtech.archunit.example.layers.persistence..")
.whereLayer("Controllers").mayNotBeAccessedByAnyLayer()
.whereLayer("Services").mayOnlyBeAccessedByLayers("Controllers")
.whereLayer("Persistence").mayOnlyBeAccessedByLayers("Services");
@DevPaco #SpringIO24
Naming conventions
@ArchTest
sta3c ArchRule interface_names =
classes().that().areInterfaces().should().haveNameMatching(".*Interface");
@ArchTest
static ArchRule controllers_should_be_suffixed =
classes()
.that().resideInAPackage("..controller..")
.or().areAnnotatedWith(MyController.class)
.or().areAssignableTo(AbstractController.class)
.should().haveSimpleNameEndingWith("Controller");
@DevPaco #SpringIO24
Tips
• Check the large set of predefined rules
• Capture common mistakes
• Create a shared module with rules
@DevPaco #SpringIO24
Preferred order of tools
• Compile Eme tools with suggesEons/fixes
• google-java-format with spo/fy plugin
• error-prone
• Compile Eme tools
• Checkstyle
• Sonar
• Tests
@DevPaco #SpringIO24
Introducing tools to your organisation
• Start small
• Involve the team
• Use sample MRs to discuss rule sets
• Centralize configuraEon
• Use a parent-pom
@DevPaco #SpringIO24
Conclusion
• Write descripEve pull requests and review them yourself
• Be specific in your communicaEon
• Be friendly and find posi/ve things
• Use VCS feature/your editor to help you review
•Stop bikeshedding, start automa4ng!
@DevPaco #SpringIO24
Thank you!
h,ps://errorprone.info/ and h,ps://error-prone.picnic.tech/
Catches common programming mistakes at compile-3me
h,ps://github.com/google/google-java-format
h,ps://github.com/spo3fy/fmt-maven-plugin
Automated formazng of your code
h,ps://www.archunit.org/
Unit test your Java architecture
h,ps://github.com/spring-io/spring-javaformat
Spring’s formazng and checkstyle plugins
h,ps://google.github.io/eng-prac3ces/
Google best prac3ces on code reviews

More Related Content

PPT
Git e GitHub - Conceitos Básicos
PDF
git - eine praktische Einführung
PDF
Git basics
PPTX
Git - Basic Crash Course
PDF
Modelos de Processo de Software Parte 4
PDF
Introduction to GitHub
PDF
Git in a nutshell
PDF
Introdução ao Git
Git e GitHub - Conceitos Básicos
git - eine praktische Einführung
Git basics
Git - Basic Crash Course
Modelos de Processo de Software Parte 4
Introduction to GitHub
Git in a nutshell
Introdução ao Git

What's hot (20)

PPTX
Git 101 for Beginners
PDF
Git - An Introduction
PDF
Tutorial: Building a GraphQL API in PHP
PDF
Git e GitHub: Versionamento de Código Fácil
PPT
Git vs SVN
PDF
Git and GitHub for Documentation
PDF
Git e GitHub
PPTX
Introduction git
PPT
Introduction to Git and Github
PDF
GIT Básico
PDF
Testes de Unidade com JUnit
PDF
Git training v10
PPTX
Git basics to advance with diagrams
PPTX
Introduction to git, a version control system
PDF
01 - Introdução a lógica de programação - v1.4
PDF
React
PDF
Git & GitHub WorkShop
PPT
Banco de Dados Distribuídos - MySql
PDF
Arquitectura de microservicios
PDF
Modelo Conceitual MER
Git 101 for Beginners
Git - An Introduction
Tutorial: Building a GraphQL API in PHP
Git e GitHub: Versionamento de Código Fácil
Git vs SVN
Git and GitHub for Documentation
Git e GitHub
Introduction git
Introduction to Git and Github
GIT Básico
Testes de Unidade com JUnit
Git training v10
Git basics to advance with diagrams
Introduction to git, a version control system
01 - Introdução a lógica de programação - v1.4
React
Git & GitHub WorkShop
Banco de Dados Distribuídos - MySql
Arquitectura de microservicios
Modelo Conceitual MER
Ad

Similar to Cracking the code review at SpringIO 2024 (20)

PDF
Cracking the Code Review - Voxxed Ticino
PDF
Code Reviews @ Quatico
PDF
Who Should Review My Code?
PDF
Voxxed days 2015-hakansaglam-codereview
PDF
Code-Review-Principles-Process-and-Tools (1)
PPTX
Writing clean code in C# and .NET
PDF
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
DOC
VizzMaintenance Eclipse Plugin Metrics
PPTX
Code smells in MVC applications (Dutch Spring meetup)
PDF
How not to run code reviews
PDF
Hacking Java - Enhancing Java Code at Build or Runtime
PDF
How to do code review and use analysis tool in software development
ODP
New Ideas for Old Code - Greach
PDF
Managing and evolving JavaScript Code
PPTX
You Live, You Learn, Then You Get Perforce Swarm
PDF
Questioning the status quo
PDF
Spring, CDI, Jakarta EE good parts
PDF
Enhancing Developer Productivity with Code Forensics
PPTX
Slides for Houston iPhone Developers' Meetup (April 2012)
 
PPT
JDK1.7 features
Cracking the Code Review - Voxxed Ticino
Code Reviews @ Quatico
Who Should Review My Code?
Voxxed days 2015-hakansaglam-codereview
Code-Review-Principles-Process-and-Tools (1)
Writing clean code in C# and .NET
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
VizzMaintenance Eclipse Plugin Metrics
Code smells in MVC applications (Dutch Spring meetup)
How not to run code reviews
Hacking Java - Enhancing Java Code at Build or Runtime
How to do code review and use analysis tool in software development
New Ideas for Old Code - Greach
Managing and evolving JavaScript Code
You Live, You Learn, Then You Get Perforce Swarm
Questioning the status quo
Spring, CDI, Jakarta EE good parts
Enhancing Developer Productivity with Code Forensics
Slides for Houston iPhone Developers' Meetup (April 2012)
 
JDK1.7 features
Ad

Recently uploaded (20)

PDF
top salesforce developer skills in 2025.pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
history of c programming in notes for students .pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
System and Network Administraation Chapter 3
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Nekopoi APK 2025 free lastest update
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
medical staffing services at VALiNTRY
top salesforce developer skills in 2025.pdf
Odoo POS Development Services by CandidRoot Solutions
history of c programming in notes for students .pptx
Design an Analysis of Algorithms I-SECS-1021-03
System and Network Administraation Chapter 3
Softaken Excel to vCard Converter Software.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
VVF-Customer-Presentation2025-Ver1.9.pptx
Upgrade and Innovation Strategies for SAP ERP Customers
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Operating system designcfffgfgggggggvggggggggg
CHAPTER 2 - PM Management and IT Context
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Nekopoi APK 2025 free lastest update
Which alternative to Crystal Reports is best for small or large businesses.pdf
medical staffing services at VALiNTRY

Cracking the code review at SpringIO 2024