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

Method check

client/tool/util/collie.py:89–171  ·  view source on GitHub ↗
(self, files=None, want_suffix=None, force_all=False, method_mode=False)

Source from the content-addressed store, hash-verified

87 return None
88
89 def check(self, files=None, want_suffix=None, force_all=False, method_mode=False):
90 incr_scan = self.params.get("incr_scan", False)
91 func_output = os.path.join(self.work_dir, f"{self.tool_name.lower()}_output")
92 files_path = os.path.join(self.work_dir, f"{self.tool_name.lower()}_paths.txt")
93
94 toscans = files
95 want_suffix = want_suffix if want_suffix else self.get_lang_ext()
96 if toscans is None:
97 if incr_scan and not force_all:
98 diffs = SCMMgr(self.params).get_scm_diff()
99 toscans = [
100 os.path.join(self.source_dir, diff.path)
101 for diff in diffs
102 if diff.path.endswith(tuple(want_suffix)) and diff.state != "del"
103 ]
104 else:
105 toscans = PathMgr().get_dir_files(self.source_dir, tuple(want_suffix))
106 else:
107 toscans = [file for file in toscans if file.endswith(tuple(want_suffix))]
108 toscans = [path.replace(os.sep, "/") for path in toscans]
109 toscans = FilterPathUtil(self.params).get_include_files(toscans, self.relpos)
110
111 if not toscans:
112 logger.info("被分析文件列表为空")
113 return None
114 with open(files_path, "w", encoding="UTF-8") as f:
115 f.write("\n".join(toscans))
116
117 options = [
118 "-l",
119 ",".join(self.scan_languages),
120 "-o",
121 func_output,
122 "-F",
123 "csv",
124 "-s",
125 self.source_dir,
126 "-p",
127 files_path,
128 ]
129 if method_mode:
130 options.append("-m")
131
132 # 默认开启所有规则
133 # 支持指定规则,使用配置文件的方式,以下是demo
134 # {
135 # "enableCheckers": {
136 # "GoFuncVisitor": {},
137 # "JavaScriptFuncVisitor": {
138 # "ignoreNestingMethods": true
139 # }
140 # }
141 # }
142 config = dict()
143 enable_rules = dict()
144 rule_list = self.params.get("rule_list", list())
145 for rule in rule_list:
146 # 因为有这个字段但本身就是None,所以返回None

Callers 1

scanMethod · 0.95

Calls 10

get_lang_extMethod · 0.95
get_cmdMethod · 0.95
_close_procMethod · 0.95
ConfigReaderClass · 0.90
get_dir_filesMethod · 0.80
dumpMethod · 0.80
getMethod · 0.45
infoMethod · 0.45
writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected