Skip to content

Commit

Permalink
Merge pull request #642 from bensonhome/main
Browse files Browse the repository at this point in the history
🎨cpplint、codecoutn适配QuickScan场景
  • Loading branch information
Lingghh authored Sep 28, 2022
2 parents c39c3e8 + 0b2e08a commit 84f3f24
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
8 changes: 4 additions & 4 deletions client/task/puppytask.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ def run(self):
time_format = "%Y-%m-%d %H:%M:%S"
task_start_time = time.strftime(time_format,time.localtime(time.time()))

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

# 记录结束时间
task_end_time = time.strftime(time_format,time.localtime(time.time()))
Expand Down
2 changes: 1 addition & 1 deletion client/tool/codecount.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,6 @@ def analyze(self, params):
# 1. 基本信息读取
# 需要server 提供:scm路径、scm版本号区间、黑白名单路径配置、业务模块配置信息
work_dir = os.getcwd()
scm_client = SCMMgr(params).get_scm_client()
last_dir = os.path.join(work_dir, "last_files")
curr_dir = os.path.join(work_dir, "curr_files")
incr_scan = params.get("incr_scan", False)
Expand Down Expand Up @@ -508,6 +507,7 @@ def analyze(self, params):
if incr_scan:
file_change_type = {}
get_file_time = time.time()
scm_client = SCMMgr(params).get_scm_client()
self.create_diff_files(scm_client, params, file_change_type, curr_dir, last_dir)
get_file_time_end = time.time()
logger.info("Get file time by scm client: %s" % (get_file_time_end - get_file_time))
Expand Down
13 changes: 8 additions & 5 deletions client/tool/cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,10 @@ def __prepare_cpplint_args(self, source_dir, rules, linelength, project_name):
if file_extensions:
cmd_args.append("--extensions=" + file_extensions)
logger.info("扫描文件为 %s" % file_extensions)
if project_name.find(".git") != -1:
project_name = project_name.replace(".git", "")
cmd_args.append("--root=%s" % project_name)
if project_name:
if project_name.find(".git") != -1:
project_name = project_name.replace(".git", "")
cmd_args.append("--root=%s" % project_name)
if rules:
filter_arg = "--filter=-,+" + ",+".join(rules)
cmd_args.append(filter_arg)
Expand Down Expand Up @@ -288,13 +289,15 @@ def analyze(self, params):
reg_client = re.compile(r"^(.+?):(\d+):\s+(.+?)\s+\[([\S]+)\]\s+\[(\d+)\]$")
max_linelength = self.__get_linelength_param(params)
# 获取项目名称
if "git" == params.get("scm_type"): # git仓库
project_name = None
scm_type = params.get("scm_type")
if "git" == scm_type: # git仓库
project_name = params.get("scm_url")
if project_name.find("#") != -1:
project_name = project_name.split("#")[0]
project_name = project_name.split("/")[-1]
project_name = project_name.replace(".git", "")
else: # svn项目
elif "svn" == scm_type: # svn项目
project_name = params.get("scm_url").split("/")[-1].split("_proj")[0]
cmd_args = self.__prepare_cpplint_args(source_dir, rules, max_linelength, project_name)

Expand Down

0 comments on commit 84f3f24

Please sign in to comment.