Skip to content

Commit 40bb897

Browse files
authored
Findings for results should not be optional (#1053)
* Findings for results are not optional * Loosen restriction on packaging * Add method to retrieve locations
1 parent 5ddd742 commit 40bb897

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies = [
1515
"GitPython<4",
1616
"isort>=5.12,<6.1",
1717
"libcst>=1.7,<1.8",
18-
"packaging>=25,<25.1",
18+
"packaging>=24.2,<25.1",
1919
# do not update pydantic due to inconsistent test failures
2020
"pydantic~=2.10.6",
2121
"pylint>=3.3,<3.4",

src/codemodder/result.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class Result(ABCDataclass):
8484
locations: Sequence[Location]
8585
codeflows: Sequence[Sequence[Location]] = field(default_factory=tuple)
8686
related_locations: Sequence[LocationWithMessage] = field(default_factory=tuple)
87-
finding: Finding | None = None
87+
finding: Finding
8888

8989
def match_location(self, pos: CodeRange, node: cst.CSTNode) -> bool:
9090
del node
@@ -103,6 +103,13 @@ def match_location(self, pos: CodeRange, node: cst.CSTNode) -> bool:
103103
def __hash__(self):
104104
return hash(self.rule_id)
105105

106+
def get_locations(self) -> Sequence[Sequence[Location]]:
107+
return self.codeflows or (
108+
[self.locations]
109+
if self.locations
110+
else [[loc.location for loc in self.related_locations]]
111+
)
112+
106113

107114
@dataclass(frozen=True, kw_only=True)
108115
class SASTResult(Result):

0 commit comments

Comments
 (0)