Skip to content

Codemod fix-assert-tuple#217

Merged
clavedeluna merged 6 commits intomainfrom
codemod-assert-tuple
Jan 24, 2024
Merged

Codemod fix-assert-tuple#217
clavedeluna merged 6 commits intomainfrom
codemod-assert-tuple

Conversation

@clavedeluna
Copy link
Copy Markdown
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

@codecov
Copy link
Copy Markdown

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%> (ø)

@clavedeluna clavedeluna marked this pull request as ready for review January 19, 2024 12:31
Comment thread src/core_codemods/fix_assert_tuple.py



Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread src/core_codemods/fix_assert_tuple.py Outdated
class FixAssertTuple(SimpleCodemod, NameResolutionMixin):
metadata = Metadata(
name="fix-assert-tuple",
summary="Fix Assert on Populated Tuple",
Copy link
Copy Markdown
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",

Comment thread src/core_codemods/fix_assert_tuple.py Outdated
references=[],
)
change_description = (
"Separate assertion on a populated tuple into multiple assert statements."
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread src/core_codemods/fix_assert_tuple.py Outdated
metadata = Metadata(
name="fix-assert-tuple",
summary="Fix Assert on Populated Tuple",
review_guidance=ReviewGuidance.MERGE_WITHOUT_REVIEW,
Copy link
Copy Markdown
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.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud 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 requested a review from drdavella January 23, 2024 11:14
@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
@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