Categorygithub.com/src-d/lookout
modulepackage
0.11.0
Repository: https://github.com/src-d/lookout.git
Documentation: pkg.go.dev

# README

source{d} Lookout

Service for assisted code review, that allows running custom code Analyzers on pull requests.

GitHub version Build Status Development Code Coverage Go Report Card GoDoc

WebsiteDocumentationBlogSlackTwitter

Introduction

With source{d} Lookout, we’re introducing a service for assisted code review, that allows running custom code analyzers on pull requests.

Jump to the Quickstart section to start using it!

Table of Contents

Motivation and Scope

source{d} is the company driving the Machine Learning on Code (#MLonCode) movement. Doing Machine Learning on Code consists of applying ML techniques to train models that can cluster, identify and predict useful aspects of source code and software repositories.

source{d} Lookout is the first step towards a full suite of Machine Learning on Code applications for AI-assisted coding, but you can also create your own analyzers without an ML approach.

The benefits of using source{d} Lookout are:

  • Keep your code base style/patterns consistent.
  • Language agnostic assisted code reviews.
  • Identify where to focus your attention on code reviews.
  • Automatically warn about common mistakes before human code review.

Current Status

Currently, source{d} Lookout is in development process.

Further Reading

This repository contains the code of source{d} Lookout and the project documentation, which you can also see properly rendered at https://docs.sourced.tech/lookout.

Quickstart

There are several ways to run source{d} Lookout; we recommend to use docker-compose because it's straightforward, but you can learn more about the different ways to run source{d} Lookout.

Please refer to the Configuring source{d} Lookout guide for documentation about the config.yml file, and to know how to configure source{d} Lookout to analyze your repositories, or to use your own analyzers.

There is docker-compose.yml config file for Docker Compose to start source{d} Lookout, its dependencies (bblfsh and PostgreSQL) and a dummy analyzer which will add some stats to the watched pull requests.

To do so, clone this repository or download docker-compose.yml directly.

Create the config.yml file in the same directory where docker-compose.yml is. You can use config.yml.tpl as a template. Make sure that you specify in the config.yml the repositories that will be watched by source{d} Lookout. Then run, passing a valid GitHub user/token:

$ docker-compose pull
$ GITHUB_USER=<user> GITHUB_TOKEN=<token> docker-compose up --force-recreate

Once it is running, source{d} Lookout will start posting the comments returned by dummy analyzer into the pull requests opened at GitHub in the repositories that you configured to be watched.

You can stop it by pressing ctrl+c

If you want to try source{d} Lookout with your own analyzer instead of dummy one, you must run it in advance, then set it into config.yml and then run:

$ docker-compose pull
$ GITHUB_USER=<user> GITHUB_TOKEN=<token> docker-compose up --force-recreate lookout bblfsh postgres

If you need to reset the database to a clean state, you should drop the postgres container. To do so, stop running source{d} Lookout with ctrl+c and then execute:

$ docker rm lookout_postgres_1

Available Analyzers

This is the list of the known implemented analyzers for source{d} Lookout:

NameDescriptionTargeted filesMaturity level
style-analyzerCode style analyzerdevelopment
terraformChecks if Terraform files are correctly formattedTerraformusable
gometalintReports gometalinter results on pull requestsGotesting and demo
sonarcheckReports SonarSource checks results on pull requests using bblfsh UASTJavatesting and demo
flake8Reports flake8 results on pull requestsPythontesting and demo
npm-auditReports issues with newly added dependencies using npm-auditJavaScriptdevelopment
function-name analyzerApplies a translation model from function identifiers to function names.development

Create an Analyzer

If you are developing an Analyzer, or you want more info about how they work, please check the documentation about source{d} Lookout analyzers.

Contribute

Contributions are more than welcome, if you are interested please take a look at our Contributing Guidelines.

Community

source{d} has an amazing community of developers and contributors who are interested in Code As Data and/or Machine Learning on Code. Please join us! 👋

Code of Conduct

All activities under source{d} projects are governed by the source{d} code of conduct.

License

Affero GPL v3.0 or later, see LICENSE.

# Packages

No description provided by the author
Package dummy implements an example analyzer.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

CachedHandler wraps an EventHandler, keeping a cache to skip successfully processed Events.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

ErrorAnalysisStatus represents an error status.
FailureAnalysisStatus represents a failure status.
PendingAnalysisStatus represents a pending status.
SuccessAnalysisStatus represents a success status.

# Variables

NoErrStopWatcher if a new error of this kind is returned by EventHandler the Watcher.Watch function exits without error.

# Structs

Analyzer is a struct of analyzer client and config.
AnalyzerComments contains a group of comments and the config for the analyzer that created them.
AnalyzerConfig is a configuration of analyzer.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
FnChangeScanner implements ChangeScanner using functions.
FnFileScanner implements FileScanner using functions.
PushEvent represents a Push to a git repository.
ReviewEvent represents a Review (pull request in case of GitHub) being created or updated.

# Interfaces

ChangeGetter is used to retrieve code changes.
ChangeScanner is a scanner for changes.
Event represents a repository event.
FileGetter is used to retrieve all code for a revision.
FileScanner is a scanner for files.
Poster can post comments about an event.
Watcher watch for new events in given provider.

# Type aliases

AnalysisStatus is the status reported to the provider to inform that we are performing an analysis, or that it has finished.
No description provided by the author
AnalyzerCommentsGroups list of AnalyzerComments.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
CommentsFilterFn is a function that filters comments.
CommitRevision defines a range of commits, from a base to a head.
EventHandler is the function to be called when a new event happens.
EventID is a unique hash id for an event.
No description provided by the author
EventType defines the supported event types.
No description provided by the author
No description provided by the author
ReferencePointer is a pointer to a git refererence in a repository.
RepositoryInfo contains information about a repository.