Detect code duplicates in make-check run

It uses jscpd project by invoking it using npm script
"duplication". For now set minimum lines to report
as 26, because we have some 25 line duplicates.
Later we can reduce that number.

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I20e0ba9a07528e15a65f01d2247420da33339749
pull/7260/head
Szymon Kłos 2023-09-04 09:57:09 +02:00 committed by pedropintosilva
parent b3abc03d27
commit 76f0b11551
3 changed files with 14 additions and 1 deletions

2
browser/.gitignore vendored
View File

@ -8,8 +8,10 @@ index.html
bower.json
component.json
mocha.log
mocha_tests/*.js
tscompile.done
duplication.log
_site
dist/*.js

View File

@ -797,6 +797,7 @@ build-tests: $(MOCHA_TS_JS_FILES)
@echo "Build of mocha test finished."
MOCHA_TEST_LOG = "`pwd`/mocha.log"
DUPLICATION_TEST_LOG = "`pwd`/duplication.log"
check-local: $(MOCHA_TS_JS_FILES)
@echo "Running mocha tests..."
@echo > ${MOCHA_TEST_LOG}
@ -806,6 +807,14 @@ check-local: $(MOCHA_TS_JS_FILES)
cat ${MOCHA_TEST_LOG}; \
exit 1; \
fi
@echo "Checking code duplication..."
@echo > ${DUPLICATION_TEST_LOG}
@if npm run duplication 2> ${DUPLICATION_TEST_LOG} 1>&2; then \
echo "Code duplication tests finished successfully."; \
else \
cat ${DUPLICATION_TEST_LOG}; \
exit 1; \
fi
# the delay (in milliseconds) between each emulated key stroke for each view
typing_speed=100

View File

@ -20,6 +20,7 @@
"jquery-contextmenu": "2.9.2",
"jquery-mousewheel": "3.1.13",
"jquery-ui": "1.13.2",
"jscpd": "3.5.9",
"l10n-for-node": "0.0.1",
"mocha": "8.2.1",
"pako": "2.0.4",
@ -49,6 +50,7 @@
},
"scripts": {
"test": "mocha 'mocha_tests/**/*.js'",
"test-single": "mocha"
"test-single": "mocha",
"duplication": "jscpd ./src/ --exitCode 1 --min-lines 26"
}
}