获取需要扫描的文件列表(相对路径)
(params, source_dir)
| 233 | |
| 234 | @staticmethod |
| 235 | def get_scan_paths(params, source_dir): |
| 236 | """获取需要扫描的文件列表(相对路径)""" |
| 237 | path_info_dict = {} |
| 238 | scan_rel_paths = [] |
| 239 | scan_paths = params.get("scan_path", []) |
| 240 | for path_info in scan_paths: |
| 241 | if path_info["type"] == "file": |
| 242 | path = path_info.get("path") |
| 243 | lines = path_info.get("lines", []) |
| 244 | if path: |
| 245 | scan_rel_paths.append(path) |
| 246 | path_info_dict[path] = lines # 指定文件时,可以指定改动的代码行,供过滤结果使用 |
| 247 | elif path_info["type"] == "dir": |
| 248 | exclude_regex = path_info.get("exclude_regex", []) |
| 249 | rel_paths = QuickScan.get_scan_files_in_dir(source_dir, path_info["path"], exclude_regex) |
| 250 | for path in rel_paths: |
| 251 | if path not in scan_rel_paths: |
| 252 | scan_rel_paths.append(path) |
| 253 | path_info_dict[path] = [] # 指定目录时,不支持指定改动代码行,为空,表示扫描整个文件 |
| 254 | return scan_rel_paths, path_info_dict |
| 255 | |
| 256 | @staticmethod |
| 257 | def get_result(proj_scan_succ, error_code, error_msg): |
no test coverage detected