Skip to content

Conversation

alexandear
Copy link
Collaborator

@alexandear alexandear commented Jun 4, 2025

This PR fixes a bug with the allowJump option. It was introduced in #1138, but missed cases where a short block contains deviating functions (such as panic, os.Exit, etc.).

Fixes #1253.

@alexandear alexandear marked this pull request as draft June 4, 2025 12:47
@alexandear alexandear force-pushed the early-return-test-case branch from 7c006de to 6b966b4 Compare June 4, 2025 13:02
@alexandear alexandear changed the title test: additional test case for early-return rule early-return: don't suggest refactor for single-statement error checks Jun 4, 2025
@alexandear alexandear force-pushed the early-return-test-case branch from 6b966b4 to b75ed09 Compare June 4, 2025 13:03
@alexandear alexandear marked this pull request as ready for review June 4, 2025 13:04
@alexandear alexandear force-pushed the early-return-test-case branch from b75ed09 to b8d11b9 Compare June 4, 2025 13:06
@alexandear alexandear requested a review from chavacava June 4, 2025 13:08
@alexandear alexandear marked this pull request as draft June 4, 2025 14:42
@alexandear alexandear changed the title early-return: don't suggest refactor for single-statement error checks early-return: don't suggest refactor for single-statement checks Jun 5, 2025
@alexandear alexandear force-pushed the early-return-test-case branch from b8d11b9 to 963298c Compare June 5, 2025 11:42
@alexandear alexandear changed the title early-return: don't suggest refactor for single-statement checks early-return: detect short deviated statements Jun 5, 2025
@alexandear alexandear requested review from ccoVeille and chavacava June 5, 2025 11:44
@alexandear alexandear marked this pull request as ready for review June 5, 2025 11:45
@alexandear alexandear force-pushed the early-return-test-case branch from 963298c to de1b8ec Compare June 5, 2025 11:48
@ccoVeille
Copy link
Contributor

I feel like you found another way to fix the issue that was reported when allow jump and preserve scope are used at same time.

I'm confident your fix works, but shouldn't you add a test where allowJump and preserveScope are enabled at same time?

@alexandear alexandear force-pushed the early-return-test-case branch from de1b8ec to bbb08c0 Compare June 6, 2025 10:51
@alexandear
Copy link
Collaborator Author

I'm confident your fix works, but shouldn't you add a test where allowJump and preserveScope are enabled at same time?

Added

@alexandear alexandear requested a review from chavacava June 11, 2025 15:01
@chavacava chavacava merged commit 77d0d4a into mgechev:master Jun 25, 2025
8 checks passed
@alexandear alexandear deleted the early-return-test-case branch June 25, 2025 13:29
@alexandear alexandear mentioned this pull request Jul 1, 2025
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.

Configuration option to ignore error handling with early return linter
4 participants