qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Thomas Huth" <thuth@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH v2 5/7] tests/style: check for commonly doubled up words
Date: Mon,  4 Jul 2022 16:23:01 +0100	[thread overview]
Message-ID: <20220704152303.760983-6-berrange@redhat.com> (raw)
In-Reply-To: <20220704152303.760983-1-berrange@redhat.com>

This style check looks for cases where the words

  the then in an on if is it but for or at and do to

are repeated in a sentence. It doesn't use the simple regex match logic
because it needs to match repeats across lines, so has a custom crafted
rule.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tests/style-excludes.mak | 12 ++++++++++++
 tests/style.mak          | 24 ++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/tests/style-excludes.mak b/tests/style-excludes.mak
index 32c0e9c328..931dd03a64 100644
--- a/tests/style-excludes.mak
+++ b/tests/style-excludes.mak
@@ -2,3 +2,15 @@
 #
 # Filenames that should be excluded from specific
 # style checks performed by style.mak
+
+exclude_file_name_regexp--sc_prohibit_doubled_word = \
+	disas/sparc\.c \
+	hw/char/terminal3270\.c \
+	include/crypto/afsplit\.h \
+	qemu-options\.hx \
+	scripts/checkpatch\.pl \
+	target/s390x/tcg/insn-data\.def \
+	pc-bios/slof\.bin \
+	tests/qemu-iotests/142(\.out)? \
+	tests/qtest/arm-cpu-features\.c \
+	ui/cursor\.c
diff --git a/tests/style.mak b/tests/style.mak
index ae658395c9..4056bde619 100644
--- a/tests/style.mak
+++ b/tests/style.mak
@@ -28,3 +28,27 @@ sc_int_assign_bool:
 	@prohibit='\<int\>.*= *(true|false)\b' \
 	halt='use bool type for boolean values' \
 	$(_sc_search_regexp)
+
+prohibit_doubled_words_ = \
+    the then in an on if is it but for or at and do to can
+# expand the regex before running the check to avoid using expensive captures
+prohibit_doubled_word_expanded_ = \
+    $(join $(prohibit_doubled_words_),$(addprefix \s+,$(prohibit_doubled_words_)))
+prohibit_doubled_word_RE_ ?= \
+    /\b(?:$(subst $(_sp),|,$(prohibit_doubled_word_expanded_)))\b/gims
+prohibit_doubled_word_ =						\
+    -e 'while ($(prohibit_doubled_word_RE_))'				\
+    $(perl_filename_lineno_text_)
+
+# Define this to a regular expression that matches
+# any filename:dd:match lines you want to ignore.
+# The default is to ignore no matches.
+ignore_doubled_word_match_RE_ ?= ^$$
+
+sc_prohibit_doubled_word:
+	@$(VC_LIST_EXCEPT)						\
+	  | xargs perl -n -0777 $(prohibit_doubled_word_)		\
+	  | $(GREP) -vE '$(ignore_doubled_word_match_RE_)'		\
+	  | $(GREP) .							\
+	  && { echo '$(ME): doubled words' 1>&2; exit 1; }		\
+	  || :
-- 
2.36.1



  parent reply	other threads:[~2022-07-04 15:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-04 15:22 [PATCH v2 0/7] tests: introduce a tree-wide code style checking facility Daniel P. Berrangé
2022-07-04 15:22 ` [PATCH v2 1/7] tests: introduce tree-wide code style checking Daniel P. Berrangé
2022-07-04 15:46   ` Peter Maydell
2022-07-04 16:12     ` Daniel P. Berrangé
2022-07-07 16:43     ` Daniel P. Berrangé
2022-07-04 15:22 ` [PATCH v2 2/7] misc: fix mixups of bool constants with int variables Daniel P. Berrangé
2022-07-04 15:38   ` Peter Maydell
2022-07-04 15:22 ` [PATCH v2 3/7] tests/style: check for " Daniel P. Berrangé
2022-07-04 15:23 ` [PATCH v2 4/7] misc: fix commonly doubled up words Daniel P. Berrangé
2022-07-04 15:52   ` Peter Maydell
2022-07-07 12:30     ` Daniel P. Berrangé
2022-07-07 12:35       ` Peter Maydell
2022-07-04 15:23 ` Daniel P. Berrangé [this message]
2022-07-04 15:23 ` [PATCH v2 6/7] misc: ensure qemu/osdep.h is included in all .c files Daniel P. Berrangé
2022-07-04 15:38   ` Warner Losh
2022-07-04 15:46     ` Daniel P. Berrangé
2022-07-04 16:08       ` Warner Losh
2022-07-04 15:23 ` [PATCH v2 7/7] tests/style: check " Daniel P. Berrangé
2022-07-04 15:47   ` Peter Maydell
2022-07-04 15:50     ` Daniel P. Berrangé
2022-07-04 15:55       ` Peter Maydell
2022-07-04 16:15         ` Daniel P. Berrangé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220704152303.760983-6-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=f4bug@amsat.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).