kucherenko / jscpd

Copy/paste detector for programming source code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Need an option to exclude a pattern from code duplication calculation

rkjaiswal1 opened this issue · comments

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
There are situations where particular piece needs to be re-used in many files. For exx import statements in java. Need an option to pass file with those contents to be excluded from code duplication calculation and reporting.

Like jscpd --exclude file1.txt.
content of file1.txt can be

/*import 1
impor2
import 3
impor4
*/

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Thank you for the request, it is looks interesting, will add the feature

ignore command will helps you with no jscpd enhancements!

https://github.com/hata6502/ignore-files

Example:

jscpd $(zsh -c "echo **/*" | ignore .jscpdignore)

.jscpdignore

example
node_modules

@hata6502 the idea here is have some files or blocks of code with content what will be excluded from detection, not just based on filename but on content, I think it can be interesting

Oh, Sorry!
this issue focuses an option to exclude a "pattern", OK.

would be nice to have a regexp pattern here. For example, js solution in .jscpd.json could be:

    "ignore": ["**/lib/constants/*.json"],
    "ignorePattern": ["import .* from '.*';"]

My solution

jscpd `git ls-files`

Is this feature supported? I configured it and it didn't seem to work.
'ignore-pattern': 'import.*'

@Confetti7 ignore-pattern used for excluding from detection files, not contect

@Confetti7 ignore-pattern used for excluding from detection files, not contect

@kucherenko

$ jscpd /path/to/source --ignore-pattern "import.*from\s*'.*'"

Is this answer still valid? Your docs say the opposite of what your comment says, including an example with imports