Skip to content

Commit

Permalink
Renamed codemod to replace-flask-send-file
Browse files Browse the repository at this point in the history
  • Loading branch information
andrecsilva committed Jan 17, 2024
1 parent 46cf352 commit ac74626
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from core_codemods.flask_send_file_path_parameterization import (
FlaskSendFilePathParameterization,
from core_codemods.replace_flask_send_file import (
ReplaceFlaskSendFile,
)
from integration_tests.base_test import (
BaseIntegrationTest,
original_and_expected_from_code_path,
)


class TestFlaskSendFilePathParameterization(BaseIntegrationTest):
codemod = FlaskSendFilePathParameterization
code_path = "tests/samples/flask_send_file_path_parameterization.py"
class TestReplaceFlaskSendFile(BaseIntegrationTest):
codemod = ReplaceFlaskSendFile
code_path = "tests/samples/replace_flask_send_file.py"
original_code, expected_new_code = original_and_expected_from_code_path(
code_path,
[
Expand Down Expand Up @@ -49,5 +49,5 @@ class TestFlaskSendFilePathParameterization(BaseIntegrationTest):
# fmt: on

expected_line_change = "7"
change_description = FlaskSendFilePathParameterization.CHANGE_DESCRIPTION
change_description = ReplaceFlaskSendFile.CHANGE_DESCRIPTION
num_changed_files = 1
2 changes: 1 addition & 1 deletion src/codemodder/scripts/generate_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class DocMetadata:
importance="High",
guidance_explained="Flask views may require proper handling of CSRF to function as expected and thus this change may break some views.",
),
"flask-send-file-path-parameterization": DocMetadata(
"replace-flask-send-file": DocMetadata(
importance="Medium",
guidance_explained="We believe this change is safe and will not cause any issues.",
),
Expand Down
4 changes: 2 additions & 2 deletions src/core_codemods/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from .combine_startswith_endswith import CombineStartswithEndswith
from .fix_deprecated_logging_warn import FixDeprecatedLoggingWarn
from .flask_enable_csrf_protection import FlaskEnableCSRFProtection
from .flask_send_file_path_parameterization import FlaskSendFilePathParameterization
from .replace_flask_send_file import ReplaceFlaskSendFile

registry = CodemodCollection(
origin="pixee",
Expand Down Expand Up @@ -97,6 +97,6 @@
CombineStartswithEndswith,
FixDeprecatedLoggingWarn,
FlaskEnableCSRFProtection,
FlaskSendFilePathParameterization,
ReplaceFlaskSendFile,
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from codemodder.utils.utils import positional_to_keyword


class FlaskSendFilePathParameterization(BaseCodemod, NameAndAncestorResolutionMixin):
NAME = "flask-send-file-path-parameterization"
class ReplaceFlaskSendFile(BaseCodemod, NameAndAncestorResolutionMixin):
NAME = "replace-flask-send-file"
SUMMARY = "Replace unsafe usage of `flask.send_file`"
DESCRIPTION = SUMMARY
REVIEW_GUIDANCE = ReviewGuidance.MERGE_WITHOUT_REVIEW
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from core_codemods.flask_send_file_path_parameterization import (
FlaskSendFilePathParameterization,
from core_codemods.replace_flask_send_file import (
ReplaceFlaskSendFile,
)
from tests.codemods.base_codemod_test import BaseCodemodTest


class TestFlaskSendFilePathParameterization(BaseCodemodTest):
codemod = FlaskSendFilePathParameterization
class TestReplaceFlaskSendFile(BaseCodemodTest):
codemod = ReplaceFlaskSendFile

def test_name(self):
assert self.codemod.name() == "flask-send-file-path-parameterization"
assert self.codemod.name() == "replace-flask-send-file"

def test_direct_string(self, tmpdir):
input_code = """\
Expand Down
File renamed without changes.

0 comments on commit ac74626

Please sign in to comment.