fix: parse multiline TypeScript function bodies#629
Open
treygoff24 wants to merge 1 commit into
Open
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The TypeScript
async_no_awaitsmell detector can report false positives for multiline async functions whose signatures contain braces before the function body, such as:opts = {})Promise<{ ... }>)The previous body extractor picked the first
{within the signature window, so it inspected an empty/default/destructuring/type block instead of the real function body and missed realawaitexpressions.Fix
Promise<{ ... }>return types.Verification
uvx pytest desloppify/languages/typescript/tests/smells/test_ts_smell_helpers.py::TestDetectAsyncNoAwait desloppify/languages/typescript/tests/test_ts_smells.py::test_detect_async_no_await desloppify/languages/typescript/tests/test_ts_smells.py::test_async_with_await_not_flagged -q— passeduvx pytest desloppify/languages/typescript/tests -q— passed, 428 testsuvx ruff check desloppify/languages/typescript/detectors/smells/detector_core.py desloppify/languages/typescript/tests/smells/test_ts_smell_helpers.py— passed/Users/treygoff/Code/elevenlabs-cliwithPYTHONPATH=/tmp/desloppify-fix ... python -m desloppify scan --path .; false async/no-await findings dropped and objective score improved.Note:
uvx pytest desloppify/tests/ -qcurrently has 3 unrelated failures indesloppify/tests/lang/common/test_bash_unused_imports.py(bash source/dot-source unused import expectations returned no findings). These are unrelated to this TypeScript detector change.