<commit_before># flow-coverage-report

[![Greenkeeper badge](https://badges.greenkeeper.io/rpl/flow-coverage-report.svg)](https://greenkeeper.io/)

[![Build Status](https://travis-ci.org/rpl/flow-coverage-report.svg?branch=master)](https://travis-ci.org/rpl/flow-coverage-report)

**flow-coverage-report** is a node command line tool to help projects which are
using [flow types][flow] in their JavaScript code to keep track and visualize
the coverage of the flow types checks.

![Screenshot flow coverage report summary in the console][screenshot-text]

![Screenshot flow coverage report summary][screenshot-summary]

![Screenshot flow coverage report sourcefile][screenshot-sourcefile]


## How to generate flow coverage reports for your project

Install the command line tool (globally or as a dev dependency of your project)

```
$ npm install -g flow-coverage-report

or

$ npm install --save-dev flow-coverage-report
```

Run the flow reporter (`-i` configures the include globs, `-x` the exclude patterns,
and `-t` the report types enabled):

```
flow-coverage-report -i 'src/**/*.js' -i 'src/**/*.jsx' -x 'src/test/**' -t html -t json -t text
```

If the **flow** executable is not in your PATH, you can specified it using the
`-f` option:

```
flow-coverage-report -f /path/to/flow ...
```

To customize the output dir (which defaults to `flow-coverage/`). you can use the `-o` option:

```
flow-coverage-report -o my-custom-flow-coverage-dir/
```

## Background

As a gradual typing system for JavaScript, flow will help you to statically checks
parts of your JavaScript code by:

- supporting syntaxes to annotate your code with types;
- supporting syntaxes to declare, export and import new types implicitly and explicitly;
- inferencing the type of the identifier used in your code as much as possible;  

Unfortunately, even with a good amount of powerful inferencing strategies,
sometimes flow is not able to inference the types in some chunks of our code.

That's usually the source of a "Meh!" moment, and we blame flow for not being able to catch
some issue that we thought it would catch statically.

Fortunately, flow has a **coverage** command which can give us a quantitative
info of the flow types coverage, and optionally a color-based visualization of the
parts of the source file that are not covered, for a single file.

How to generate this quantitative info and this very useful visualization of the
uncoverage parts of our sources for our entire project?

You have just found it ;-)
<commit_msg>docs: add config file example and info on the valid values for the "type" property<commit_after># flow-coverage-report

[![Greenkeeper badge](https://badges.greenkeeper.io/rpl/flow-coverage-report.svg)](https://greenkeeper.io/)

[![Build Status](https://travis-ci.org/rpl/flow-coverage-report.svg?branch=master)](https://travis-ci.org/rpl/flow-coverage-report)

**flow-coverage-report** is a node command line tool to help projects which are
using [flow types][flow] in their JavaScript code to keep track and visualize
the coverage of the flow types checks.

![Screenshot flow coverage report summary in the console][screenshot-text]

![Screenshot flow coverage report summary][screenshot-summary]

![Screenshot flow coverage report sourcefile][screenshot-sourcefile]


## How to generate flow coverage reports for your project

Install the command line tool (globally or as a dev dependency of your project)

```
$ npm install -g flow-coverage-report

or

$ npm install --save-dev flow-coverage-report
```

Run the flow reporter (`-i` configures the include globs, `-x` the exclude patterns,
and `-t` the report types enabled):

```
flow-coverage-report -i 'src/**/*.js' -i 'src/**/*.jsx' -x 'src/test/**' -t html -t json -t text
```

If the **flow** executable is not in your PATH, you can specified it using the
`-f` option:

```
flow-coverage-report -f /path/to/flow ...
```

To customize the output dir (which defaults to `flow-coverage/`). you can use the `-o` option:

```
flow-coverage-report -o my-custom-flow-coverage-dir/
```

### With a config file

The `--config` flag allows specifying a path to a config file. The config file
is a JSON file with the following structure:

``` json
{
  "concurrentFiles": 1,
  "excludeGlob": [
    "node_modules/**"
  ],
  "flowCommandPath": "path/to/flow/bin",
  "includeGlob": [
    "src/**/*.js"
  ],
  "outputDir": "path/to/output",
  "projectDir": "path/to/project",
  "threshold": 80,
  "type": "text"
}
```

`type` can be one of `"text"`, `"html"`, or `"json"`. The default is `"text"`.

## Background

As a gradual typing system for JavaScript, flow will help you to statically checks
parts of your JavaScript code by:

- supporting syntaxes to annotate your code with types;
- supporting syntaxes to declare, export and import new types implicitly and explicitly;
- inferencing the type of the identifier used in your code as much as possible;  

Unfortunately, even with a good amount of powerful inferencing strategies,
sometimes flow is not able to inference the types in some chunks of our code.

That's usually the source of a "Meh!" moment, and we blame flow for not being able to catch
some issue that we thought it would catch statically.

Fortunately, flow has a **coverage** command which can give us a quantitative
info of the flow types coverage, and optionally a color-based visualization of the
parts of the source file that are not covered, for a single file.

How to generate this quantitative info and this very useful visualization of the
uncoverage parts of our sources for our entire project?

You have just found it ;-)

{'fraction_non_alphanumeric': 0.10439267295038236, 'fraction_numerical': 0.0005335230304108127, 'mean_word_length': 4.2757973733583485, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '155570', 'n_tokens_mistral': 1673, 'n_tokens_neox': 1597, 'n_words': 728}