Skip to content

fix: skip the destructuring assignment of the new object #78

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ dist
composer.json
composer.lock
vendor
venv/
.idea
2 changes: 2 additions & 0 deletions code2flow/javascript.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def process_assign(element):
return []

if target['init']['type'] == 'NewExpression':
if 'name' not in target['id']:
return []
token = target['id']['name']
call = get_call_from_func_element(target['init'])
if call:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_code/js/destructor_new/destructor_new.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class A {
b() {};
}

const { b } = new A();

b();
6 changes: 6 additions & 0 deletions tests/testdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,12 @@
"moment::toInt",
"moment::subtract$1",
"moment::humanize"]
},
{
"test_name": "destructor_new",
"directory": "destructor_new",
"expected_edges": [],
"expected_nodes": []
}
],
'mjs': [
Expand Down