-
Automatic Code Review Process
-
Traditional code review process
-
Offline code review
-
Scenario
- Author submitted the code
- Reviewer reviewed the code later
- Reviewer gave some suggestion to the author
- Author refactored the code
- Reviewer checked the code again and accepted the changes
-
Disadvantages
- Low efficient
- Decrease productivity
- Boring
-
Code review as event
-
Scenario
- Team members found there were many bad codes and decided to hold a meeting to address them
- Team members gathered together for the CR meeting
- Speaker talked about the bad practices in the recently submitted code
- Team went back and fixed their own problems
-
Disadvantages
- No all problems can be mentioned on the meeting
- Breed the tiger from cute to horrible one
- Could be more efficient if CR is daily practice
-
Why Automatic matters in CR
-
Scenario
- The code analysis tool runs at night and a report was generated
- The developers get the report from email notification
-
Tom got a coding convention warning of his method
- Tom checked the MA Coding Convention and identify the problem
- Tom fixed the issue and run the code analysis tool locally
- The locally running code analysis tool told Tom the code was fine this time
- Tom submit the code, happily
-
Jerry got a design warning of his class
- Jerry read the description and the suggested solution of the warning
- Jerry really had no idea how to get it fixed
- Jerry came to his mentor (or his colleague) Henry, who had the responsibility to do code review with Jerry in this iteration
- Jerry and Henry sat together for 1 hour and finally fixed the warning
- Jerry and Henry run code analysis tool locally and the warning disapear
- Jerry and Henry run unit test locally and nothing failed by this modification
- Jerry submit the code, “High five!”
-
Advantages
- Help to make real online code review practical
- Help to identify the facial issues (productivity)
- Help to identify the potential hidden issues (productivity)
- Help to establish a process of really doing CR and get benifit from it
- Make CR as a daily practice
-
Tools
- CC.NET
-
StyleCop
-
Default rules area
- Documentation
- Layout
- Maintanablity
- Naming
- Ordering
- Readability
- Spacing
-
Customize default rules into MA Coding Convention rules
- General
- Comments
- Subtopic 3
- Subtopic 4
- Extend more good rules accommodate our needs
-
FxCop
-
Default warnings area
- Design
- Globalization
- Interoperability
- Naming
- Performance
- Security
- Usage
-
Customize default rules into rules fit our needs
- Study them all
- Directly use some of them
- Customize some of them
- Establish our own rule set
-
Why useful?
- Give warnings to code which violate design guidelines
- Learn design guidelines from the warnings
-
Tasks
- Customize a set of rules which accommodate Moody's Coding Convention
- Integrate StyleCop into CC.NET
- Establish reporting mechanism of StyleCop
- Apply the coding convention to an existing project
- Retrospective of the StyleCop ACR customization
- Select/Modify/Add a rule set from default FxCop rule base
- Identify one piece of code belongs to whom
- Integrate FxCop into CC.NET
- Establish reporting mechanism of FxCop
- Retrospective of the FxCop ACR customization
- Define the ACR process and spread the experience
-
Advantages
- Improve product quality
- Have clean & consistent code base
- Improve developer skills
- Knowledge spreading
- Way of mentoring
- Metrics of performance