<commit_before>#!/bin/sh

H="~/dev/irods/E-iRODS/e-irods/iRODS/"

~/bin/cppcheck -j 8 -f -I/usr/include -I$H/nt/include -I$H/lib/md5/include -I$H/lib/rbudp/include -I$H/lib/api/include -I$H/lib/core/include -I$H/lib/isio/include -I$H/server/re/include -I$H/server/drivers/include -I$H/server/core/include -I$H/server/icat/include -i nt/ -i modules/msoDrivers/ -i modules/webservices/ -i boost_irods/ -i clients/icommands/rulegen/ -i modules . | grep error<commit_msg>[#763] made run cppcheck much smarter, detects os, cpucount, cppcheck binary<commit_after>#!/bin/bash -e

# preflight
CPPCHECK=`which cppcheck`
if [[ "$?" != "0" || `echo $CPPCHECK | awk '{print $1}'` == "no" ]] ; then
    echo "cppcheck is required on this machine"
    if [ "$DETECTEDOS" == "MacOSX" ] ; then
        echo "try:"
        echo "  sudo apt-get install cppcheck"
    fi
    echo ""
    exit 1
fi

# find proper directory
DETECTEDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DETECTEDDIR
H=`pwd`
echo "Detected Directory [$H]"

# detect operating system
DETECTEDOS=`$DETECTEDDIR/../packaging/find_os.sh`
echo "Detected OS [$DETECTEDOS]"


# find number of cpus
if [ "$DETECTEDOS" == "MacOSX" ] ; then
    DETECTEDCPUCOUNT=`sysctl -n hw.ncpu`
elif [ "$DETECTEDOS" == "Solaris" ] ; then
    DETECTEDCPUCOUNT=`/usr/sbin/psrinfo -p`
else
    DETECTEDCPUCOUNT=`cat /proc/cpuinfo | grep processor | wc -l`
fi
if [ "$DETECTEDCPUCOUNT" \< "2" ] ; then
    DETECTEDCPUCOUNT=1
fi
CPUCOUNT=$(( $DETECTEDCPUCOUNT + 3 ))
MAKEJCMD="make -j $CPUCOUNT"
echo "-----------------------------------"
echo "Detected CPUs:          $DETECTEDCPUCOUNT"
echo "Running cppcheck with:  $CPUCOUNT"
echo "-----------------------------------"
sleep 1


# run cppcheck
cppcheck -j $CPUCOUNT -f -I/usr/include -I$H/nt/include -I$H/lib/md5/include -I$H/lib/rbudp/include -I$H/lib/api/include -I$H/lib/core/include -I$H/lib/isio/include -I$H/server/re/include -I$H/server/drivers/include -I$H/server/core/include -I$H/server/icat/include -i nt/ -i modules/msoDrivers/ -i modules/webservices/ -i boost_irods/ -i clients/icommands/rulegen/ -i modules . | grep error | grep -v "error\.c"
{'fraction_non_alphanumeric': 0.20093240093240095, 'fraction_numerical': 0.006526806526806527, 'mean_word_length': 3.0643939393939394, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1962664', 'n_tokens_mistral': 895, 'n_tokens_neox': 841, 'n_words': 184}