8. 8 • 8-November-23
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.
9. 9 • 8-November-23
Picnic and its code quality
1
Introduction of Error Prone and Refaster
2
Workshop 1 - Initial setup
3
Workshop 2 - Refaster
4
Agenda
Workshop 3 - Error Prone
5
Using Error Prone in practice!
6
25. 25 • 8-November-23
Picnic’s Error Prone Support
Run Refaster rules from classpath
Test support for Refaster rules
Improved reporting of Refaster rules
Documentation website
https://error-prone.picnic.tech
27. 27 • 8-November-23
Let’s start with the setup!
PicnicSupermarket
error-prone-support
Error Prone extensions:
extra bug checkers and a large battery of
Refaster rules.
branch: workshop
28. 28 • 8-November-23
Picnic and its code quality
1
Introduction of Error Prone and Refaster
2
Workshop 1 - Initial setup
3
Workshop 2 - Refaster
4
Agenda
Workshop 3 - Error Prone
5
Using Error Prone in practice!
6
29. 29 • 8-November-23
Deep dive Refaster
- Background information
- Goals
- How does Refaster work?
- Advanced features
32. 32 • 8-November-23
Deep dive Refaster
Goals of Refaster (source):
- Scalability
- Expressiveness
- 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.
48. 48 • 8-November-23
Picnic and its code quality
1
Introduction of Error Prone and Refaster
2
Workshop 1 - Initial setup
3
Workshop 2 - Refaster
4
Agenda
Workshop 3 - Error Prone
5
Using Error Prone in practice!
6
49. 49 • 8-November-23
Deep dive Error Prone
- Background
- How to write a BugPattern?
- Automatically fixing code
- How to test a BugPattern?
50. 50 • 8-November-23
Error Prone background
- 2012 - Edward Aftandilian
- Code review and unit testing
- Subclass JavaCompiler
- CompilationUnit level
Source: Error Prone paper
OpenRewrite docs
51. 51 • 8-November-23
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
60. 60 • 8-November-23
Refaster vs. Error Prone
Easy: work with
concrete syntax
Complex: AST
manipulation code
Limited
expressiveness
Full AST available
Refactoring only Also flags
without suggestions