diff --git a/src/codemodder/semgrep.py b/src/codemodder/semgrep.py index 7c6e7a32..5884f1e2 100644 --- a/src/codemodder/semgrep.py +++ b/src/codemodder/semgrep.py @@ -7,7 +7,6 @@ from typing_extensions import Self, override -from codemodder.codetf import Finding, Rule from codemodder.context import CodemodExecutionContext from codemodder.logging import logger from codemodder.result import LineInfo, Result, ResultSet, SarifLocation, SarifResult @@ -48,31 +47,11 @@ class SemgrepResult(SarifResult): location_type = SemgrepLocation @classmethod - def from_sarif( - cls, sarif_result, sarif_run, truncate_rule_id: bool = False - ) -> Self: - # avoid circular import + def rule_url_from_id(cls, sarif_result, sarif_run, rule_id): + del sarif_result, sarif_run from core_codemods.semgrep.api import semgrep_url_from_id - return cls( - rule_id=( - rule_id := cls.extract_rule_id( - sarif_result, sarif_run, truncate_rule_id - ) - ), - locations=cls.extract_locations(sarif_result), - codeflows=cls.extract_code_flows(sarif_result), - related_locations=cls.extract_related_locations(sarif_result), - finding_id=rule_id, - finding=Finding( - id=rule_id, - rule=Rule( - id=rule_id, - name=rule_id, - url=semgrep_url_from_id(rule_id), - ), - ), - ) + return semgrep_url_from_id(rule_id) class SemgrepResultSet(ResultSet):