(self)
| 43 | self._result_path = result_path |
| 44 | |
| 45 | def run(self): |
| 46 | # self._thread_event.set() |
| 47 | try: |
| 48 | LogPrinter.info("Start to count code lines...") |
| 49 | # 删除旧结果文件 |
| 50 | if os.path.exists(self._result_path): |
| 51 | PathMgr().rmpath(self._result_path) |
| 52 | |
| 53 | # 修改任务参数,确保代码量统计到准确的diff文件范围 |
| 54 | InitParams.prepare_params_about_path_filters(self._task_params) |
| 55 | |
| 56 | # 加载codecount工具环境变量,即加载cloc命令需要的环境变量(cloc是通用工具,已经在之前拉取过,不需要重复拉取) |
| 57 | ToolLoader(tool_names=["codecount"], include_common=True).set_tool_env() |
| 58 | |
| 59 | code_line_data = CodeLineCount(self._task_params, self._work_dir).run() |
| 60 | |
| 61 | with open(self._result_path, "w") as wf: |
| 62 | json.dump(code_line_data, wf, indent=2) |
| 63 | except Exception as err: |
| 64 | LogPrinter.error("linecount raise error: %s" % err) |
| 65 | raise |
| 66 | finally: |
| 67 | self._thread_event.clear() |
| 68 | |
| 69 | |
| 70 | class LocalCountLine(object): |
nothing calls this directly
no test coverage detected