Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codemod fix-assert-tuple #217

Merged
merged 6 commits into from
Jan 24, 2024
Merged

Codemod fix-assert-tuple #217

merged 6 commits into from
Jan 24, 2024

Conversation

clavedeluna
Copy link
Contributor

@clavedeluna clavedeluna commented Jan 18, 2024

Overview

Codemod to convert assert (1, 2) into

assert 1
assert 2

Notice the same sonarcloud rule this PR triggered and this is the same pylint rule

Copy link

codecov bot commented Jan 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c0f1b24) 96.44% compared to head (5953722) 96.47%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #217      +/-   ##
==========================================
+ Coverage   96.44%   96.47%   +0.02%     
==========================================
  Files          97       98       +1     
  Lines        4169     4196      +27     
==========================================
+ Hits         4021     4048      +27     
  Misses        148      148              
Files Coverage Δ
src/core_codemods/__init__.py 100.00% <100.00%> (ø)
src/core_codemods/fix_assert_tuple.py 100.00% <100.00%> (ø)

src/core_codemods/fix_assert_tuple.py Show resolved Hide resolved



Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel those empty lines shouldn't be here.

Copy link
Member

@drdavella drdavella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice overall but some suggestions for metadata

class FixAssertTuple(SimpleCodemod, NameResolutionMixin):
metadata = Metadata(
name="fix-assert-tuple",
summary="Fix Assert on Populated Tuple",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

Suggested change
summary="Fix Assert on Populated Tuple",
summary="Fix `assert` on Non-Empty Tuple Literal",

references=[],
)
change_description = (
"Separate assertion on a populated tuple into multiple assert statements."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Separate assertion on a populated tuple into multiple assert statements."
"Separate assertion on a non-empty tuple literal into multiple assert statements."

@@ -0,0 +1,11 @@
An assertion on a non-empty tuple will always evaluate to `True` so it's likely to be written unintentionally. This codemod will write one assert statement for each item in the tuple.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
An assertion on a non-empty tuple will always evaluate to `True` so it's likely to be written unintentionally. This codemod will write one assert statement for each item in the tuple.
An assertion on a non-empty tuple will always evaluate to `True`. This means that `assert` statements involving non-empty tuple literals are likely unintentional and should be rewritten. This codemod rewrites the original `assert` statement by creating a new `assert` for each item in the original tuple.

metadata = Metadata(
name="fix-assert-tuple",
summary="Fix Assert on Populated Tuple",
review_guidance=ReviewGuidance.MERGE_WITHOUT_REVIEW,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be MERGE_AFTER_CURSORY_REVIEW because there's a decent change we break some tests.

Copy link

sonarcloud bot commented Jan 23, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@clavedeluna clavedeluna added this pull request to the merge queue Jan 24, 2024
Merged via the queue into main with commit 4cc579f Jan 24, 2024
14 checks passed
@clavedeluna clavedeluna deleted the codemod-assert-tuple branch January 24, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants