-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sonar version of flask-json-response-type and UtilsMixin refactor
- Loading branch information
1 parent
fe47276
commit a5406e8
Showing
14 changed files
with
227 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from core_codemods.flask_json_response_type import FlaskJsonResponseTypeTransformer | ||
from core_codemods.sonar.sonar_flask_json_response_type import ( | ||
SonarFlaskJsonResponseType, | ||
) | ||
from integration_tests.base_test import ( | ||
BaseIntegrationTest, | ||
original_and_expected_from_code_path, | ||
) | ||
|
||
|
||
class TestSonarFlaskJsonResponseType(BaseIntegrationTest): | ||
codemod = SonarFlaskJsonResponseType | ||
code_path = "tests/samples/flask_json_response_type.py" | ||
original_code, expected_new_code = original_and_expected_from_code_path( | ||
code_path, | ||
[ | ||
( | ||
8, | ||
""" return make_response(json_response, {'Content-Type': 'application/json'})\n""", | ||
), | ||
], | ||
) | ||
sonar_issues_json = "tests/samples/sonar_issues.json" | ||
|
||
# fmt: off | ||
expected_diff =( | ||
"""--- \n""" | ||
"""+++ \n""" | ||
"""@@ -6,4 +6,4 @@\n""" | ||
""" @app.route("/test")\n""" | ||
""" def foo(request):\n""" | ||
""" json_response = json.dumps({ "user_input": request.GET.get("input") })\n""" | ||
"""- return make_response(json_response)\n""" | ||
"""+ return make_response(json_response, {'Content-Type': 'application/json'})\n""" | ||
) | ||
# fmt: on | ||
|
||
expected_line_change = "9" | ||
change_description = FlaskJsonResponseTypeTransformer.change_description | ||
num_changed_files = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from codemodder.codemods.base_codemod import Reference | ||
from codemodder.codemods.sonar import SonarCodemod | ||
from core_codemods.flask_json_response_type import FlaskJsonResponseType | ||
|
||
SonarFlaskJsonResponseType = SonarCodemod.from_core_codemod( | ||
name="flask-json-response-type-S5131", | ||
other=FlaskJsonResponseType, | ||
rules=["pythonsecurity:S5131"], | ||
new_references=[ | ||
Reference(url="https://rules.sonarsource.com/python/type/Bug/RSPEC-5131/"), | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.