[Concept,26/29] patman: Use single quotes for all quoted tokens in reviews

Message ID 20260501110040.1874719-27-sjg@u-boot.org
State New
Headers
Series patman: Review-flow improvements and shared helpers |

Commit Message

Simon Glass May 1, 2026, 11 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

The review prompt told the agent to quote string literals with double
quotes, which ends up looking out of place next to the surrounding
single-quoted identifiers (e.g. a review would say "handosff" next to
'my_var').

Use single quotes for everything except bare function names (which
keep their parentheses). Add a cleanup pass that rewrites short
double-quoted tokens to single quotes, leaving longer phrases (which
are more likely to be intentional quotations) alone.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/patman/review.py | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

-- 
2.43.0
  

Patch

diff --git a/tools/patman/review.py b/tools/patman/review.py
index eb8a3da63b3..054d18c6d80 100644
--- a/tools/patman/review.py
+++ b/tools/patman/review.py
@@ -401,9 +401,9 @@  Rules:
   possible to make the point. Avoid restating what the code does;
 - NEVER use backticks — this is plain-text email, not markdown.
   For functions, always use parentheses with no quotes: malloc() not
-  'malloc()' or `malloc`. For other identifiers (variables, struct
-  names, filenames) use single quotes: 'my_var' not "my_var", unless
-  it is a string literal (use double quotes for strings). Do not
+  'malloc()' or `malloc`. For all other quoting (identifiers,
+  filenames, string literals, misspelled words, etc.) use single
+  quotes: 'my_var' and 'handoff' not "my_var" or "handoff". Do not
   quote identifiers that are obviously code (e.g. CONFIG_FOO)
 - Never put a period directly after a code identifier — rephrase,
   omit the period, or use an em dash to start the next clause
@@ -505,9 +505,9 @@  VERDICT: changes_needed
 Rules:
 - NEVER use backticks — this is plain-text email, not markdown.
   For functions, always use parentheses with no quotes: malloc() not
-  'malloc()' or `malloc`. For other identifiers (variables, struct
-  names, filenames) use single quotes: 'my_var' not "my_var", unless
-  it is a string literal (use double quotes for strings). Do not
+  'malloc()' or `malloc`. For all other quoting (identifiers,
+  filenames, string literals, misspelled words, etc.) use single
+  quotes: 'my_var' and 'handoff' not "my_var" or "handoff". Do not
   quote identifiers that are obviously code (e.g. CONFIG_FOO)
 - Never put a period directly after a code identifier — rephrase,
   omit the period, or use an em dash to start the next clause
@@ -759,6 +759,14 @@  def cleanup_review_text(text):
     # Remove double quotes around function references: "func()" -> func()
     text = re.sub(r'"(\w+\(\))"', r'\1', text)
 
+    # Convert double-quoted short tokens to single quotes:
+    # "handoff" -> 'handoff'. Leave longer quoted text (full sentences
+    # or phrases) alone, since they may be intentional quotations.
+    text = re.sub(r'"([^"\n]{1,40})"',
+                  lambda m: f"'{m.group(1)}'"
+                  if ' ' not in m.group(1) else m.group(0),
+                  text)
+
     return text