(self, output_file)
| 65 | return issues |
| 66 | |
| 67 | def _format_issue(self, output_file): |
| 68 | issues = [] |
| 69 | try: |
| 70 | result_tree = ET.parse(output_file) |
| 71 | except ET.ParseError: |
| 72 | raise AnalyzeTaskError("源文件编码格式错误,建议启用WrongEncoding规则检测源文件编码格式") |
| 73 | root = result_tree.getroot() |
| 74 | for error in root: |
| 75 | error_attr = error.attrib |
| 76 | path = error_attr["file"] |
| 77 | if not path: |
| 78 | continue |
| 79 | rule = error_attr["subid"] |
| 80 | if not rule or rule not in self.rules: |
| 81 | continue |
| 82 | issues.append( |
| 83 | { |
| 84 | "path": path[self.relpos :], |
| 85 | "rule": rule, |
| 86 | "line": int(error_attr.get("line", "0")), |
| 87 | "column": "1", |
| 88 | "msg": error_attr.get("msg", ""), |
| 89 | } |
| 90 | ) |
| 91 | return issues |
| 92 | |
| 93 | |
| 94 | if __name__ == "__main__": |
no test coverage detected