kucherenko / jscpd

Copy/paste detector for programming source code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in logic of getLinesCount function

NieZhuZhu opened this issue · comments

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;
  }

Screenshots
image

Desktop (please complete the following information):

  • OS Version 10.14.6
  • NodeJS Version 12.16.3
  • jscpd version 3.3.24

Thank you for the report, will fix