File indexing completed on 2024-05-19 04:19:13
0001 #!/bin/bash 0002 0003 # SPDX-FileCopyrightText: 2013-2024 by Gilles Caulier, <caulier dot gilles at gmail dot com> 0004 # 0005 # Run CppCheck static analyzer on whole digiKam source code. 0006 # http://cppcheck.sourceforge.net/ 0007 # Dependencies : Python::pygments module to export report as HTML. 0008 # 0009 # If '--nowebupdate' is passed as argument, static analyzer results are just created locally. 0010 # 0011 # SPDX-License-Identifier: BSD-3-Clause 0012 # 0013 0014 # Halt and catch errors 0015 set -eE 0016 trap 'PREVIOUS_COMMAND=$THIS_COMMAND; THIS_COMMAND=$BASH_COMMAND' DEBUG 0017 trap 'echo "FAILED COMMAND: $PREVIOUS_COMMAND"' ERR 0018 0019 . ./common.sh 0020 0021 checksCPUCores 0022 0023 ORIG_WD="`pwd`" 0024 REPORT_DIR="${ORIG_WD}/report.cppcheck" 0025 WEBSITE_DIR="${ORIG_WD}/site" 0026 0027 # Get active git branches to create report description string 0028 TITLE="digiKam-$(parseGitBranch)$(parseGitHash)" 0029 echo "CppCheck Static Analyzer task name: $TITLE" 0030 0031 rm -fr $REPORT_DIR 0032 rm -fr $WEBSITE_DIR 0033 0034 # Do not parse unwanted directories accordingly with Krazy configuration. 0035 krazySkipConfig 0036 0037 IGNORE_DIRS="" 0038 0039 for DROP_ITEM in $KRAZY_FILTERS ; do 0040 IGNORE_DIRS+="-i../../$DROP_ITEM/ " 0041 done 0042 0043 # List sub-dirs with headers to append as cppcheck includes paths 0044 HDIRS=$(find ../../core -name '*.h' -printf '%h\n' | sort -u) 0045 0046 for INCLUDE_PATH in $HDIRS ; do 0047 INCLUDE_DIRS+="-I $INCLUDE_PATH/ " 0048 done 0049 0050 cppcheck -j$CPU_CORES \ 0051 -DQ_OS_LINUX \ 0052 --verbose \ 0053 --std=c++17 \ 0054 --library=qt.cfg \ 0055 --library=opencv2.cfg \ 0056 --library=boost.cfg \ 0057 --library=kde.cfg \ 0058 --inline-suppr \ 0059 --xml-version=2 \ 0060 --platform=unix64 \ 0061 --enable=all \ 0062 --max-ctu-depth=4 \ 0063 --report-progress \ 0064 --suppress=*:*cimg*.h \ 0065 --suppress=*:*libraw*.h \ 0066 --suppress=*:*libpgf*.h \ 0067 --suppress=*:*upnpsdk*.h \ 0068 --suppress=*:*yfauth*.h \ 0069 --suppress=*:*o2*.h \ 0070 --suppress=*:*lqr*.h \ 0071 --suppress=*:*libjpeg*.h \ 0072 --suppress=*:*dng_sdk*.h \ 0073 --suppress=*:*xmp_sdk*.h \ 0074 --suppress=variableScope \ 0075 --suppress=purgedConfiguration \ 0076 --suppress=toomanyconfigs \ 0077 --suppress=unreadVariable \ 0078 --suppress=unusedVariable \ 0079 --suppress=unusedStructMember \ 0080 --suppress=unknownMacro \ 0081 --suppress=class_X_Y \ 0082 --suppress=ConfigurationNotChecked \ 0083 --suppress=unmatchedSuppression:* \ 0084 --suppress=useStlAlgorithm \ 0085 --output-file=report.cppcheck.xml \ 0086 $IGNORE_DIRS \ 0087 $INCLUDE_DIRS \ 0088 ../../core 0089 0090 cppcheck-htmlreport --file=report.cppcheck.xml \ 0091 --report-dir=$REPORT_DIR \ 0092 --source-dir=. \ 0093 --title=$TITLE 0094 0095 if [[ $1 != "--nowebupdate" ]] ; then 0096 0097 # update www.digikam.org report section. 0098 updateReportToWebsite "cppcheck" $REPORT_DIR $TITLE $(parseGitBranch) 0099 0100 fi 0101 0102 cd $ORIG_DIR 0103