Comments (8)
That's because the statement coverage for the function is added just before it and doesn't get executed due to the early return.
I'm not going to fix this because it is non-trivial to do it correctly for the general case and I don't see the value of adding complexity to the instrumenter for this edge case.
Let me know if you don't agree.
from istanbul.
@gotwarlost can you add an option to not complain about "dead code" not being covered after the return statement ?
I really like the function declarations after statements in the function body coding style.
from istanbul.
So I think the real fix is to not consider function declarations as a "statement" at all. That way this case is easily covered.
But this fix, which in my opinion is correct, might cause a lot of people to yell at me because their coverage numbers "suddenly changed" (the numbers should go up in most cases so maybe they won't yell as loudly).
I'm still concerned about making this change for this reason.
from istanbul.
@gotwarlost bump the major version number. semver works.
from istanbul.
:)
from istanbul.
OK, I'm not going to consider function declarations as "not a statement" which will cause aforementioned ire (actually the coverage numbers go down because the percentage of uncovered statements will be higher now that the total number of statements has decreased).
I'm just going to consider function dclarations as a statement with an initial cover count of 1 so that function declarations will always be seen as covered no matter where you put it. This is mostly correct in that the function declaration is a statement and it is always executed from the compiler's viewpoint.
from istanbul.
Available in v0.1.38
from istanbul.
@gotwarlost nice! thanks :)
from istanbul.
Related Issues (20)
- Looking for Constantinople.js HOT 1
- is it possible to apply the effect from /* istanbul ignore next */ to all typescript private methods automagically?
- option to disable coverage on import lines
- Open Coverage File Automatically on Test Command? HOT 2
- Branches that don't exist get reported as missing
- how to use istanbul as a library
- Analyzing coverage of node server in Windows HOT 1
- exclude imported node modules from coverage reporting HOT 1
- Cannot get the backend coverage by running Cypress UI e2e test HOT 1
- Ignore implied "else"
- Coverage format documentation not explicitly stating 'end' meaning HOT 1
- Istanbul doesn't ignore nested if, when not executed
- Async package is vulnerable
- Coverage not being collected from file called "payload.ts"
- Fails when running `istanbul report` HOT 1
- Unit test branch for SignInPage showing the SignUpComponent
- Ignore docs could be clarified by adding a list of allowed keywords
- Code comments are being covered.
- Feature Request - Parcel plugin
- No function coverage for named exports in barrel file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from istanbul.