DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] devtools: add script to check for non inclusive naming
@ 2023-03-31 20:08 Stephen Hemminger
  0 siblings, 0 replies; 36+ messages in thread
From: Stephen Hemminger @ 2023-03-31 20:08 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

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).

Examples:
 $ ./devtools/check-naming.sh -q
Total files: 37 errors, 90 warnings, 1 suggestions

 $ ./devtools/check-naming.sh -q -l
Total lines: 121 errors, 255 warnings, 1 suggestions

Uses the word lists from Inclusive Naming Initiative
see https://inclusivenaming.org/word-lists/

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 devtools/check-naming.sh  | 89 +++++++++++++++++++++++++++++++++++++++
 devtools/naming/tier1.txt |  8 ++++
 devtools/naming/tier2.txt |  1 +
 devtools/naming/tier3.txt |  3 ++
 4 files changed, 101 insertions(+)
 create mode 100755 devtools/check-naming.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/devtools/check-naming.sh b/devtools/check-naming.sh
new file mode 100755
index 000000000000..2a25eaa2eef9
--- /dev/null
+++ b/devtools/check-naming.sh
@@ -0,0 +1,89 @@
+#! /bin/bash
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Produce a list of files with non-inclusive naming
+
+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[@]} > $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
+
+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..46532f2b234b
--- /dev/null
+++ b/devtools/naming/tier1.txt
@@ -0,0 +1,8 @@
+abort
+blackhat
+whitehat
+cipple
+master
+slave
+whitelist
+blacklist
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..0f9586ff5bac
--- /dev/null
+++ b/devtools/naming/tier3.txt
@@ -0,0 +1,3 @@
+man.in.the.middle
+segregate
+tribe
-- 
2.39.2


^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2024-02-06 10:05 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <0230331200824.195294-1-stephen@networkplumber.org>
2023-04-05 23:29 ` [PATCH v3] devtools: add script to check for non inclusive naming Stephen Hemminger
2023-08-17 14:58   ` Stephen Hemminger
2023-04-19 15:00 ` [PATCH] " Stephen Hemminger
2023-10-30 21:33 ` [PATCH v4] " Stephen Hemminger
2023-10-30 22:17 ` [PATCH v5] " Stephen Hemminger
2023-10-30 22:22 ` [PATCH v6] " Stephen Hemminger
2023-10-30 22:32 ` [PATCH v7] " Stephen Hemminger
2023-11-02 20:57   ` [PATCH v8] " Stephen Hemminger
2024-02-05 17:43 ` [PATCH v9 00/23] Use inclusive naming in DPDK Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 01/23] devtools: add script to check for non inclusive naming Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 02/23] test: replace use of term segregate Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 03/23] examples/ptp: replace terms master and slave Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 04/23] test: remove use of word master in test_red Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 05/23] mbuf: replace term sanity check Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 06/23] eal: replace use of sanity check in comments and messages Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 07/23] test: replace use word sanity Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 08/23] examples: remove term sanity Stephen Hemminger
2024-02-06 10:05     ` [EXT] " Akhil Goyal
2024-02-05 17:43   ` [PATCH v9 09/23] lib: replace use of sanity check in comments and messages Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 10/23] doc/eventdev_pipeline: remove sanity Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 11/23] net/ring: replace use of sanity Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 12/23] net/fm10k, net/ixgbe: remove word sanity Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 13/23] net/mlx[45]: " Stephen Hemminger
2024-02-05 19:22     ` Dariusz Sosnowski
2024-02-05 17:43   ` [PATCH v9 14/23] net/sfc: remove term "sanity check" Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 15/23] net/ark: replace use of term sanity Stephen Hemminger
2024-02-05 21:12     ` Ed Czeck
2024-02-05 17:43   ` [PATCH v9 16/23] net/bnxt: " Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 17/23] net/bnx2x: remove reference to sanity Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 18/23] cnxk: replace term sanity Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 19/23] event/opdl: remove " Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 20/23] net/txgbe: replace " Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 21/23] net/cxgbe: remove use of " Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 22/23] crypto/bcmfs: replace term sanity check Stephen Hemminger
2024-02-05 17:43   ` [PATCH v9 23/23] drivers: remove use of " Stephen Hemminger
2023-03-31 20:08 [PATCH] devtools: add script to check for non inclusive naming Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).