Error in logic of getLinesCount function
NieZhuZhu opened this issue · comments
弹铁蛋 commented
Describe the bug
I got the wrong statistics.forms[XX].lines from this jscpd-report.json
file. The data is always 1 less than the real data
To Reproduce
Steps to reproduce the behavior:
await jscpd([
'',
'',
...pathFinal,
'-i',
...ignorePath,
'--reporters',
'json',
'-o',
'.',
'-s',
'-g',
]).catch((err: any) => {
console.log('jscpd', err)
})
Expected behavior
// https://github.com/kucherenko/jscpd/blob/master/packages/tokenizer/src/token-map.ts#L47
public getLinesCount(): number {
return this.tokens[this.tokens.length - 1].loc.end.line - this.tokens[0].loc.start.line + 1;
}
Desktop (please complete the following information):
- OS Version 10.14.6
- NodeJS Version 12.16.3
- jscpd version 3.3.24
Andrey Kucherenko commented
Thank you for the report, will fix