File indexing completed on 2024-05-19 04:19:14
0001 #!/bin/bash 0002 0003 # SPDX-FileCopyrightText: 2013-2024 by Gilles Caulier, <caulier dot gilles at gmail dot com> 0004 # 0005 # Run Krazy static analyzer on whole digiKam source code. 0006 # https://github.com/Krazy-collection/krazy 0007 # 0008 # Production revision: 0b3a02537d4c56135bd81cd5e4f436fcea7da657 0009 # Production patch : ./krazy.patch 0010 # 0011 # Dependencies: 0012 # 0013 # - Perl:Tie::IxHash and Perl:XML::LibXML modules at run-time. 0014 # - Saxon 9HE java xml parser (saxon.jar) to export report as HTML [https://www.saxonica.com/download/java.xml]. 0015 # Production files: saxon9he.jar saxon9-test.jar saxon9-xqj.jar 0016 # 0017 # If '--nowebupdate' is passed as argument, static analyzer results are just created locally. 0018 # 0019 # SPDX-License-Identifier: BSD-3-Clause 0020 # 0021 0022 # Halt and catch errors 0023 set -eE 0024 trap 'PREVIOUS_COMMAND=$THIS_COMMAND; THIS_COMMAND=$BASH_COMMAND' DEBUG 0025 trap 'echo "FAILED COMMAND: $PREVIOUS_COMMAND"' ERR 0026 0027 . ./common.sh 0028 0029 checksCPUCores 0030 0031 # Check run-time dependencies 0032 0033 if [ ! -f /opt/saxon/saxon9he.jar ] ; then 0034 0035 echo "Java Saxon 9HE XML parser is not installed in /opt/saxon." 0036 echo "Please install Saxon from https://www.saxonica.com/download/java.xml" 0037 echo "Aborted..." 0038 exit -1 0039 0040 0041 else 0042 0043 echo "Check Java Saxon 9HE XML parser passed..." 0044 0045 fi 0046 0047 if [ ! -f /opt/krazy/bin/krazy2all ] ; then 0048 0049 echo "Krazy Static analyzer is not installed in /opt/krazy." 0050 echo "Please install Krazy from https://github.com/Krazy-collection/krazy" 0051 echo "Aborted..." 0052 exit -1 0053 0054 else 0055 0056 echo "Check Krazy static analyzer passed..." 0057 0058 fi 0059 0060 export PATH=$PATH:/opt/krazy/bin 0061 0062 ORIG_WD="`pwd`" 0063 REPORT_DIR="${ORIG_WD}/report.krazy" 0064 WEBSITE_DIR="${ORIG_WD}/site" 0065 0066 # Get active git branches to create report description string 0067 TITLE="digiKam-$(parseGitBranch)$(parseGitHash)" 0068 echo "Krazy Static Analyzer task name: $TITLE" 0069 0070 rm -fr $REPORT_DIR 0071 rm -fr $WEBSITE_DIR 0072 0073 # Compute static analyzer output as XML 0074 TITLE_EXT=$TITLE+" 0075 This is the static analyzis processed with Krazy." 0076 0077 krazy2all --export xml \ 0078 --title $TITLE \ 0079 --no-brief \ 0080 --strict all \ 0081 --priority all \ 0082 --verbose \ 0083 --exclude qclasses,license \ 0084 --exclude-types qml,python,qdoc,perl \ 0085 --topdir ../../ \ 0086 --config ../../.krazy \ 0087 --outfile ./report.krazy.xml \ 0088 || true 0089 0090 # Clean up XML file 0091 0092 sed -i "s/repo-rev value=\"unknown\"/repo-rev value=\"$(parseGitBranch)$(parseGitHash)\"/g" ./report.krazy.xml 0093 0094 DROP_PATH=$(echo $ORIG_WD | rev | cut -d'/' -f3- | rev | sed 's_/_\\/_g') 0095 sed -i "s/$DROP_PATH//g" ./report.krazy.xml 0096 0097 mkdir -p $REPORT_DIR 0098 0099 # Process XML file to generate HTML 0100 0101 java -jar /opt/saxon/saxon9he.jar \ 0102 -o:$REPORT_DIR/index.html \ 0103 -im:krazy2ebn \ 0104 ./report.krazy.xml \ 0105 ./krazy/krazy-main.xsl \ 0106 module=graphics \ 0107 component= \ 0108 submodule=digikam 0109 0110 cp ./krazy/style.css $REPORT_DIR/ 0111 0112 if [[ $1 != "--nowebupdate" ]] ; then 0113 0114 # update www.digikam.org report section. 0115 updateReportToWebsite "krazy" $REPORT_DIR $TITLE $(parseGitBranch) 0116 0117 fi 0118 0119 cd $ORIG_DIR