Git Product home page Git Product logo

flow-coverage-report's Introduction

flow-coverage-report

Greenkeeper badge

Build Status

flow-coverage-report is a node command line tool to help projects which are using flow types 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 flow coverage report summary

Screenshot flow coverage report 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, --threshold to configure a minimum coverage below which the build should fail, which defaults to 80%, and -t the report types enabled):

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

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. Though by default the output type is text meaning that it ouputs to the console. Use -o in conjunction with -t to save your desired format:

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

To customize the type you can use -t options:

flow-coverage-report -t html

Load default options from a JSON config file

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

{
  "concurrentFiles": 1,
  "globExcludePatterns": ["node_modules/**"],
  "flowCommandPath": "path/to/flow/bin",
  "globIncludePatterns": ["src/**/*.js"],
  "outputDir": "path/to/output",
  "projectDir": "path/to/project",
  "threshold": 90,
  "reportTypes": "text"
}

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

Load default options from package.json

For an npm package, the default options can also be configured by including them in a "flow-coverage-report" package.json property property:

{
  "name": "my-npm-package",
  "version": "1.0.1",
  "scripts": {
    "flow-coverage": "flow-coverage-report",
    ...
  },
  ...
  "flow-coverage-report": {
    "globIncludePatterns": [
      "src/lib/**/*.js",
      "src/lib/**/*.jsx"
    ],
    "reportTypes": [
      "text",
      "html",
      "json"
    ]
  }
}

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 ;-)

Changelog

Fixes:

  • Upgraded production dependencies (#197) (c13aca8):
    • Unpinned all dependencies (fixes #122)
    • Updated babel to v7
    • Updated parse-json to v5
    • Updated react and react-dom to v16
    • Updated strip-json-comments to v3
    • Updated yargs to v16

⚠ BREAKING CHANGES ⚠

  • Dropped support for node.js <= 10

Fixes:

  • npm audit: updated mkdirp dependency to version ^1.0.4 (removes minimist dependency and fixes npm audit failure due to CVE-2020-7598
  • npm audit: updated mkdirp dependency to version ^0.5.5

Fixes:

  • npm audit: changed the badge-up npm dependency to @rpl/badge-up, forked from the original (currently unmantained) package to update its svgo dependency, as it is detected by npm audit as the source of a moderate security vulnerability (#178, See #177 for a rationale).

Bug Fixes:

  • Added support for the new flow annotations (strict and strict-local) (#150, #155)
  • Added warning on deprecated config names and improve cli/config type checks

Features:

  • Added --percent-decimals cli options (#148, #157, #161)
  • Added -exclude-non-flow cli option (#144, #154)

This new release fixes the issues with the new flow annotations (e.g. strict and strict-local) and introduces two new command line options:

  • --exclude-non-flow to automatically ignore any file that match the patterns but do not have any flow annotation
  • --percent-decimals N to include N decimals digits in the coverage percent values

Thanks to Ville Saukkonen and Ben Styles for contributing the new --exclude-non-flow and --percent-deciments options, and Xandor Schiefer for adding support to the new flow annotations.

0.5.0

Features:

  • added a new badge reporter (#140)
  • added a new --strict-coverage option to enforce a more strict coverage reporting mode. (#141)

The new badge reporter is implicitly executed when the html report is enabled and it generates two badges: 'flow-badge.svg' is a badge related to the flow validation check, 'flow-coverage-badge.svg' is a badge related to the flow coverage level reached by the project.

The new --strict-coverage option enables a more strict coverage reporting where only the flow annotated files are considered as covered (while all the non annotated files and the "@flow weak" annotated ones are considered as fully uncovered).

Thanks to Rúnar Berg Baugsson Sigríðarson for contributing the new badge reporter, and to Desmond Brand and Matt Sprague for contributing the new --strict-coverage option.

0.4.1

Bug Fixes:

  • fixed wrong annotation on multiple pragmas on the same line (#135)

Thanks to Ryan Albrecht and Karolis Grinkevičius for their help on this bugfix release.

0.4.0

Features:

  • collect and report flow preamble annotation type along with coverage information (thanks to Ryan Albrecht)

Bug Fixes:

  • fixed bug related to ignored custom threshold in the rendered HTML report (thanks to Boris Egorov)
  • fixed coverage percent 0 rendered as NaN in report text
  • upgraded flow to v.0.57.3 and fixed new flow error (Julien Wajsberg)
  • fix flow coverage for escaped special chars in filenames

Thanks to Ryan Albrecht, Boris Egorov, Julien Wajsberg for their help on this new release.

0.3.0

Introduces the new command line options:

  • submit more then 1 concurrent file to flow using -c numManConcurentFilesSubmitted (defaults to 1)
  • load options from a specific config file using --config filepath and disable config loading using --no-config

flow-coverage-report v0.3.0 loads the configuration automatically from the flow-coverage-report section of the target project package.json (or from a .flow-coverage-report.json file in the project dir), which is going to help to reduce the number of command line options that have to be explicitly passed on the command line.

In this version, the flow-coverage-report npm package is also switching to a MIT license.

Features:

  • enhancements on the HTML report template (thanks to Jason Laster)
  • added optional -c/--concurrent-files option, to submit multiple files to flow
  • optionally load config from package.json or json config file

Bug Fixes:

  • fixed missing error exit code with text reporter
  • fixed the link to GitHub in the cli help
  • saved collected coverage data in temp json file to support larger project

Thanks to Ryan Albrecht, Jason Laster, Guillaume Claret and Steven Luscher for their help on this new release.

0.2.0

Introduces the new command line options:

  • excluded file patterns using -x "pattern"
  • customize the output dir using -o reportDirPath

flow-coverage-report v0.2.0 also introduces some fixes needed to be able to generate flow coverage reports on larger projects (and projects with flow issues) and new command line options:

  • fix: fixed NaN percent and React false-positive mutation warning (thanks to Ilia Saulenko)
  • feat: new -o cli option to customize the output dir (thanks to Ryan Albrecht)
  • fix: cleanup old dirs before a new babel build (thanks to Ryan Albrecht)
  • fix: fixed issues with larger projects and projects with flow issues (thanks to Ilia Saulenko and Ryan Albrecht for the help hunting this issue down)
  • feat: new -x cli option to exclude files from the coverage report
  • fix: fixed report-text rendering issues on larger number of files
  • feat: highlight files with errors and no coverage data in the reports
  • feat: included URL to the generated HTML report in the console output (thanks to Jason Laster)

Thanks to Ilia Saulenko, Ryan Albrecht and Jason Laster for their help on this new release.

0.1.0

Initial prototype release:

  • collect and report coverage data as json, text and html
  • navigable sourcefile coverage html view based on CodeMirror
  • run unit tests on travis

Thanks to Kumar McMillan and Andy MacKay for their advice and support, this project and its github repo wouldn't exist without you.

flow-coverage-report's People

Contributors

apolishch avatar benadamstyles avatar brianzchen avatar clarus avatar dolphin278 avatar greenkeeper[bot] avatar jasonlaster avatar joshuanapoli avatar julienw avatar karolisgrinkevicius avatar loganbarnett avatar rpl avatar ryan953 avatar scott-silver avatar steveluscher avatar victorrodrigues avatar zeorin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flow-coverage-report's Issues

lcov report

Hi there,

I would love to use this tool with codecov.io but I think I will need a lcov report, can you tell me what needs to be done than I will try to have a look into it 👍

Ability to mark certain parts of code as covered in order to achieve 100% coverage.

First of all, this looks like a great tool. I still find that, for example, when I call
const result: MyType = await response.json() on an isomorhic-fetch I get that part of code uncovered, whatever I do. The other place is a default (action: empty) guard in a react-redux reducer which is also reported as an uncovered code.

I want to try to get a 100% coverage, if that is possible at all, and thus would like to mark "unsafe" places somehow, the first idea is to analyze the generated json file, extract "uncovered_locs" together with a source code for those chunks and get rid of those pieces of code which I explicitly specify. The other option would be to somehow annotate those places directly, although no ideas how, may be with a special comment like
const result: MyType = /*UnsafeStart*/ response.json() /*UnsafeEnd*/

stdout maxBuffer exceeded

Getting Error while generating Flow Coverage Report: Error: stdout maxBuffer exceeded Error: stdout maxBuffer exceeded for some reason.

node: v6.2.0
command: node_modules/.bin/flow-coverage-report -i 'src/**/*.js' -t html -t json -t text

Propose to move react and react-dom to peerDependencies

Currently react and react-dom specified as dependencies in package.json.
If user use next React version, e.g. React v16, there will have some unexpected dependencies in node_modules.
Here to propose move them as peerDependencies.

ERROR: The included glob needs to be quoted

Hello. I'm trying to use this package, but am running into an odd problem when attempting to run a report over a directory of files.

The command I'm using is:

yarn flow-coverage-report -- -i 'app/**/*.js'

This results in:

ERROR: The include glob needs to be quoted. error Command failed with exit code 1.

The odd thing is, I can run this command successfully on a directory that doesn't exist (say I swap app with xyz. I can also run the report on a single js file.

I get the same result running the package directly (outside of yarn). Thanks!

`flow-coverage-report` should work with `// @flow strict` declaration

When I run the following command:

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

I get this error for any file with a // @flow strict header:

Error while generating Flow Coverage Report: Error: Unexpected missing flow annotation on src/.../foo.js Error: Unexpected missing flow annotation on src/.../foo.js

When I remove 'strict' from that header comment, the errors moves on to another file with it. This is syntax officially supported by flow (https://flow.org/en/docs/strict/) so expected it to work with this tool.

Renamed Properties

Hi,

I get the following warnings when running flow-coverage-report from my package.json:

WARN: "includeGlob" config file property has been renamed to "globIncludePatterns"
WARN: "excludeGlob" config file property has been renamed to "globExcludePatterns"
WARN: "type" config file property has been renamed to "reportTypes"

Is there any reason these changes haven't been made in the README? If not I can submit a PR.

not using my .flowconfig?

when i use flow-coverage-report through my package.json, none of my .flowconfig settings get picked up. this results in a lot of false negatives (basically, every single imported 3rd party module gets marked as not typed)

my settings look like this:

screen shot 2017-11-14 at 11 24 38 pm

Programmatic api

It would be really useful for integrating with other tools if flow-coverage-report had a programmatic api.

import flowCoverageReport from 'flow-coverage-report'

flowCoverageReport(options).then(({percent}) => console.log(`${percent}% covered`))

Unpin dependencies

Because this project uses pinned dependency versions, it's very likely that consumers will end up with multiple versions of various dependencies like React. React doesn't like to have multiple versions, and in some cases this is causing me problems.

I think it would be better to use semver and specify only the minimum required versions, and allow proper dependency resolution. You can check in a package.lock or yarn.lock file to ensure that consistent versions are used during development, if you like. But I don't think it's a good idea to pin dependencies as you have in your package.json.

Allow threshold to be applied on a per file basis

This is a feature request and pool for ideas.

I can cannot achieve 100% coverage for the reasons explained here, but I want to make sure as the codebase grows that the amount of untyped code will not grow.

One way to limit this is to enforce coverage on a per-file basis. Theory being e.g. 95% on each file is better then 99% overall.

There would also need to be an additional option to specify a coverage map which would describe override thresholds for files that need it (for example, files that use exceptions from catch.

Thoughts?

Add indication of whether files include the @flow annotation

When incrementally adding flow coverage to an existing project it is recommended to add the @flow annotation to one file, run flow to see a list of errors and proceed to fix those errors before starting on the next file. See https://flowtype.org/docs/existing.html. However it's not reasonable to expect each file will achieve 100% coverage after it has been touched because not all of the dependencies will have coverage either.

Tp support this workflow it would be helpful if flow-coverage-report would indicate not just what percent of a file is covered by flow, but which files have /* @flow */ or /* @flow weak */ annotations. This would make it easier to ensure that all statements are covered, but also that errors/warnings are emitted by flow when they should be.

license issue - org doesn't support Mozilla Public License :-(

Hi,
I was trying to implement your amazing package, but I've run into a bit of problem internally with the license.
It looks like we don't support the Mozilla Public License, and that's turning out to be a real blocker for me :-(
I think I would have more luck using your package internally if the license were one of these:

  • Apache 2.0 License
  • BSD "2-clause" or "Simplified" License
  • BSD "3-clause" License
  • MIT License
  • Code Project Open License 1.02
  • Microsoft Public or "Permissive" License
  • PostgreSQL License
  • Scala License
  • zlib/libpng License
  • ISC
  • WTFPL (slightly offensive)
  • Public Domain Dedication
  • The Unlicense
  • Creative Commons Attribution License (but NOT other Creative Commons licenses such as ShareAlike and Noncommercial)

Any help or consideration you could offer would be appreciated! I'd love to have the ability to use your package here at LinkedIn!

  • John

#1

Sorting a long list in the web view is slow

Sorting the columns of a report with ~5500 files/table rows takes ~40 seconds for the first sort, then ~6seconds for subsequent ones.

First sort (by uncovered lines, descending):
screen shot 2018-11-28 at 8 57 38 am

Subsequent Sort (uncovered lines, asc):
screen shot 2018-11-28 at 8 58 42 am

Overhead from jQuery is the likely culprit. Google shows there are many other drop-in options that may or may not work just as well. I've no suggestions. I'll try to test a few out and see about a PR

Support higher coverage threshold precision

It would be nice to be able to get the coverage in decimal points (e.g. 52.34%) and likewise fix the threshold to a custom precision (e.g. --threshold 52.34).

The use case I have in mind is bigger code bases where 100 lines of code being covered or not would currently result in the same coverage percentage, so there is no fine way to control the threshold.

Is there any plan to output xml in cobertura format?

We use Jenkins for CI. For now, we are linking to the html version of flow coverage report, which is awesome. But we want to use cobertura to have better historical graph and simple statistics in task view.

Is there any plan to output xml in cobertura format? Or anyone knows if there's already some scripts available to convert the json result into cobertura format?

How to report coverage only on files marked with "// @flow"?

I started to add flow annotations to my project by adding // @flow to certain files.
I would like to make sure that those files are passing a certain flow coverage threshold.

At the moment, it looks like the files included in the coverage report are based on -i (and -x).
This causing the covered percent to be very low.

Is it possible to report coverage only on files marked with // @flow?

File list in generated index.html can be long

The generated index.html list of files can get really long for large projects. It would be helpful to split the output by source folder and summarize the coverage info for everything below.

ie:

index.html

Filename Percent
📁 js/components/comments 90%
📃 js/components/ListView.react.js 100%

comments_index.html

Filename Percent
📃 js/components/comments/Composer.react.js 80%
📃 js/components/comments/Comment.react.js 100%

Display coverage percent with decimals

Hi!
First of all, thanks for the great lib :) It really helps us tracking+finding how to improve our coverage!

I wanted to suggest a feature, it would be great to be able to see the decimals of the coverage in the final summary. For instance:

project percent total covered uncovered
app 70.97 % 35616 25277 10339

(instead of just 70%)

It would allow to have a more micro visibility on the impact of the recent changes the developer made.

What do you think about it? I would be happy to help ;)

include covered_locs in json output

Hello! Awesome project! I'm not sure how you can work using Flow without this.

I've been trying to upload the coverage reports to http://codecov.io/ so we can get some additional reporting on our coverage over time. The @codecov team has been really helpful but one thing is missing from the generated report.

There is uncovered_locs but no inverse for covered_locs, only the sum covered_count which doesn't make is possible for them to create the line-by-line report. The flow report only shows lines not covered and therefore Codecov will never know when lines are so it is always resulting in 0% coverage.

Can covered_locs be added to the output?

I searched but couldn't find any previous mention of covered_locs in issues or code. I could try to take a look if I knew where to get started. I'm happy to sit down and pair on this as well.

Example

Oh yeah, here's an example coverage file from our project just in case its useful:
https://codecov.s3.amazonaws.com/v4/raw/2017-01-11/AAA12261C5E4BE20272185677850291B/a1ff5a7fc828aa85277cb09a5e534eb4a699960c/d74f9f70-e1c8-469d-8f37-6cf4e1afe8eb.txt

You have to scroll down to:

# path=/tmp/circle-junit.qhJLwiZ/flow-coverage/flow-coverage.json

Thank you!

😃

Feature request: coverage ignore comments

Ideally I'd have a 100% flow coverage in my projects. However, this is usually not realistic, there are almost always parts of the code base that either can't be covered at all, or are extremely difficult to cover properly. As a result, we generally can't set the threshold to 100% for CI builds, we need to lower it to a somewhat arbitrary lower value. This has as the unintended side-effect that the build will now allow a non-zero percentage of unintended uncovered code as well.

It would therefore be very useful if we could somehow specify that certain parts of the code should not count towards coverage percentage, e.g. by using comments. For example:

/* flow-coverage ignore-next-line */
const y : any; 

const z : any; // flow-coverage-ignore-line

/* flow-coverage ignore-start */
const a : any; 
const b : any;
/* flow-coverage ignore-end */

The tool could still warn about missing coverage, but it just wouldn't count towards to threshold.

With something like this we would be able to set the threshold as 100% and explicitly opt-out of coverage where desired.

Would something like this be possible and desirable for this project?

Escape special shell characters in filenames

I just noticed that flow-coverage-report isn't escaping special chars, and it causes the check to fail.

Without the escaping we're basically asking flow for the ast of some other file:

"error":{"killed":false,"code":10,"signal":null,"cmd":"flow ast /path/to/file-with--a-slash.js"},"stdout":"","stderr":"File not found: /path/to/file-with--a-slash.js\n"}

Should be file-with-\-a-slash.js

I added some fixtures to flow-annotation-check and a little method to help out, here's how it looks:
screen shot 2017-06-08 at 6 04 15 pm

Release new version?

It looks like master is 50+ commits ahead of the latest release (0.3.0). Any chance we can get a new release?

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

[0.3.0] [email protected] reports unused suppression

I've added flow-coverage-report to my project. I'm using [email protected], and it's not configured to ignore node_modules. (I believe this is best practice.)

Flow reports this:

node_modules/flow-coverage-report/src/lib/flow.js:87
 87:   // $FLOW_FIXME: code is there, but flow doesn't seem to know about it.
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error suppressing comment. Unused suppression

I guess an earlier version of flow barfed at the next line. It isn't now, so flow is now differently barfing.

Removing line 87 stops the error, which I guess is the correct fix.

(node:26397) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Missing percent in coverageData

 ~/src/frontend  master ?  flow-coverage-report -f node_modules/.bin/flow -i 'src/**/*.js' -x '**/*-test.js' -x '**/index.js' -t html                                                                 ✓  5575  17:05:17

(node:26397) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Missing percent in coverageData
(node:26397) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Missing percent in coverageData

No other output, although it does write a report to file.

NaN in text report

If a file with no type at all, flow-coverage-report returns this result line:

src/url.js                          │   NaN % │     7 │       0 │         7

I first thought it was a division by 0, but then realised that's the other way around.

Maybe unrelated, but when I then try to generate an html report, I get:

(node:54292) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Missing percent in coverageData
(node:54292) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

For reference, here is the content of the src/url.js file:

// @flow

const url: any = window.URL || window.webkitURL || window.mozURL

export default url

Not working on Windows

Not working properly on Windows.

I've tested it on multiple different Windows and Linux computers. It works perfectly on Linux, but on Windows, here's what the output looks like:

┌──────────┬─────────┬───────┬─────────┬───────────┐
│ filename │ percent │ total │ covered │ uncovered │
└──────────┴─────────┴───────┴─────────┴───────────┘
┌─────────────────────────┬───────────────────────────────────────────────────────────┐
│ included glob patterns: │ 'core/src/**/*.js'                                        │
│ excluded glob patterns: │ '**/node_modules/**'                                      │
│              threshold: │ 1                                                         │
│       concurrent files: │ 20                                                        │
│           generated at: │ Wed Oct 18 2017 14:46:14 GMT+0200 (Romance Daylight Time) │
│           flow version: │ 0.52.0                                                    │
│      flow check passed: │ no ( >= 50 errors)                                        │
└─────────────────────────┴───────────────────────────────────────────────────────────┘
┌───────────┬─────────┬───────┬─────────┬───────────┐
│ project   │ percent │ total │ covered │ uncovered │
│ workspace │   100 % │     0 │       0 │         0 │
└───────────┴─────────┴───────┴─────────┴───────────┘
View generated HTML Report at file://C:\Jenkins\jobs\ActiveUI-nightly\workspace/dist-coverage/flow/index.html

The above output was reproduced on two different very different Windows computers, so this is likely not an environment-related issue, but rather an issue in this project.

Failing to Generate Coverage for Some Files

I'm running flow-coverage-report against a moderately large codebase. It's failing get coverage information for some files, seemingly at random. I'm not sure what's different about these files from the others.

An example:

ERROR Collecting coverage data from scripts/uglify.js { Error: Command failed: flow coverage --json scripts/uglify.js
    at ChildProcess.exithandler (child_process.js:297:12)
    at ChildProcess.emit (events.js:197:13)
    at maybeClose (internal/child_process.js:984:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
  killed: true,
  code: null,
  signal: 'SIGTERM',
  cmd: 'flow coverage --json scripts/uglify.js' }

Interestingly, running flow coverage --json scripts/uglify.js manually works completely fine. The number of files it fails on also seems to vary depending on what the -c flag has been set to. If it's left on the default of 1, it fails on about a third to half of the files, and setting it to 4 causes it to fail on all of the files in the entire codebase.

Should not fail annotation check if .flowconfig [options] all=true

I'm starting a new project from scratch and want to have things type checked with Flow as best as I can from the start. To that end, I'm using all=true under the [options] section of my .flowconfig. with all of my code in {project dir}/src, I run the coverage tool as:

yarn run flow-coverage-report -i src/**/*.js

All of the files come back marked red/failing due to no flow annotation regardless of coverage %, which makes it more annoying to identify which files actually need attention. With the all=true option enabled, no annotation should not be a reason for failing.

Not sure how to type a required library

I'm using the tool for the first time, and I'm finding something weird. I'm typing the variables that I require, but the tool still tells me that the line is not fully covered because I need to type also the required part. But I'm not sure how to type it. Maybe is this s bug? I'm not really sure. Here it is a screenshot of my output:

screenshot 2018-04-10 16 41 29

Fails to typecheck with flow 0.54.1

When using flow in a project where flow-coverage-report is installed to node_modules, I get the following errors:

Error: node_modules/flow-coverage-report/src/lib/report-html.js:70
                v------------------------
 70:     return Promise.reject(new Error(
 71:       'filename is not relative to the projectDir: ' +
 72:         [opt.projectDir, opt.filename].join(' - ')
 73:     ));
         -^ type parameter `T` of call of method `reject`. Missing annotation

Error: node_modules/flow-coverage-report/src/lib/report-html.js:181
                v-----------------------------------------
181:     return waitForReportContent.then(function (res) {
182:       var reportFilePath = res.reportFilePath;
183:       var reportFileContent = res.reportFileContent;
...:
188:     });
         -^ type parameter `U` of call of method `then`. Missing annotation

Error: node_modules/flow-coverage-report/src/lib/report-html.js:191
191:   return Promise.reject(new Error('Unknown report type: ' + opt.type));
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` of call of method `reject`. Missing annotation

I've excluded flow-coverage-report via my .flowconfig for now, but it would be nice to have this fixed upstream.

Configuration error: ERROR: No glob has been specified.

I just installed the module globally. When I run:
flow-coverage-report report -i "src/**/*.js"
straight from the examples (which happens to match my dir structure) I get:
Configuration error: ERROR: No glob has been specified.

Am I doing something stupid here?

Kill the Flow server after coverage report generation

flow-coverage-report starts a Flow server in:

const res = await exec(`${flowCommandPath} status --json`,
{cwd: projectDir, maxBuffer: Infinity},
{dontReject: true});

but never stops it. The server process thus continues running unnoticed in the background.

When using services like CircleCI, running flow-coverage-report without running flow stop manually afterwards will fail the build. Indeed, CircleCI will consider that the Flow process has been running for too long, will terminate it, and mark the build as failed.

Would you please consider making flow-coverage-report stop the Flow server when it started it itself?

Thanks.

doesn't output any files

I ran the following command:

./node_modules/.bin/flow-coverage-report \\
-f ./node_modules/.bin/flow \\
-i 'packages/wonder-blocks-*/**/*.js' \\
-x 'packages/wonder-blocks-*/dist/*.js' -x '**/generated-snapshot.test.js' \\
-o "./flow-coverage"

and it prints out the coverage but doesn't store the output anywhere. The -o seems redundant since "./flow-coverage" is the default so I tried with and without that parameter with the same results.

Help with invoking coverage programatically

Hi,
I stumbled across some difficulties when trying to invoke flow-coverage-report from npm script.

I'm using execa for this but it was reproduced with child_process too.

 await execa.shell('yarn flow-coverage-report --project-dir /rootDir --output-dir /rootDir/coverage -t json --threshold 1 --include-glob /rootDir/src/**/*.js --exclude-glob /rootDir/src/legacy/**/*.js')

What I get is

message: Command failed: <command>
    Error while generating Flow Coverage Report: [object Object] undefined␊
    error Command failed with exit code 255.␊

Invoking command from command line seems to work pretty well.
Issue is gone after removing --project-dir, though

Error: Command failed: node_modules/.bin/flow status --json

Hey there,

I would really like to get such a cool coverage report for my project. Unfortunately the latest version says that node_modules/.bin/flow status --json fails. I can verify that, this command needs a file as a target. My call is flow-coverage-report -i './src/**/*.js' -x './node_modules' -f node_modules/.bin/flow -t html -t json -t text. Am I misusing this library?

JSX Syntax Highlighting is broken in the report

codemirror supports jsx you should just add it to the list of dropdown options.
maybe you assume all jsx files have jsx extentions which is not correct all the time.
I have jsx inside my normal js files

Threshold option for max uncovered line count

It'd be really useful to be able to specify a threshold on uncovered line count, i.e. a maximum number of uncovered lines.

Why? In a codebase which continuously grows, if you fix the number of lines uncovered then you (loosely) enforce that all new code should be covered.

It's a neat trick which provides an automatic coverage ratchet, so long as the codebase keeps growing.

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.