Say goodybe to bugs and anti-patterns with Error Prone - @JavaZone

RickOssendrijver1 21 views 42 slides Oct 13, 2024
Slide 1
Slide 1 of 42
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42

About This Presentation

Slides from my talk at JavaZone.


Slide Content

2

3
Code quality and repetitive discussions1
Introduce Error Prone2
Using Error Prone in practice!3
Error Prone @ Picnic4
Agenda
Applying Error Prone rules within Picnic5

4

5
Code reviews and discussions

6

7
Tools
Google/google-java-format
Reformats Java source code to comply
with Google Java Style.
checkstyle/checkstyle
Helps programmers write Java code
that adheres to a coding standard.
spotbugs/spotbugs
A tool for static analysis to look
for bugs in Java code.
SonarSource/sonarqube
Continuous Inspection.

8
Code quality and repetitive discussions1
Introduce Error Prone2
Using Error Prone in practice!3
Error Prone @ Picnic4
Agenda
Applying Error Prone rules within Picnic5

9
Open-source static analysis
Compiler plugin
Powerful
500+ Error Prone checks
Complex
Error Prone
Google/error-prone
Catch common Java mistakes
as compile-time errors

10
Refaster
Examples from: http://errorprone.info/docs/refaster
Define refactorings with templates.
becomes

11
Demo
Let’s demonstrate!
https://github.com/rickie/error-prone-demo

12
Maven profile 1

13
Maven profile 2

14
Demo
Let’s demonstrate!
https://github.com/rickie/error-prone-demo

15
Bug patterns
https://errorprone.info/bugpatterns

16
Error Prone as superpower

17

18
Error Prone as superpower
Input:
Output:

19
Code quality and repetitive discussions1
Introduce Error Prone2
Using Error Prone in practice!3
Error Prone @ Picnic4
Agenda
Applying Error Prone rules within Picnic5

20
Roadmap to Enable Error Prone
Level 1:
Disable everything
Level 2:
Selectively enable a
few ERROR checks

Level 3:
Enable all default
ERROR checks

21
Demo: introducing Error Prone in practice!
Let’s demonstrate!

22

23
Roadmap to Enable Error Prone
Level 1:
Disable everything

Level 2:
Selectively turn on a
few ERROR checks

Level 3:
Turn on all default
ERROR checks

24
Code quality and repetitive discussions1
Introduce Error Prone2
Using Error Prone in practice!3
Error Prone @ Picnic4
Agenda
Applying Error Prone rules within Picnic5

25
Error Prone @ Picnic
70+ repositories
Common configuration
./patch.sh
Continuous Integration

26

27
Picnic open-sourced: Error Prone Support!
900+ Refaster rules
40+ Error Prone bug checks
Picnic-opinionated set of rules
Migrations
https://error-prone.picnic.tech

28
Refaster rule

29
Error Prone BugPattern

30
Picnic’s Error Prone Support
Run Refaster rules
Test support
Improved reporting for Refaster
Documentation website

31 https://error-prone.picnic.tech

32
Code quality and repetitive discussions1
Introduce Error Prone2
Using Error Prone in practice!3
Error Prone @ Picnic4
Agenda
Applying Error Prone rules within Picnic5

33
Applying Error Prone Support @ Picnic
Introducing:
-all Refaster rules

-all Error Prone checks

Approach
Perspective
https://error-prone.picnic.tech

34
Applying Error Prone Support @ Picnic
70+ PRs spread over 50+ Java repositories

33.665 insertions (+) 31.281 deletions (-)

35

36

37
Current state of Error Prone Support
People contributing ideas (from reviews)

50+ contributors

Stickers

Adoption

External adoption

38
Picnic x Moderne
+

39
Let’s create a Refaster rule!

40
Conclusion
Two perspectives:
-Happy developers!

-Platform team or configuration
maintainers.

41
join.picnic.app

42
Unsure about next steps?
Feel free to reach out!

- error-prone.picnic.tech


- github.com/rickie/error-prone-demo - Demo code
Jan Kothe
Special thanks to:
Stephan Schroevers
[email protected]
github.com/Stephan202

My contact details:
[email protected]
github.com/rickie
rick_ossies
Tags