From a8284d136eaa67724411b774cfd833bb67da93e5 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Wed, 1 Apr 2020 15:16:08 +0300 Subject: [PATCH 1/2] make cpd paths relative, so developers won't rewrite entire file --- xcode/build_phases/copy_paste_detection.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xcode/build_phases/copy_paste_detection.sh b/xcode/build_phases/copy_paste_detection.sh index 884e1c3..a8a167a 100644 --- a/xcode/build_phases/copy_paste_detection.sh +++ b/xcode/build_phases/copy_paste_detection.sh @@ -9,8 +9,12 @@ if which pmd >/dev/null; then pmd cpd --files ${SOURCES_DIR} --exclude ${FILES_TO_EXCLUDE} --minimum-tokens 50 --language swift --encoding UTF-8 --format net.sourceforge.pmd.cpd.XMLRenderer > ${REPORTS_DIR}/cpd-output.xml --failOnViolation true # running script - php ./build-scripts/xcode/aux_scripts/cpd_script.php ${REPORTS_DIR}/cpd-output.xml | tee ${REPORTS_DIR}/CPDLog.txt + readonly WARNINGS=$(php ./build-scripts/xcode/aux_scripts/cpd_script.php ${REPORTS_DIR}/cpd-output.xml) + # Make paths relative to SOURCES_DIR, so different developers won't rewrite entire file + readonly SED_REPLACEMENT_STRING=$(echo ${SOURCES_DIR} | sed "s/\//\\\\\//g") + echo ${WARNINGS} | sed "s/${SED_REPLACEMENT_STRING}//" > ${REPORTS_DIR}/CPDLog.txt + echo ${WARNINGS} else echo "warning: pmd not installed, install using 'brew install pmd'" exit 1 -fi +fi \ No newline at end of file From 1a5abfc580bf916bbc54cd694b1010bd097c04ff Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Wed, 1 Apr 2020 16:07:36 +0300 Subject: [PATCH 2/2] fix multiline warnings --- xcode/build_phases/copy_paste_detection.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xcode/build_phases/copy_paste_detection.sh b/xcode/build_phases/copy_paste_detection.sh index a8a167a..d1ead79 100644 --- a/xcode/build_phases/copy_paste_detection.sh +++ b/xcode/build_phases/copy_paste_detection.sh @@ -8,12 +8,12 @@ if which pmd >/dev/null; then pmd cpd --files ${SOURCES_DIR} --exclude ${FILES_TO_EXCLUDE} --minimum-tokens 50 --language swift --encoding UTF-8 --format net.sourceforge.pmd.cpd.XMLRenderer > ${REPORTS_DIR}/cpd-output.xml --failOnViolation true - # running script - readonly WARNINGS=$(php ./build-scripts/xcode/aux_scripts/cpd_script.php ${REPORTS_DIR}/cpd-output.xml) + php ./build-scripts/xcode/aux_scripts/cpd_script.php ${REPORTS_DIR}/cpd-output.xml | tee ${REPORTS_DIR}/CPDLog.txt + # Make paths relative to SOURCES_DIR, so different developers won't rewrite entire file readonly SED_REPLACEMENT_STRING=$(echo ${SOURCES_DIR} | sed "s/\//\\\\\//g") - echo ${WARNINGS} | sed "s/${SED_REPLACEMENT_STRING}//" > ${REPORTS_DIR}/CPDLog.txt - echo ${WARNINGS} + + sed -i '' "s/${SED_REPLACEMENT_STRING}//g" "${REPORTS_DIR}/CPDLog.txt" else echo "warning: pmd not installed, install using 'brew install pmd'" exit 1