Reputation: 792
Some background: I am developing two main projects. The first project is an API written in TypeScript using NodeJS. The second project is also written in TypeScript, using Ionic Framework to develop a hybrid mobile application.
I recently added jscpd
to my project to detect duplicate blocks of code. It works very well except for one primary issue: it detects import statements as code duplications.
My question: How do I force jscpd
to ignore all import statements in my code?
The documentation for jscpd is quite lousy and there seems to be no answers online. I could only find one resource that addresses this issue (on GitHub Issues), and the project maintainer just dismissed the issue rather than providing an actual solution.
Below is my config file:
.jscpd.json
{
"path": ["src/"],
"output": "cpd",
"reporters": ["console", "html"],
"minLines": 2,
"minTokens": 10,
"blame": true,
"threshold": 0.1,
"languages": ["typescript"],
"ignore": ["import .*"]
}
My script to run jscpd
is:
jscpd --config .jscpd.json # Execute jscpd
open ./cpd/html/index.html # Open the results in the browser
Upvotes: 2
Views: 724
Reputation: 51
There is no magic.
You can add
/* jscpd:ignore-start */
import ....
/* jscpd:ignore-end */
Take a look here : https://github.com/kucherenko/jscpd/issues/341#issuecomment-2016830988
Upvotes: 0