create code-quality-reports folder for cpd and unused; check if cpd is installed; run cpd for all targets
This commit is contained in:
parent
7a29254c2e
commit
1d0ef76314
|
|
@ -90,7 +90,8 @@ class Unused
|
|||
puts "Unused Code Warning!: warning: Total Count #{unused_warnings.length}"
|
||||
puts "#{unused_warnings.map { |e| e.to_xcode}.join("\n")}"
|
||||
# write log
|
||||
File.open("UnusedLog.txt", "w") do |file|
|
||||
Dir.mkdir(directory_name) unless File.exists?("code-quality-reports")
|
||||
File.open("code-quality-reports/UnusedLog.txt", "w") do |file|
|
||||
file.write("Unused code warnings count: #{unused_warnings.length}\n\n")
|
||||
file.write("#{unused_warnings.map { |e| e.serialize }.join("\n")}")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
# running CPD
|
||||
SOURCES_DIR=${1:-${EXECUTABLE_NAME}} # first argument or EXECUTABLE_NAME
|
||||
pmd cpd --files ${SOURCES_DIR} --exclude ${EXECUTABLE_NAME}/Generated --minimum-tokens 50 --language swift --encoding UTF-8 --format net.sourceforge.pmd.cpd.XMLRenderer > cpd-output.xml --failOnViolation true
|
||||
if which pmd >/dev/null; then
|
||||
# running CPD
|
||||
readonly SOURCES_DIR=${1:-${PROJECT_DIR}} # first argument or PROJECT_DIR
|
||||
readonly REPORTS_DIR=${PROJECT_DIR}/code-quality-reports
|
||||
readonly FILES_TO_EXCLUDE=`find ${SOURCES_DIR} -type d -name Localization -or -name Generated -or -name Pods | paste -sd " " -`
|
||||
|
||||
# running script
|
||||
php ./build-scripts/xcode/aux_scripts/cpd_script.php -cpd-xml cpd-output.xml
|
||||
mkdir ${REPORTS_DIR}
|
||||
|
||||
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 -cpd-xml ${REPORTS_DIR}/cpd-output.xml | tee ${REPORTS_DIR}/CPDLog.txt
|
||||
else
|
||||
echo "warning: pmd not installed, install using 'brew install pmd'"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in New Issue