Git Product home page Git Product logo

codecoach's Introduction

CodeCoach

npm version badge npm download badge
Release

CodeCoach logo

Lightweight code review tool. Provide lint output to CodeCoach, it will automatically review pull requests. CodeCoach uses node.js as run time. It can be run from any command line. So it can be integrated with any CI with ease.

Supported linters.

  • ESLint
  • TSLint
  • MSBuild (both msbuild.exe and dotnet build commands)
  • ScalaStyle
  • AndroidLint
  • DartLint
  • SwiftLint (0.49.1 or later)

Supported source controls

  • GitHub
  • GitHub Enterprise
  • GitLab

Prerequisite

Node.js v14 or later

Installation

Install it globally using npm

$ npm i -g @codecoach/cli

or Yarn

$ yarn global add @codecoach/cli

Usage

Use command codecoach with required config.

Configs

Configuration could be supplied by arguments options or config JSON file.

Example: Supplying config by options
$ codecoach \
  -g="github"
  --githubRepoUrl="https://github.com/codeleague/codecoach" \
  --githubPr=99 \
  --githubToken="yourtoken" \
  -f="eslint;/path/to/eslintoutput.json" \
  -f="dotnetbuild;/path/to/dotnetbuild;/repo/src" \
  -r
Example: Supplying config by json
$ codecoach --config="codecoach.json"

and in codecoach.json

{
  "vcs": "github",
  "githubRepoUrl": "https://github.com/codeleague/codecoach",
  "githubPr": 99,
  "githubToken": "yourtoken",
  "buildLogFile": [
    "eslint;/path/to/eslintoutput.json",
    "dotnetbuild;/path/to/dotnetbuild;/repo/src"
  ],
  "removeOldComment": true
}

Will do the same thing.

Warning: If both config file and options are supplied, options will override config in file.

Option Required Value Description
vcs / -g when dryRun is false github or gitlab
githubRepoUrl when vcs is github Repository's HTTPS URL
githubPr when vcs is github Pull request ID
githubToken when vcs is github Personal Access Token
gitlabHost when vcs is gitlab https://gitlab.company.com GitLab Server (Could also be https://gitlab.com)
gitlabProjectId when vcs is gitlab Project ID
gitlabMrIid when vcs is gitlab MergeRequest IID (not to be confused with ID)
gitlabToken when vcs is gitlab Access Token
buildLogFile / -f yes, repeatable Read below
output / -o no CodeCoach parsed output for debugging
removeOldComment / -r no true or false Remove CodeCoach's old comments before adding new one
failOnWarnings no true or false Fail the job when warnings are found
dryRun no true or false Running CodeCoach without reporting to VCS
suppressRules no rule-group-1/.* rule-id-1 rule-id-2 Rule IDs that CodeCoach will still comment but no longer treated as errors or warnings
--buildLogFile or -f
Required, Repeatable

Build log content files config. Splitted in to 3 part, formatted in <type>;<path>[;<cwd>]

  • Type: one of dotnetbuild, msbuild, tslint, eslint, scalastyle, androidlint or dartlint
  • Path: Path to lint output file to be processed
  • cwd: Linter context repository root (optional, will use current directory if not provided)

For example,
Case 1: Run CodeCoach from repo root for eslint and dotnetbuild in the same lint context directory

--buildLogFile="eslint;./src/client/eslint-out.json" --buildLogFile="dotnetbuild;./src/api/msbuild.log"

Case 2: Run CodeCoach from somewhere else for androidlint (linter context root was /path/to/project/root)

--buildLogFile="androidlint;./android-lint.xml;/path/to/project/root"

How to get lint output for CodeCoach

ESLint

Use -o <filename> to output lint result to file and -f json to format logs as JSON. (ref.)

TSLint

Use -o <filename> to output lint result to file and -t json or --format json to format logs as JSON. (ref.)

MSBuild and dotnet build

Use -fileLoggerParameters or -flp switch with msbuild, dotnet build or dotnet msbuild command to send logs to file. (ref.)

ScalaStyle

Result is already written to target/scalastyle-result.xml when project is built (ref.)

AndroidLint

Use -o <filename> to output lint result to file (ref.)

DartLint

Use -o <filename> on output lint result created by command dart analyze > <filename> in dart project (ref.)

SwiftLint

Use --output <filename> to output lint result to file and --reporter json to format logs as JSON. (ref.)

Contribute

For contribution guidelines and project dev setup. Please see CONTRIBUTING.md

codecoach's People

Contributors

encx avatar icmpecho avatar jkozal avatar jeeyo avatar goggags123 avatar flapperz avatar thaweesak-sai avatar pooh-chan avatar yeeezsh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.