---
# System prepended metadata

title: Gamify code reviews

---

# Gamify code reviews

## initial notes


### Monocle
The software factory team has been cooking up the following
* https://github.com/change-metrics
* TripleO live server: http://rdo-ci-fx2-02-s2.v101.rdoci.lab.eng.rdu2.redhat.com:3000/tripleo
* screenshot ![](https://i.imgur.com/ZXvM5cE.jpg)

### Others apps
* https://github.com/holmari/repostats
* ??


## RFE's
* process the comments and score as a result
  * word count?
  * complete sentences?
  * other?
* Daily streak count of code reviews.
  * ignore weekends
  * measure and reward for number of consecutive days performing code reviews


## Gamify rules
  * ignore votes
     * we're looking for folks to learn from others. You can't learn from a vote.
     * Reward code reviews with written comments
  * We interested in forming a habit of code reviews
     * reward daily streaks
  * Reward positive language?
     * e.g. "good job"
  * Penalize negative language/reviews?
     * e.g. "this is terrible"
     * adding a -1 without any comment or specific feedback about what needs to be fixed

## Rewards
  * Monthly announcement, GLORY!
  * Red Hat rewards, ( not available to contractors )
  * Managers discretion   


## notes on monocle
* gerrit comments are processed [here](https://github.com/change-metrics/monocle/blob/master/monocle/gerrit/review.py#L366-L430)

```
    self.message_re = re.compile(r"Patch Set \d+:( [^ ]+[+-]\d+)?\n\n.+")
    self.approval_re = re.compile(r"Patch Set \d+:(?P<approval> [^ ]+[+-]\d+)\n.*")
```
* example messages found in unit tests
```
(Pdb) review["messages"][0]['message']
'Uploaded patch set 1.'
(Pdb) review["messages"][1]['message']
'Patch Set 1: Code-Style+1\n\n✅ All files are correctly formatted\n    (https://gerrit-ci.gerritforge.com/job/Gerrit-codestyle/47611/consoleText)'
(Pdb) review["messages"][2]['message']
'Patch Set 1: Verified+1\n\n✅ notedb : SUCCESS\n    (https://gerrit-ci.gerritforge.com/job/Gerrit-verifier-bazel/75671/consoleText)'
(Pdb) review["messages"][3]['message']
'Patch Set 1: -Code-Style -Verified'
(Pdb) review["messages"][4]['message']
'Patch Set 1: Code-Style+1\n\n✅ All files are correctly formatted\n    (https://gerrit-ci.gerritforge.com/job/Gerrit-codestyle/47725/consoleText)'
(Pdb) review["messages"][5]['message']
'Patch Set 1: Verified+1\n\n✅ notedb : SUCCESS\n    (https://gerrit-ci.gerritforge.com/job/Gerrit-verifier-bazel/75809/consoleText)'
(Pdb) review["messages"][165]['message']
'Patch Set 56:\n\n> Ben, do you mean we should remove the topic on the two changes and submit the backend change first?\n\nYes.'

```

* seems like there is a lot of messages that need to be ignored
    * search for comments like patch set 56

* could use NLP natural language processing to grade review comments
    * Sentences used in a comment
    * positive or negative language in a comment

* Tooling with this capacity
    * options https://sunscrapers.com/blog/8-best-python-natural-language-processing-nlp-libraries/
   * SpaCy
       * https://spacy.io/usage/spacy-101
       * perhaps a first pass would be to scan the gerrit comment for positive language
      * example: https://spacy.io/usage/rule-based-matching#example3
   * Textblob
       * https://textblob.readthedocs.io/en/dev/index.html
       * https://textblob.readthedocs.io/en/dev/quickstart.html#sentiment-analysis
       * positive / negative training
           * https://textblob.readthedocs.io/en/dev/api_reference.html#module-textblob.classifiers
        * Number of sentences
            * https://textblob.readthedocs.io/en/latest/quickstart.html#tokenization