#!/usr/bin/env bash # # $Id: fmd-lint,v 1.4 2025/04/15 14:39:06 snw Exp $ # Run cppcheck on FreeM # # # Author: Serena Willis # Copyright (C) 2025 Coherent Logic Development LLC # # # This file is part of FreeM. # # FreeM is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # FreeM is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero Public License for more details. # # You should have received a copy of the GNU Affero Public License # along with FreeM. If not, see . # # $Log: fmd-lint,v $ # Revision 1.4 2025/04/15 14:39:06 snw # Further improvements to logging # # Revision 1.3 2025/04/10 01:24:38 snw # Remove C++ style comments # # Revision 1.2 2025/04/09 19:52:02 snw # Eliminate as many warnings as possible while building with -Wall # # Revision 1.1 2025/04/09 15:47:36 snw # Add fmd lint command # # # SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC # SPDX-License-Identifier: AGPL-3.0-or-later # PGM=$(basename $0) SCRIPT_DIR=$(dirname "$0") source "${SCRIPT_DIR}/_fmd_common.bash" function usage() { echo echo "Runs static code analysis on FreeM code" echo echo "usage: " echo echo " fmd lint" echo exit 0 } if [[ $1 == "help" ]] then usage fi if [[ $# == 0 ]] then echo "lint: must be run from 'fmd lint'" exit 1 fi FMD=$1 REPORTFILE="freem_lint_${_fmd_freem_version}.log" echo -n "${PGM}: linting src/*.[ch] to ${REPORTFILE} (this may take awhile)... " cppcheck --language=c --std=c99 --template=gcc --suppress=missingIncludeSystem --enable=all --check-level=exhaustive --quiet --force --check-level=exhaustive --enable=all --inconclusive src/*.[ch] &> "${REPORTFILE}" if [[ $? == 0 ]] then echo "[OK]" else echo "[FAIL]" fi