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

Method _get_id_severity_map

client/tool/cppcheck.py:187–208  ·  view source on GitHub ↗

获取cppcheck所有规则和严重级别的对应关系 :return:

(self)

Source from the content-addressed store, hash-verified

185 return result_list
186
187 def _get_id_severity_map(self):
188 """获取cppcheck所有规则和严重级别的对应关系
189
190 :return:
191 """
192 cmd_args = ["cppcheck", "--errorlist", "--xml-version=2"]
193 errorlist_path = "cppcheck_errorlist.xml"
194 return_code = SubProcController(
195 cmd_args,
196 cwd=os.environ["CPPCHECK_HOME"],
197 stdout_filepath=errorlist_path,
198 stderr_line_callback=self.print_log,
199 env=EnvSet().get_origin_env(),
200 ).wait()
201 if return_code != 0:
202 raise ConfigError("当前机器环境可能不支持cppcheck执行,请查阅任务日志,根据实际情况适配。")
203 with open(errorlist_path, "r") as rf:
204 errorlist = rf.read()
205
206 error_root = ET.fromstring(errorlist).find("errors")
207 id_severity_map = {error.get("id"): error.get("severity") for error in error_root}
208 return id_severity_map
209
210 def _get_needed_visitors(self, id_severity_map, rule_list):
211 """cppcheck不能指定规则分析,只能指定规则级别,这里通过rules获取所属的规则级别"""

Callers 1

analyzeMethod · 0.95

Calls 5

EnvSetClass · 0.90
ConfigErrorClass · 0.90
get_origin_envMethod · 0.80
readMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected