Assisted Code Review with source{d} Lookout

Vadim Markovtsev, source{d}.

Assisted Code Review with source{d} Lookout

Vadim Markovtsev

Plan

  1. Origins
  2. What is Lookout?
  3. SDK
  4. From scratch: typo correction

Origins

Many efforts target boring stuff

Boring means automatable

Automatable ≠ unattended 😔

When to help?

IDE

CI

PR reviews

cron

Comparison

∈ workflow UI Feedback Rich info FP requirements
IDE ✓ ✓✓ instant ✓ low
CI ✓ ✗ minutes ✗ 0
PR ✓ ✓ minutes ✗ lowest
cron ✗ ✗ hours ✗ low

When to help?

What is Lookout?

Goals

Architecture

Push event

Push event

Push event

Push event

Push event

Push event

Push event

PR event

PR event

docs.sourced.tech/lookout

SDK

src-d/lookout-sdk

src-d/lookout-sdk-ml

Rule of 👍

High-level API

class MyAnalyzer(Analyzer):
    @classmethod
    def train(cls, ...) -> AnalyzerModel:
        # ...

    def analyze(self, ...) -> [Comment]:
        # do something with self.model

Train

@with_uasts_and_contents
def train(cls,
          ptr: ReferencePointer,
          config: Dict[str, Any],
          data_service: DataService,
          files: Iterable[File]
          ) -> AnalyzerModel:

Analyze

@with_changed_uasts_and_contents
def analyze(self,
            ptr_from: ReferencePointer,
            ptr_to: ReferencePointer,
            data_service: DataService,
            changes: Iterable[Change]
            ) -> [Comment]:

Behind the scenes

Hands on

Objective

class Packfile:

Objective

def read_packfile(...):
    # ...
 
class Packfile:

Objective

def read_packfile(...):
        # ...
     
    class Packfle:

Steps

  1. Install lookout-sdk-ml and autocorrect
  2. Write typos.py
  3. Fork a repo, create a PR
  4. Generate a new GitHub Personal Access Token
  5. Run our analyzer

Summary

Summary

Thank you

bit.ly/2H8U5ra