Giter VIP home page Giter VIP logo

Comments (8)

gotwarlost avatar gotwarlost commented on June 9, 2024

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.

Raynos avatar Raynos commented on June 9, 2024

@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.

gotwarlost avatar gotwarlost commented on June 9, 2024

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.

Raynos avatar Raynos commented on June 9, 2024

@gotwarlost bump the major version number. semver works.

from istanbul.

gotwarlost avatar gotwarlost commented on June 9, 2024

:)

from istanbul.

gotwarlost avatar gotwarlost commented on June 9, 2024

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.

gotwarlost avatar gotwarlost commented on June 9, 2024

Available in v0.1.38

from istanbul.

Raynos avatar Raynos commented on June 9, 2024

@gotwarlost nice! thanks :)

from istanbul.

Related Issues (20)

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.