[PATCH] D140772: [clang-tidy] Fix minor bug in add_new_check.py

Carlos Galvez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 30 00:54:40 PST 2022


carlosgalvezp accepted this revision.
carlosgalvezp added a comment.
This revision is now accepted and ready to land.

LGTM, I have a suggestion for further improvement.



================
Comment at: clang-tools-extra/clang-tidy/add_new_check.py:324-328
   doc_files = []
-  for subdir in list(filter(lambda s: not s.endswith('.rst') and not s.endswith('.py'),
-                     os.listdir(docs_dir))):
+  for subdir in list(filter(os.path.isdir, os.listdir(docs_dir))):
     for file in filter(lambda s: s.endswith('.rst'), os.listdir(os.path.join(docs_dir, subdir))):
       doc_files.append([subdir, file])
   doc_files.sort()
----------------
It feels this whole code could be made much simpler, readable and safer by just doing:

  doc_files = glob.glob(os.path.join(docs_dir, "**", "*.rst"), recursive=True)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140772/new/

https://reviews.llvm.org/D140772



More information about the cfe-commits mailing list