MCPcopy Index your code
hub / github.com/Tencent/CodeAnalysis / run_cpplint_on_file

Method run_cpplint_on_file

client/tool/cpplint.py:117–142  ·  view source on GitHub ↗

扫描单个文件

(self, file_path, cmd_args, regex_client, source_dir, rules)

Source from the content-addressed store, hash-verified

115 return issues
116
117 def run_cpplint_on_file(self, file_path, cmd_args, regex_client, source_dir, rules):
118 """扫描单个文件"""
119 # 先置空,以免上一个影响
120 self.cmd_output = []
121 cmd = cmd_args + ["\"%s\"" % file_path]
122 logger.info("scan file: %s" % file_path)
123 # cpplint的error信息通过stderr通道输出,结果统计信息通过stdout通道输出,可以只解析stderr结果
124 subProC = SubProcController(cmd, stderr_line_callback=self.__collect_result_callback__)
125 try:
126 subProC.wait(timeout=300) # 设置cpplint分析单个文件超时为5分钟,避免cpplint卡死的情况
127 except Exception as err:
128 if "SubProcControllerTimeout" in str(err):
129 logger.error(
130 "timeout when run on file(%s): %s. Kill this process(%s)..." % (file_path, str(err), subProC.pid)
131 )
132 ProcMgr().kill_proc_famliy(subProC.pid)
133 else:
134 logger.error("error on file(%s): %s" % (file_path, err))
135 raise
136
137 # 解析cpplint原始结果
138 scan_result = ResultMgr().parse_result(regex_client, self.cmd_output)
139
140 # 转换成codedog最终结果格式
141 file_issues = ResultMgr().format_result(source_dir, scan_result, rules)
142 return file_issues
143
144
145class ThreadRunner(object):

Callers 2

run_cpplint_on_filesMethod · 0.95

Calls 7

ProcMgrClass · 0.90
ResultMgrClass · 0.85
errorMethod · 0.80
kill_proc_famliyMethod · 0.80
parse_resultMethod · 0.80
infoMethod · 0.45
format_resultMethod · 0.45

Tested by

no test coverage detected