MCPcopy Create free account
hub / github.com/Tencent/CodeAnalysis / format_issues

Method format_issues

client/tool/scalastyle.py:140–173  ·  view source on GitHub ↗

格式化scalastyle结果

(self, output_file)

Source from the content-addressed store, hash-verified

138 return config_file
139
140 def format_issues(self, output_file):
141 """格式化scalastyle结果
142 """
143 if not os.path.exists(output_file):
144 LogPrinter.info("分析失败")
145 return []
146 issues = []
147 root = ET.parse(output_file).getroot()
148 files = root.findall("file")
149 for file_node in files:
150 errors = file_node.findall("error")
151 for error in errors:
152 path = file_node.get("name")
153 rule = error.get("source")
154 line = error.get("line")
155 # 有些是文件层级错误没有line信息
156 if not line:
157 line = 1
158 column = error.get("column")
159 if not column:
160 column = "1"
161 msg = error.get("message")
162 if rule not in self.rules:
163 continue
164 issues.append(
165 {
166 "path": path[self.pos :],
167 "line": int(line),
168 "column": column,
169 "msg": msg,
170 "rule": rule,
171 }
172 )
173 return issues
174
175
176tool = ScalaStyle

Callers 1

analyzeMethod · 0.95

Calls 3

infoMethod · 0.45
parseMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected