Skip to content

Commit

Permalink
No annotation, no coverage
Browse files Browse the repository at this point in the history
When calculating coverage for a project, I don't care about coverage in
files that don't have the `@flow` pragma. While it's nice that Flow
infers types anyway, since it's never going to report an error it
doesn't help me at all and is potentially misleading. For example, my
project is 75% covered with master, but only 34% covered with this
change.

This PR changes flow-coverage-report to ignore coverage in unannotated
files. This could be considered a breaking change or a bugfix - I'm not
sure. You might consider making this a configuration option.

Resolves rpl#85
  • Loading branch information
dmnd committed Jul 10, 2017
1 parent ccabcbd commit 96e25b1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib/flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import temp from 'temp';
import {genCheckFlowStatus} from 'flow-annotation-check';
import {exec, glob, writeFile} from './promisified';

const NO_ANNOTATION_NO_COVERAGE = true; // TODO(dmnd): option or default?

// Load the Array.prototype.find polyfill if needed (e.g. nodejs 0.12).
/* istanbul ignore if */
if (!Array.prototype.find) {
Expand Down Expand Up @@ -237,6 +239,12 @@ export async function collectFlowCoverageForFile(
if (parsedData && !parsedData.error) {
parsedData.filename = filename;
parsedData.annotation = await genCheckFlowStatus(flowCommandPath, filename);

if (parsedData.annotation === 'no flow' && NO_ANNOTATION_NO_COVERAGE) {
parsedData.expressions.uncovered_count += parsedData.expressions.covered_count;
parsedData.expressions.covered_count = 0;
}

return parsedData;
}

Expand Down

0 comments on commit 96e25b1

Please sign in to comment.