From c04fd856daf21c7e5c8d822934591a360adbe17d Mon Sep 17 00:00:00 2001 From: "hela.ben-khalfallah" Date: Sun, 2 Jun 2024 14:26:49 +0200 Subject: [PATCH] [FIX]: code duplication exclude --- package.json | 2 +- .../duplication/CodeDuplicationAuditor.js | 28 +++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 7506ec9..28d6737 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "code-health-meter", - "version": "1.7.0", + "version": "1.8.0", "description": "", "main": "src/index.js", "type": "module", diff --git a/src/kernel/duplication/CodeDuplicationAuditor.js b/src/kernel/duplication/CodeDuplicationAuditor.js index 1df4292..a940151 100644 --- a/src/kernel/duplication/CodeDuplicationAuditor.js +++ b/src/kernel/duplication/CodeDuplicationAuditor.js @@ -16,16 +16,28 @@ const defaultOptions = { '**/target/**', '**/dist/**', '**/__mocks__/*', - '**/husky/**', + '**/.husky/**', '**/.vscode/.*', '**/.idea/**', '**/.gitlab/**', '**/.github/**', - 'eslint.*', - 'jest.*', - 'test', - 'next.*', - 'babel.*', + '**/eslint-config/**', + '**/jest-config/**', + '**/tailwind-config/**', + '**/typescript-config/**', + '**/.eslintrc.**', + '**/.gitlab-ci.**', + '**/tailwind.**', + '**/tsconfig.json', + '**/turbo.json', + '**/jest.**', + '**/__test__/**', + '**/**test.**', + '**/**.config.**', + '**/webpack/**', + '**/**webpack**', + '**/next**.**', + 'babel', '.*.d.ts.*' ] }; @@ -45,6 +57,10 @@ const startAudit = async (directory, outputDir, fileFormat) => { AppLogger.info(`[CodeDuplicationAuditor - inspectDirectory] outputDir: ${outputDir}`); AppLogger.info(`[CodeDuplicationAuditor - inspectDirectory] fileFormat: ${fileFormat}`); + // add jscpd if not installed + execSync('npm i -g jscpd@4.0.4'); + + // execute audit const codeDuplicationCommand = `jscpd --silent --mode "${defaultOptions.mode}" --threshold ${defaultOptions.threshold} --reporters "${fileFormat}" --output "${outputDir}" --format "${defaultOptions.format}" --ignore "${defaultOptions.ignore.join(',')}" ${directory}`; AppLogger.info(`[CodeDuplicationAuditor - inspectDirectory] jscpd script: ${codeDuplicationCommand}`);