Skip to content

Commit 84f3f24

Browse files
authored
Merge pull request #642 from bensonhome/main
🎨cpplint、codecoutn适配QuickScan场景
2 parents c39c3e8 + 0b2e08a commit 84f3f24

3 files changed

Lines changed: 13 additions & 10 deletions

File tree

client/task/puppytask.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ def run(self):
4040
time_format = "%Y-%m-%d %H:%M:%S"
4141
task_start_time = time.strftime(time_format,time.localtime(time.time()))
4242

43-
# 初始化task_params
44-
task_params = None
4543
try:
4644
if settings.DEBUG:
4745
level = logging.DEBUG
@@ -83,9 +81,11 @@ def run(self):
8381
if response.message:
8482
logger.warning('task messsage: %s', response.message)
8583
if response.result:
86-
# 不是敏感工具,才打印出堆栈(避免泄露工具信息)
84+
with open(request_file, "r") as rf:
85+
task_request = json.load(rf)
86+
task_params = task_request.get("task_params")
8787
if not ToolDisplay.is_sensitive_tool(task_params):
88-
logger.warning('task result: %s', response.result)
88+
logger.warning('task result: \n%s', response.result)
8989

9090
# 记录结束时间
9191
task_end_time = time.strftime(time_format,time.localtime(time.time()))

client/tool/codecount.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,6 @@ def analyze(self, params):
476476
# 1. 基本信息读取
477477
# 需要server 提供:scm路径、scm版本号区间、黑白名单路径配置、业务模块配置信息
478478
work_dir = os.getcwd()
479-
scm_client = SCMMgr(params).get_scm_client()
480479
last_dir = os.path.join(work_dir, "last_files")
481480
curr_dir = os.path.join(work_dir, "curr_files")
482481
incr_scan = params.get("incr_scan", False)
@@ -508,6 +507,7 @@ def analyze(self, params):
508507
if incr_scan:
509508
file_change_type = {}
510509
get_file_time = time.time()
510+
scm_client = SCMMgr(params).get_scm_client()
511511
self.create_diff_files(scm_client, params, file_change_type, curr_dir, last_dir)
512512
get_file_time_end = time.time()
513513
logger.info("Get file time by scm client: %s" % (get_file_time_end - get_file_time))

client/tool/cpplint.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,10 @@ def __prepare_cpplint_args(self, source_dir, rules, linelength, project_name):
213213
if file_extensions:
214214
cmd_args.append("--extensions=" + file_extensions)
215215
logger.info("扫描文件为 %s" % file_extensions)
216-
if project_name.find(".git") != -1:
217-
project_name = project_name.replace(".git", "")
218-
cmd_args.append("--root=%s" % project_name)
216+
if project_name:
217+
if project_name.find(".git") != -1:
218+
project_name = project_name.replace(".git", "")
219+
cmd_args.append("--root=%s" % project_name)
219220
if rules:
220221
filter_arg = "--filter=-,+" + ",+".join(rules)
221222
cmd_args.append(filter_arg)
@@ -288,13 +289,15 @@ def analyze(self, params):
288289
reg_client = re.compile(r"^(.+?):(\d+):\s+(.+?)\s+\[([\S]+)\]\s+\[(\d+)\]$")
289290
max_linelength = self.__get_linelength_param(params)
290291
# 获取项目名称
291-
if "git" == params.get("scm_type"): # git仓库
292+
project_name = None
293+
scm_type = params.get("scm_type")
294+
if "git" == scm_type: # git仓库
292295
project_name = params.get("scm_url")
293296
if project_name.find("#") != -1:
294297
project_name = project_name.split("#")[0]
295298
project_name = project_name.split("/")[-1]
296299
project_name = project_name.replace(".git", "")
297-
else: # svn项目
300+
elif "svn" == scm_type: # svn项目
298301
project_name = params.get("scm_url").split("/")[-1].split("_proj")[0]
299302
cmd_args = self.__prepare_cpplint_args(source_dir, rules, max_linelength, project_name)
300303

0 commit comments

Comments
 (0)