#!/bin/sh1#***************************************************************************2# _ _ ____ _3# Project ___| | | | _ \| |4# / __| | | | |_) | |5# | (__| |_| | _ <| |___6# \___|\___/|_| \_\_____|7#8# Copyright (C) Dan Fandrich, <[email protected]>, Viktor Szakats, et al.9#10# This software is licensed as described in the file COPYING, which11# you should have received as part of this distribution. The terms12# are also available at https://curl.se/docs/copyright.html.13#14# You may opt to use, copy, modify, merge, publish, distribute and/or sell15# copies of the Software, and permit persons to whom the Software is16# furnished to do so, under the terms of the COPYING file.17#18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY19# KIND, either express or implied.20#21# SPDX-License-Identifier: curl22#23###########################################################################2425# https://cmake-format.readthedocs.io/en/latest/cmake-lint.html26# https://cmake-format.readthedocs.io/en/latest/lint-usage.html27# https://github.com/cheshirekow/cmake_format/blob/master/cmakelang/configuration.py2829# Run cmakelint on the curl source code. It will check all files given on the30# command-line, or else all relevant files in git, or if not in a git31# repository, all files starting in the tree rooted in the current directory.32#33# cmake-lint can be installed from PyPi with the command "python3 -m pip34# install cmakelang".35#36# The xargs invocation is portable, but does not preserve spaces in file names.37# If such a file is ever added, then this can be portably fixed by switching to38# "xargs -I{}" and appending {} to the end of the xargs arguments (which will39# call cmakelint once per file) or by using the GNU extension "xargs -d'\n'".4041set -eu4243cd "$(dirname "$0")"/..4445{46if [ -n "${1:-}" ]; then47for A in "$@"; do printf "%s\n" "$A"; done48elif git rev-parse --is-inside-work-tree >/dev/null 2>&1; then49git ls-files50else51# strip off the leading ./ to make the grep regexes work properly52find . -type f | sed 's@^\./@@'53fi54} | grep -E '(^CMake|/CMake|\.cmake$)' | grep -v -E '(\.h\.cmake|\.in|\.c)$' \55| xargs \56cmake-lint \57--suppress-decorations \58--disable \59--line-width 132 \60--tab-size 2 \61--use-tabchars false \62--disabled-codes C0113 \63--function-pattern 'curl_[0-9a-z_]+' \64--macro-pattern '(curl_[0-9a-z_]+|check_include_file_concat_curl)' \65--global-var-pattern '[A-Z][0-9A-Z_]+' \66--internal-var-pattern '_[a-z][0-9a-z_]+' \67--local-var-pattern '_[a-z][0-9a-z_]+' \68--private-var-pattern '_[0-9a-z_]+' \69--public-var-pattern '([A-Z][0-9A-Z_]+|[A-Z][A-Za-z0-9]+_FOUND|[a-z]+_SOURCES|prefix|exec_prefix|includedir|libdir|ssize_t|_FILE_OFFSET_BITS)' \70--argument-var-pattern '_[a-z][0-9a-z_]+' \71--keyword-pattern '[A-Z][0-9A-Z_]+' \72--max-conditionals-custom-parser 2 \73--min-statement-spacing 1 \74--max-statement-spacing 2 \75--max-returns 6 \76--max-branches 12 \77--max-arguments 5 \78--max-localvars 15 \79--max-statements 50 \80--818283