istanbuljs / nyc

the Istanbul command line interface
https://istanbul.js.org/
ISC License
5.55k stars 353 forks source link

Funcs coverage below 100% while Stmts coverage at 100% #1480

Open oprogramador opened 1 year ago

oprogramador commented 1 year ago

Observed Behavior

Expected Behavior

98.66% Funcs coverage means that there's at least one function that hasn't been invoked (including arrow functions and class/object methods). 100% Lines coverage looks potentially normal because in the same line there might be some logic which is executed and an arrow function which isn't. However, when even Stmts is 100%, for me it's not normal because if a given function isn't invoked, it means that there's at least one statement in that function which isn't invoked.

Troubleshooting steps

Environment Information

⟩ npx envinfo@latest --preset nyc
npx: installed 1 in 1.054s

  System:
    OS: Linux 5.4 Linux Mint 20 (Ulyana)
    CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
    Memory: 776.19 MB / 15.37 GB
  Binaries:
    Node: 14.17.6 - ~/.nvm/versions/node/v14.17.6/bin/node
    Yarn: 1.22.15 - ~/.nvm/versions/node/v14.17.6/bin/yarn
    npm: 6.14.15 - ~/.nvm/versions/node/v14.17.6/bin/npm
  npmPackages:
    nyc: ^15.1.0 => 15.1.0 
oprogramador commented 1 year ago

One of the methods in my class was empty. That was my assumption. I wasn't able to find anything when looking for an empty arrow function (()=>{}), and my class is very long so it was a bit difficult to find that empty method.

However, in such a case, IMO nyc should show the line number of the function which isn't invoked so we could save a lot of time.