szaszm commented on a change in pull request #1231:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1231#discussion_r778848401
##########
File path: thirdparty/google-styleguide/run_linter.py
##########
@@ -9,18 +12,48 @@
list_of_files = list()
for include_path in args.includePaths:
- for (dir_path, dir_names, file_names) in os.walk(include_path):
- for file_name in file_names:
- if (".h" in file_name) or (".cpp" in file_name):
- list_of_files += [os.path.join(dir_path, file_name)]
+ for (dir_path, dir_names, file_names) in os.walk(include_path):
+ for file_name in file_names:
+ if (".h" in file_name) or (".cpp" in file_name):
+ list_of_files += [os.path.join(dir_path, file_name)]
script_dir = os.path.dirname(os.path.realpath(__file__))
repository_path = os.path.abspath(os.path.join(script_dir, os.pardir,
os.pardir))
arg_list = list()
arg_list.append("--linelength=200")
arg_list.append("--repository=" + repository_path)
-if (args.quiet):
- arg_list.append("--quiet")
+if args.quiet:
+ arg_list.append("--quiet")
-cpplint.main(arg_list + list_of_files)
+
+def cpplint_main_wrapper(file_list):
+ try:
+ cpplint.main(arg_list + file_list)
+ return 0
+ except SystemExit as err:
+ return err.code
+
+
+if __name__ == '__main__':
+ # break up list_of_files to ~equal chunks
+ chunk_num = multiprocessing.cpu_count()
+ chunk_size = math.ceil(len(list_of_files) / chunk_num)
+ chunks = []
+ chunk_begin = 0
+ chunk_end = chunk_size
+ for chunk_cnt in range(chunk_num):
+ chunks.append(list_of_files[chunk_begin:chunk_end])
+ chunk_begin += chunk_size
+ if chunk_begin >= len(list_of_files):
+ break
+ chunk_end += chunk_size
+ if chunk_end > len(list_of_files):
+ chunk_end = len(list_of_files)
Review comment:
Would this mean that in order to run the linter, we all need to install
this package system-wide? If so, it may not be worth the extra effort required
to simplify this code. One solution could be using a virtualenv in the build
directory, but this also sounds more complex than maintaining 10 extra lines of
code. What do you think?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]