From patchwork Mon Apr 3 14:47:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 125725 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1FC11428BF; Mon, 3 Apr 2023 16:47:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AD11C40ED7; Mon, 3 Apr 2023 16:47:12 +0200 (CEST) Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by mails.dpdk.org (Postfix) with ESMTP id 7C67040A7E for ; Mon, 3 Apr 2023 16:47:11 +0200 (CEST) Received: by mail-pj1-f52.google.com with SMTP id h12-20020a17090aea8c00b0023d1311fab3so30801905pjz.1 for ; Mon, 03 Apr 2023 07:47:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; t=1680533230; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wjYjole4Z7AfqmXg71jBrQ/stpuHInnSPm16oG/XMKU=; b=hgwzw+60uZUgDzk/pOoXZnG5JzyhcUAp7QWLgxeTMYHYuMoc7wcR5xFYVWx4eDoy3L A9NEc3Og/bPBLszryMnAUHHCyfwfK+NgkdeSM9xtTB/4XekqzOIEF72f7x69dsJCSlJ/ 1G15unoASWn8X3ul+Xu0VogRDENCTJnNMCh9hH0VtUrSjK1QNKoUq7fbEwt68IVQQ7+n z62J8uhfcoB7SUEb0fO35UI8bSSV72Cw4hTHAAR4MHYXbzVFG5VALvakRgU6jChW1mtk NuvHxx3hF7TxybtTQ2KBe4SeovcM99PZXpgeUrWmDvV/AAM8zq9bZbKatMe9IaI2NWKi gFvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680533230; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wjYjole4Z7AfqmXg71jBrQ/stpuHInnSPm16oG/XMKU=; b=1SpNuFI1Jd6wHeHwPlQqb7R4mxRInW5QR1LPQ0JoUYPwcINHGNyYBOWwIMgwujsCkQ +Si0tY4GvbP8VfETmZf5RYKUxmMxHxL+6dmIlJz1UECoPYrLs5LEJFXx/Hq8tMvbEdHN nJreqJ3DQ35MKz24RUWAXhD5iVlIAC8uGxCTBrvFd88JNovBANHrZWu0Fpwi56j+6GmN 0EovH9t42crvUz6/l/H1cKG5Ng5mTJFsVNWWIat9c9tuP5X9fXWgrEb1uvbnjzAR/o5w XjnQGKlZsj7rvP0n95TMa1bItn1SGIlTDP3YyXm7lp6N/pgw+V84Zw/jsjF2yNqRFDMt C5OA== X-Gm-Message-State: AAQBX9d8MStJiUAwJgvIUVZ2PY3/M1F1ss/5PrieMD1CQjEnnw81SR2g OUQxetv3QoHjJJGDcKxyJvfW+VN/08vmXE+LgZl9JXRA X-Google-Smtp-Source: AKy350ZW3ddh8aTCmt37DvcNIRMa1sgFXTVi0snTlywnBePagF+28sEFpqV3LUcFBAy1WCJkf59Jog== X-Received: by 2002:a17:903:2948:b0:19c:f232:21ca with SMTP id li8-20020a170903294800b0019cf23221camr34761637plb.3.1680533230048; Mon, 03 Apr 2023 07:47:10 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id f3-20020a170902e98300b0019cc3d0e1basm6673100plb.112.2023.04.03.07.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 07:47:09 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v2] devtools: add script to check for non inclusive naming Date: Mon, 3 Apr 2023 07:47:07 -0700 Message-Id: <20230403144707.8413-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230331200824.195294-1-stephen@networkplumber.org> References: <20230331200824.195294-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Shell script to find use of words that not be used. By default it prints matches. The -q (quiet) option is used to just count. There is also -l option which lists lines matching (like grep -l). Uses the word lists from Inclusive Naming Initiative see https://inclusivenaming.org/word-lists/ Examples: $ ./devtools/check-naming-policy.sh -q Total files: 37 errors, 90 warnings, 2 suggestions $ ./devtools/check-naming-policy.sh -q -l lib/eal Total lines: 32 errors, 8 warnings, 0 suggestions Add MAINTAINERS file entry for the new tool and resort the list files back into to alphabetic order Signed-off-by: Stephen Hemminger --- v2 - fix typo in words - add subtree (pathspec) option - update maintainers file (and fix alphabetic order) MAINTAINERS | 8 ++- devtools/check-naming-policy.sh | 107 ++++++++++++++++++++++++++++++++ devtools/naming/tier1.txt | 8 +++ devtools/naming/tier2.txt | 1 + devtools/naming/tier3.txt | 4 ++ 5 files changed, 125 insertions(+), 3 deletions(-) create mode 100755 devtools/check-naming-policy.sh create mode 100644 devtools/naming/tier1.txt create mode 100644 devtools/naming/tier2.txt create mode 100644 devtools/naming/tier3.txt diff --git a/MAINTAINERS b/MAINTAINERS index 8df23e50999f..b5881113ba85 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -83,26 +83,28 @@ Developers and Maintainers Tools M: Thomas Monjalon F: MAINTAINERS F: devtools/build-dict.sh -F: devtools/check-abi.sh F: devtools/check-abi-version.sh +F: devtools/check-abi.sh F: devtools/check-doc-vs-code.sh F: devtools/check-dup-includes.sh -F: devtools/check-maintainers.sh F: devtools/check-forbidden-tokens.awk F: devtools/check-git-log.sh +F: devtools/check-maintainers.sh +F: devtools/check-naming-policy.sh F: devtools/check-spdx-tag.sh F: devtools/check-symbol-change.sh F: devtools/check-symbol-maps.sh F: devtools/checkpatches.sh F: devtools/get-maintainer.sh F: devtools/git-log-fixes.sh +F: devtools/libabigail.abignore F: devtools/load-devel-config +F: devtools/naming/ F: devtools/parse-flow-support.sh F: devtools/process-iwyu.py F: devtools/update-abi.sh F: devtools/update-patches.py F: devtools/update_version_map_abi.py -F: devtools/libabigail.abignore F: devtools/words-case.txt F: license/ F: .editorconfig diff --git a/devtools/check-naming-policy.sh b/devtools/check-naming-policy.sh new file mode 100755 index 000000000000..90347b415652 --- /dev/null +++ b/devtools/check-naming-policy.sh @@ -0,0 +1,107 @@ +#! /bin/bash +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2023 Stephen Hemminger +# +# This script scans the source tree and creates list of files +# containing words that are recommended to bavoide by the +# Inclusive Naming Initiative. +# See: https://inclusivenaming.org/word-lists/ +# +# The options are: +# -q = quiet mode, produces summary count only +# -l = show lines instead of files with recommendations +# -v = verbose, show a header between each tier +# +# Default is to scan all of DPDK source and documentation. +# Optional pathspec can be used to limit specific tree. +# +# Example: +# check-naming-policy.sh -q doc/* +# + +errors=0 +warnings=0 +suggestions=0 +quiet=false +veborse=false +lines='-l' + +print_usage () { + echo "usage: $(basename $0) [-l] [-q] [-v] []" + exit 1 +} + +# Locate word list files +selfdir=$(dirname $(readlink -f $0)) +words=$selfdir/naming + +# These give false positives +skipfiles=( ':^devtools/naming/' \ + ':^doc/guides/rel_notes/' \ + ':^doc/guides/contributing/coding_style.rst' \ + ':^doc/guides/prog_guide/glossary.rst' \ +) +# These are obsolete +skipfiles+=( \ + ':^drivers/net/liquidio/' \ + ':^drivers/net/bnx2x/' \ + ':^lib/table/' \ + ':^lib/port/' \ + ':^lib/pipeline/' \ + ':^examples/pipeline/' \ +) + +# +# check_wordlist wordfile description +check_wordlist() { + local list=$words/$1 + local description=$2 + + git grep -i $lines -f $list -- ${skipfiles[@]} $pathspec > $tmpfile + count=$(wc -l < $tmpfile) + if ! $quiet; then + if [ $count -gt 0 ]; then + if $verbose; then + echo $description + echo $description | tr '[:print:]' '-' + fi + cat $tmpfile + echo + fi + fi + return $count +} + +while getopts lqvh ARG ; do + case $ARG in + l ) lines= ;; + q ) quiet=true ;; + v ) verbose=true ;; + h ) print_usage ; exit 0 ;; + ? ) print_usage ; exit 1 ;; + esac +done +shift $(($OPTIND - 1)) + +tmpfile=$(mktemp -t dpdk.checknames.XXXXXX) +trap 'rm -f -- "$tmpfile"' INT TERM HUP EXIT + +pathspec=$* + +check_wordlist tier1.txt "Tier 1: Replace immediately" +errors=$? + +check_wordlist tier2.txt "Tier 2: Strongly consider replacing" +warnings=$? + +check_wordlist tier3.txt "Tier 3: Recommend to replace" +suggestions=$? + +if [ -z "$lines" ] ; then + echo -n "Total lines: " +else + echo -n "Total files: " +fi + +echo $errors "errors," $warnings "warnings," $suggestions "suggestions" +exit $errors diff --git a/devtools/naming/tier1.txt b/devtools/naming/tier1.txt new file mode 100644 index 000000000000..a0e9b549c218 --- /dev/null +++ b/devtools/naming/tier1.txt @@ -0,0 +1,8 @@ +abort +blackhat +blacklist +cripple +master +slave +whitehat +whitelist diff --git a/devtools/naming/tier2.txt b/devtools/naming/tier2.txt new file mode 100644 index 000000000000..cd4280d1625c --- /dev/null +++ b/devtools/naming/tier2.txt @@ -0,0 +1 @@ +sanity diff --git a/devtools/naming/tier3.txt b/devtools/naming/tier3.txt new file mode 100644 index 000000000000..072f6468ea47 --- /dev/null +++ b/devtools/naming/tier3.txt @@ -0,0 +1,4 @@ +man.in.the.middle +segregate +segregation +tribe