You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.1 KiB

"""
数据模型和数据结构定义
"""
from dataclasses import dataclass
from pathlib import Path
from typing import List, Optional
@dataclass
class IssueLocation:
"""问题位置信息"""
file_path: Path
line: Optional[int]
@dataclass
class CppcheckIssue:
"""Cppcheck问题信息"""
id: str
severity: str
message: str
locations: List[IssueLocation]
@dataclass
class CodeContext:
"""代码上下文信息"""
file_path: Path
function_name: Optional[str] = None
class_name: Optional[str] = None
namespace: Optional[str] = None
includes: List[str] = None
dependencies: List[str] = None
variable_context: List[str] = None
control_flow_context: List[str] = None
def __post_init__(self):
if self.includes is None:
self.includes = []
if self.dependencies is None:
self.dependencies = []
if self.variable_context is None:
self.variable_context = []
if self.control_flow_context is None:
self.control_flow_context = []