From 22e3c04584fa2e94d002fe9b2c1e0f5ece89bd0c Mon Sep 17 00:00:00 2001 From: Daniel D'Avella Date: Fri, 1 Mar 2024 11:19:41 -0500 Subject: [PATCH] Ensure all codemods have non-empty change descriptions --- src/codemodder/codemods/test/utils.py | 2 ++ src/core_codemods/https_connection.py | 2 ++ src/core_codemods/remove_unnecessary_f_str.py | 2 ++ src/core_codemods/replace_flask_send_file.py | 4 ++++ 4 files changed, 10 insertions(+) diff --git a/src/codemodder/codemods/test/utils.py b/src/codemodder/codemods/test/utils.py index b4ad0bc5..67a81bc8 100644 --- a/src/codemodder/codemods/test/utils.py +++ b/src/codemodder/codemods/test/utils.py @@ -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, diff --git a/src/core_codemods/https_connection.py b/src/core_codemods/https_connection.py index a1b2eeb1..9d2ea3f3 100644 --- a/src/core_codemods/https_connection.py +++ b/src/core_codemods/https_connection.py @@ -66,6 +66,8 @@ class HTTPSConnection(SimpleCodemod): ], ) + change_description = "Enforce HTTPS connection for `urllib3`" + METADATA_DEPENDENCIES = (PositionProvider,) matching_functions: set[str] = { diff --git a/src/core_codemods/remove_unnecessary_f_str.py b/src/core_codemods/remove_unnecessary_f_str.py index 1d3003b9..de7dc1b0 100644 --- a/src/core_codemods/remove_unnecessary_f_str.py +++ b/src/core_codemods/remove_unnecessary_f_str.py @@ -28,6 +28,8 @@ class RemoveUnnecessaryFStr(SimpleCodemod, UnnecessaryFormatString): ], ) + change_description = "Remove unnecessary f-string" + def __init__( self, codemod_context: CodemodContext, *codemod_args, **codemod_kwargs ): diff --git a/src/core_codemods/replace_flask_send_file.py b/src/core_codemods/replace_flask_send_file.py index 8737347a..37097fa3 100644 --- a/src/core_codemods/replace_flask_send_file.py +++ b/src/core_codemods/replace_flask_send_file.py @@ -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",