Error Prone Support workshop - internal conference
RickOssendrijver1
25 views
69 slides
Jul 06, 2024
Slide 1 of 69
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
About This Presentation
-
Size: 6.62 MB
Language: en
Added: Jul 06, 2024
Slides: 69 pages
Slide Content
1
2
Agenda
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Agenda
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduce Error Prone and Refaster (10 min)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)6
Error Prone Support (5 min)5
Picnic and its code quality1
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!
Standardization and repetitive discussions
Introduce Error Prone and Refaster2
Refaster - Workshop part 14
Error Prone - Workshop part 25
Error Prone Support3
Using Error Prone in practice!6Using Error Prone in practice! (15 min)5Using Error Prone in practice!6Using Error Prone in practice! (15 min)5Using Error Prone in practice! (15 min)5Using Error Prone in practice!6Using Error Prone in practice! (15 min)7Error Prone @ Picnic
3
Understanding code
“developers on average spend as
much as 58% of their time
comprehending existing source code”
- Felienne Hermans
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
Agenda
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Agenda
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduce Error Prone and Refaster (10 min)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)6
Error Prone Support (5 min)5
Picnic and its code quality1
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!
Standardization and repetitive discussions
Introduce Error Prone and Refaster2
Refaster - Workshop part 14
Error Prone - Workshop part 25
Error Prone Support3
Using Error Prone in practice!6Using Error Prone in practice! (15 min)5Using Error Prone in practice!6Using Error Prone in practice! (15 min)5Using Error Prone in practice! (15 min)5Using Error Prone in practice!6Using Error Prone in practice! (15 min)7Error Prone @ Picnic
19
Agenda
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Agenda
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduce Error Prone and Refaster (10 min)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)6
Error Prone Support (5 min)5
Picnic and its code quality1
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!
Standardization and repetitive discussions
Introduce Error Prone and Refaster2
Refaster - Workshop part 14
Error Prone - Workshop part 25
Error Prone Support3
Using Error Prone in practice!6Using Error Prone in practice! (15 min)5Using Error Prone in practice!6Using Error Prone in practice! (15 min)5Using Error Prone in practice! (15 min)5Using Error Prone in practice!6Using Error Prone in practice! (15 min)7Error Prone @ Picnic
20
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
21
Picnic’s Error Prone Support
Running Refaster rules
Test support
Improved reporting
Documentation
22
Error Prone Support website
https://error-prone.picnic.tech
23
Agenda
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Agenda
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduce Error Prone and Refaster (10 min)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)6
Error Prone Support (5 min)5
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!
Standardization and repetitive discussions
Introduce Error Prone and Refaster2
Refaster - Workshop part 14
Error Prone - Workshop part 25
Error Prone Support3
Using Error Prone in practice!6Using Error Prone in practice! (15 min)5Using Error Prone in practice!6Using Error Prone in practice! (15 min)5Using Error Prone in practice! (15 min)5Using Error Prone in practice!6Using Error Prone in practice! (15 min)7Error Prone @ Picnic
1
24
Deep dive Refaster
-Background information
-Goals
-How does Refaster work?
-Advanced features
25
Refaster
-2015 - Louis Wasserman (source)
-Two tools
-Closed source
26
27
Deep dive Refaster
Goals of Refaster (source):
-Scalability
-Expressivity
-Usability
When to use Refaster? (docs)
-Method A to method B.
-Migrate a fluent sequence of method invocations to some other
pattern.
-Migrate a sequence of consecutive statements to an alternative.
28
Running Refaster
29
Running Refaster - The Picnic Way
Link to an example configuration in Error Prone Support
30
Running Refaster - The Picnic Way
Refaster runner - `pom.xml` in Error Prone Support
31
Refaster @ Picnic
32
Advanced Refaster features
33
Multiple
`@BeforeTemplate`s
34
Refaster#anyOf
35
@AlsoNegation
36
Import policies
IMPORT_TOP_LEVEL
IMPORT_CLASS_DIRECTLY
STATIC_IMPORT_ALWAYS
37
Block Template
38
@Placeholder
39
Argument types
40
Workshop Refaster
60+ minutes
Tip: use the slides
PicnicSupermarket/
error-prone-support
branch: workshop
Workshop README
41
Agenda
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Agenda
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduce Error Prone and Refaster (10 min)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)6
Error Prone Support (5 min)5
Picnic and its code quality1
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!
Standardization and repetitive discussions
Introduce Error Prone and Refaster2
Refaster - Workshop part 14
Error Prone - Workshop part 25
Error Prone Support3
Using Error Prone in practice!6Using Error Prone in practice! (15 min)5Using Error Prone in practice!6Using Error Prone in practice! (15 min)5Using Error Prone in practice! (15 min)5Using Error Prone in practice!6Using Error Prone in practice! (15 min)7Error Prone @ Picnic
42
Deep dive Error Prone
-Background
-How to write a BugPattern?
-Automatically fixing code
-How to test a BugPattern?
43
Error Prone background
-2012 - Edward Aftandilian
-Code review and unit testing
-Subclass JavaCompiler
-CompilationUnit level
Source: Error Prone paper
44
Rules for an Error Prone check
1.The bug should be easy to understand.
2.The fix should be easy to make.
3.No false positives.
4.The bug should represent a correctness issue.
5.The bug should occur with a small but noticeable frequency.
https://errorprone.info/docs/criteria
45
How does Error Prone work?
Java code Abstract Syntax Tree Tree Node
46
Abstract Syntax Tree
47
Abstract Syntax Tree
48
Creating a BugChecker
49
Automatically fixing code!
Flagging vs. Fixing
50
51
Testing our BugChecker
52
Testing our
BugChecker
53
Refaster vs. Error Prone
Easy: work with
concrete syntax
Complex: AST
manipulation code
Limited
expressiveness
Full AST available
Refactoring only Also flags
without suggestions
54
Workshop part 2 - Error Prone
60 minutes
Prize
Workshop README
55
Agenda
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Agenda
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduce Error Prone and Refaster (10 min)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)6
Error Prone Support (5 min)5
Picnic and its code quality1
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!
Standardization and repetitive discussions
Introduce Error Prone and Refaster2
Refaster - Workshop part 14
Error Prone - Workshop part 25
Error Prone Support3
Using Error Prone in practice!6Using Error Prone in practice! (15 min)5Using Error Prone in practice!6Using Error Prone in practice! (15 min)5Using Error Prone in practice! (15 min)5Using Error Prone in practice!6Using Error Prone in practice! (15 min)7Error Prone @ Picnic
56
Roadmap to Enable Error Prone
Level 1:
Disable everything
Level 2:
Selectively enable a
few ERROR checks
Level 3:
Enable all default
ERROR checks
57
Demo: introducing Error Prone in
practice!
58
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
59
Agenda
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Agenda
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduce Error Prone and Refaster (10 min)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)5
Error Prone Support (5 min)5
Picnic and its code quality
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!6
Picnic and its code quality (10 min)
Introduction Error Prone and Refaster (10)2
Workshop 1 - Refaster (65 min) 3
Workshop 2 - Error Prone (65 min)4
Using Error Prone in practice! (15 min)6
Error Prone Support (5 min)5
Picnic and its code quality1
Introduction of Error Prone and Refaster2
Workshop 1 - Initial setup3
Workshop 2 - Refaster4
Workshop 3 - Error Prone5
Using Error Prone in practice!
Standardization and repetitive discussions
Introduce Error Prone and Refaster2
Refaster - Workshop part 14
Error Prone - Workshop part 25
Error Prone Support3
Using Error Prone in practice!6Using Error Prone in practice! (15 min)5Using Error Prone in practice!6Using Error Prone in practice! (15 min)5Using Error Prone in practice! (15 min)5Using Error Prone in practice!6Using Error Prone in practice! (15 min)7Error Prone @ Picnic
60
Error Prone @ Picnic
Common configuration
./patch.sh
Continuous Integration
62
Applying Error Prone Support @ Picnic
60+ PRs spread over 40+ Java repositories
33.665 insertions (+) 31.281 deletions (-)
63
64
65
Current state of Error Prone Support
People contributing ideas (from reviews)
50+ contributors
Stickers
Adoption
External adoption
66
Picnic x Moderne
+
67
In summary
Two perspectives:
-Happy developers!
-Platform team or configuration
maintainers.
68
69
Unsure about next steps?
Feel free to reach out!
error-prone.picnic.tech
Jan Kothe
Contact details for vacancies
My contact details: [email protected]
github.com/rickie
rick_ossies
github.com/rickie/error-prone-demo Demo + setup