Skip to content

Commit

Permalink
Ensure all codemods have non-empty change descriptions (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
drdavella authored Mar 1, 2024
1 parent 8a7946e commit 15dba6b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/codemodder/codemods/test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def assert_changes(self, root, file_path, input_code, expected, changes):
output_code = tmp_file.read()

assert output_code == dedent(expected)
# All changes must have non-empty descriptions
assert all(change.description for change in changes.changes)

def run_and_assert_filepath(
self,
Expand Down
2 changes: 2 additions & 0 deletions src/core_codemods/https_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class HTTPSConnection(SimpleCodemod):
],
)

change_description = "Enforce HTTPS connection for `urllib3`"

METADATA_DEPENDENCIES = (PositionProvider,)

matching_functions: set[str] = {
Expand Down
2 changes: 2 additions & 0 deletions src/core_codemods/remove_unnecessary_f_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class RemoveUnnecessaryFStr(SimpleCodemod, UnnecessaryFormatString):
],
)

change_description = "Remove unnecessary f-string"

def __init__(
self, codemod_context: CodemodContext, *codemod_args, **codemod_kwargs
):
Expand Down
4 changes: 4 additions & 0 deletions src/core_codemods/replace_flask_send_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class ReplaceFlaskSendFile(SimpleCodemod, NameAndAncestorResolutionMixin):
],
)

change_description = (
"Replace unsafe usage of `flask.send_file` with `flask.send_from_directory`"
)

pos_to_key_map: list[str | None] = [
"mimetype",
"as_attachment",
Expand Down

0 comments on commit 15dba6b

Please sign in to comment.