gotwarlost / istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k stars 785 forks source link

Variable declaration is incorrectly marked as not run #417

Open blakeembrey opened 9 years ago

blakeembrey commented 9 years ago

Any variable initialization below return is marked as not run, even though the JavaScript runtime would have hoisted it. This code is being generated by a transpiler for JS, so it's unusual, but not incorrect.

image

gotwarlost commented 9 years ago

This is similar to function declarations in the same scope for which istanbul has some crazy hacks to report "coverage" correctly. I think istanbul should not even consider function declarations and variable declarations that do not have an initializer. This is not trivial to fix without a major version upgrade since it is a change to coverage behavior.