-
-
Notifications
You must be signed in to change notification settings - Fork 7
fix: Ensure all checks pass without overwriting previous failures #213
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
fix: Ensure all checks pass without overwriting previous failures #213
Conversation
Passing checks could overwrite a previous failing check and result in returning with an exit code of 0 when a check failed
Caution Review failedThe pull request is closed. WalkthroughThis pull request modifies the commit-check logic by replacing the single return variable with a list that aggregates results from multiple checks. The main function in Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
commit_check/main.py (1)
122-125
: Consider early return optimization for dry-run.Moving the dry-run check before running any checks would be more efficient as it could avoid unnecessary processing.
def main() -> int: parser = get_parser() args = parser.parse_args() + if args.dry_run: + return PASS check_results: list[int] = [] # ... rest of the function - if args.dry_run: - return PASS return PASS if all(val == PASS for val in check_results) else FAILtests/main_test.py (1)
167-169
: Consider refactoring author check implementation.The comment about the messy implementation suggests a need for separate
check_author_name
andcheck_author_email
functions.Would you like me to propose a refactored implementation that separates these concerns?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
commit_check/main.py
(2 hunks)tests/main_test.py
(1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
tests/main_test.py
122-122: Undefined name PASS
(F821)
122-122: Undefined name PASS
(F821)
122-122: Undefined name PASS
(F821)
122-122: Undefined name PASS
(F821)
122-122: Undefined name PASS
(F821)
122-122: Undefined name PASS
(F821)
122-122: Undefined name PASS
(F821)
123-123: Undefined name FAIL
(F821)
123-123: Undefined name PASS
(F821)
123-123: Undefined name PASS
(F821)
123-123: Undefined name PASS
(F821)
123-123: Undefined name PASS
(F821)
123-123: Undefined name PASS
(F821)
123-123: Undefined name FAIL
(F821)
124-124: Undefined name FAIL
(F821)
124-124: Undefined name PASS
(F821)
124-124: Undefined name PASS
(F821)
124-124: Undefined name PASS
(F821)
124-124: Undefined name PASS
(F821)
124-124: Undefined name PASS
(F821)
124-124: Undefined name FAIL
(F821)
125-125: Undefined name PASS
(F821)
125-125: Undefined name PASS
(F821)
125-125: Undefined name PASS
(F821)
125-125: Undefined name PASS
(F821)
125-125: Undefined name FAIL
(F821)
125-125: Undefined name PASS
(F821)
125-125: Undefined name FAIL
(F821)
126-126: Undefined name PASS
(F821)
126-126: Undefined name PASS
(F821)
126-126: Undefined name PASS
(F821)
126-126: Undefined name PASS
(F821)
126-126: Undefined name PASS
(F821)
126-126: Undefined name PASS
(F821)
126-126: Undefined name PASS
(F821)
127-127: Undefined name FAIL
(F821)
127-127: Undefined name PASS
(F821)
127-127: Undefined name PASS
(F821)
127-127: Undefined name PASS
(F821)
127-127: Undefined name PASS
(F821)
127-127: Undefined name PASS
(F821)
127-127: Undefined name FAIL
(F821)
128-128: Undefined name PASS
(F821)
128-128: Undefined name PASS
(F821)
128-128: Undefined name FAIL
(F821)
128-128: Undefined name PASS
(F821)
128-128: Undefined name PASS
(F821)
128-128: Undefined name PASS
(F821)
128-128: Undefined name FAIL
(F821)
129-129: Undefined name PASS
(F821)
129-129: Undefined name PASS
(F821)
129-129: Undefined name PASS
(F821)
129-129: Undefined name FAIL
(F821)
129-129: Undefined name PASS
(F821)
129-129: Undefined name PASS
(F821)
129-129: Undefined name FAIL
(F821)
130-130: Undefined name PASS
(F821)
130-130: Undefined name PASS
(F821)
130-130: Undefined name FAIL
(F821)
130-130: Undefined name FAIL
(F821)
130-130: Undefined name PASS
(F821)
130-130: Undefined name PASS
(F821)
130-130: Undefined name FAIL
(F821)
131-131: Undefined name PASS
(F821)
131-131: Undefined name PASS
(F821)
131-131: Undefined name PASS
(F821)
131-131: Undefined name PASS
(F821)
131-131: Undefined name PASS
(F821)
131-131: Undefined name PASS
(F821)
131-131: Undefined name PASS
(F821)
132-132: Undefined name FAIL
(F821)
132-132: Undefined name FAIL
(F821)
132-132: Undefined name FAIL
(F821)
132-132: Undefined name FAIL
(F821)
132-132: Undefined name FAIL
(F821)
132-132: Undefined name FAIL
(F821)
132-132: Undefined name FAIL
(F821)
133-133: Undefined name FAIL
(F821)
133-133: Undefined name PASS
(F821)
133-133: Undefined name PASS
(F821)
133-133: Undefined name PASS
(F821)
133-133: Undefined name PASS
(F821)
133-133: Undefined name PASS
(F821)
133-133: Undefined name FAIL
(F821)
134-134: Undefined name FAIL
(F821)
134-134: Undefined name FAIL
(F821)
134-134: Undefined name FAIL
(F821)
134-134: Undefined name FAIL
(F821)
134-134: Undefined name FAIL
(F821)
134-134: Undefined name FAIL
(F821)
134-134: Undefined name PASS
(F821)
🔇 Additional comments (3)
commit_check/main.py (2)
102-102
: LGTM! Good use of type hints.The type hint for
check_results
clearly indicates it's a list of integers, which aligns with the PASS/FAIL return values.
110-120
: LGTM! Improved result aggregation.The changes effectively collect results from all checks without overwriting previous failures. This fixes the core issue where subsequent checks could mask earlier failures.
tests/main_test.py (1)
119-136
: LGTM! Comprehensive test coverage.The parametrized test cases effectively verify the new result aggregation logic with various combinations of check results.
🧰 Tools
🪛 Ruff (0.8.2)
122-122: Undefined name
PASS
(F821)
122-122: Undefined name
PASS
(F821)
122-122: Undefined name
PASS
(F821)
122-122: Undefined name
PASS
(F821)
122-122: Undefined name
PASS
(F821)
122-122: Undefined name
PASS
(F821)
122-122: Undefined name
PASS
(F821)
123-123: Undefined name
FAIL
(F821)
123-123: Undefined name
PASS
(F821)
123-123: Undefined name
PASS
(F821)
123-123: Undefined name
PASS
(F821)
123-123: Undefined name
PASS
(F821)
123-123: Undefined name
PASS
(F821)
123-123: Undefined name
FAIL
(F821)
124-124: Undefined name
FAIL
(F821)
124-124: Undefined name
PASS
(F821)
124-124: Undefined name
PASS
(F821)
124-124: Undefined name
PASS
(F821)
124-124: Undefined name
PASS
(F821)
124-124: Undefined name
PASS
(F821)
124-124: Undefined name
FAIL
(F821)
125-125: Undefined name
PASS
(F821)
125-125: Undefined name
PASS
(F821)
125-125: Undefined name
PASS
(F821)
125-125: Undefined name
PASS
(F821)
125-125: Undefined name
FAIL
(F821)
125-125: Undefined name
PASS
(F821)
125-125: Undefined name
FAIL
(F821)
126-126: Undefined name
PASS
(F821)
126-126: Undefined name
PASS
(F821)
126-126: Undefined name
PASS
(F821)
126-126: Undefined name
PASS
(F821)
126-126: Undefined name
PASS
(F821)
126-126: Undefined name
PASS
(F821)
126-126: Undefined name
PASS
(F821)
127-127: Undefined name
FAIL
(F821)
127-127: Undefined name
PASS
(F821)
127-127: Undefined name
PASS
(F821)
127-127: Undefined name
PASS
(F821)
127-127: Undefined name
PASS
(F821)
127-127: Undefined name
PASS
(F821)
127-127: Undefined name
FAIL
(F821)
128-128: Undefined name
PASS
(F821)
128-128: Undefined name
PASS
(F821)
128-128: Undefined name
FAIL
(F821)
128-128: Undefined name
PASS
(F821)
128-128: Undefined name
PASS
(F821)
128-128: Undefined name
PASS
(F821)
128-128: Undefined name
FAIL
(F821)
129-129: Undefined name
PASS
(F821)
129-129: Undefined name
PASS
(F821)
129-129: Undefined name
PASS
(F821)
129-129: Undefined name
FAIL
(F821)
129-129: Undefined name
PASS
(F821)
129-129: Undefined name
PASS
(F821)
129-129: Undefined name
FAIL
(F821)
130-130: Undefined name
PASS
(F821)
130-130: Undefined name
PASS
(F821)
130-130: Undefined name
FAIL
(F821)
130-130: Undefined name
FAIL
(F821)
130-130: Undefined name
PASS
(F821)
130-130: Undefined name
PASS
(F821)
130-130: Undefined name
FAIL
(F821)
131-131: Undefined name
PASS
(F821)
131-131: Undefined name
PASS
(F821)
131-131: Undefined name
PASS
(F821)
131-131: Undefined name
PASS
(F821)
131-131: Undefined name
PASS
(F821)
131-131: Undefined name
PASS
(F821)
131-131: Undefined name
PASS
(F821)
132-132: Undefined name
FAIL
(F821)
132-132: Undefined name
FAIL
(F821)
132-132: Undefined name
FAIL
(F821)
132-132: Undefined name
FAIL
(F821)
132-132: Undefined name
FAIL
(F821)
132-132: Undefined name
FAIL
(F821)
132-132: Undefined name
FAIL
(F821)
133-133: Undefined name
FAIL
(F821)
133-133: Undefined name
PASS
(F821)
133-133: Undefined name
PASS
(F821)
133-133: Undefined name
PASS
(F821)
133-133: Undefined name
PASS
(F821)
133-133: Undefined name
PASS
(F821)
133-133: Undefined name
FAIL
(F821)
134-134: Undefined name
FAIL
(F821)
134-134: Undefined name
FAIL
(F821)
134-134: Undefined name
FAIL
(F821)
134-134: Undefined name
FAIL
(F821)
134-134: Undefined name
FAIL
(F821)
134-134: Undefined name
FAIL
(F821)
134-134: Undefined name
PASS
(F821)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
tests/main_test.py (1)
176-177
:⚠️ Potential issueRemove duplicate mock.
The mock for
check_author
is duplicated. This was previously flagged in a review.Apply this diff to fix the issue:
mocker.patch("commit_check.author.check_author", side_effect=author_side_effect) -mocker.patch("commit_check.author.check_author", side_effect=author_side_effect)
🧹 Nitpick comments (1)
tests/main_test.py (1)
167-176
: Consider refactoring author checks for better encapsulation.The comment correctly identifies that the current implementation exposes unnecessary implementation details. Consider splitting the author check into two separate public methods.
Here's a suggested approach:
# In commit_check/author.py def check_author_name(config) -> int: return check_author(config, "author_name") def check_author_email(config) -> int: return check_author(config, "author_email") # Make check_author private by renaming to _check_authorThis would simplify testing and provide a cleaner API.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/main_test.py
(2 hunks)
🔇 Additional comments (2)
tests/main_test.py (2)
4-4
: LGTM! Import statement added as suggested.The missing imports for
PASS
andFAIL
constants have been added as recommended in the previous review.
119-180
: Well-structured test cases with comprehensive coverage!The new test method
test_main_multiple_checks
effectively validates:
- Individual check failures
- Multiple check combinations
- All pass/fail scenarios
- Dry run behavior
The parametrized test cases provide good coverage of the main function's behavior.
All code paths are covered here, checked by the assert
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #213 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 7 7
Lines 290 290
=========================================
Hits 290 290 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! thank you.
See #212 for rationale
I also added some testing to demonstrate the problem and verify the solution in
main_test.py
Before fix:
After fix:
Closes #212
Summary by CodeRabbit