Skip to content

Commit

Permalink
make description = url automated
Browse files Browse the repository at this point in the history
  • Loading branch information
clavedeluna committed Oct 13, 2023
1 parent b3c7ce1 commit 8fa8463
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions integration_tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ def _assert_results_fields(self, results, output_path):
result = results[0]
assert result["codemod"] == self.codemod_wrapper.id
assert result["references"] == self.codemod_wrapper.references

# TODO: once we add description for each url.
for reference in result["references"]:
assert reference["url"] == reference["description"]

assert len(result["changeset"]) == self.num_changed_files

# A codemod may change multiple files. For now we will
Expand Down
15 changes: 15 additions & 0 deletions src/codemodder/codemods/base_codemod.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ class CodemodMetadata:
REVIEW_GUIDANCE: ReviewGuidance
REFERENCES: list = field(default_factory=list)

# TODO: remove post_init update_references once we add description for each url.
def __post_init__(self):
object.__setattr__(self, "REFERENCES", self.update_references(self.REFERENCES))

@staticmethod
def update_references(references):
updated_references = []
for reference in references:
updated_reference = dict(
reference
) # Create a copy to avoid modifying the original dict
updated_reference["description"] = updated_reference["url"]
updated_references.append(updated_reference)
return updated_references


class BaseCodemod:
# Implementation borrowed from https://stackoverflow.com/a/45250114
Expand Down

0 comments on commit 8fa8463

Please sign in to comment.