Skip to content
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

JavaScript warnings on Array, Object-type methods does not respect function parameter defaults #73

Open
mschlitz-trux opened this issue Dec 30, 2020 · 2 comments

Comments

@mschlitz-trux
Copy link

mschlitz-trux commented Dec 30, 2020

Using this example code below:

_renderAttachments(attachments = []) {
    return attachments.map((attach) => {

DeepCode will warn that calling .map() on non array object for attachments will not work.
It suggests to use (attachments || []). While this is correct, it does not account for the function parameter default value which is already provided.

In the above case, the function already provides a fallback for (attachments = []), so the suggested change would offer no further benefit.

This also occurs for things like Object fallbacks (attachments = {}), or es6 Object types such as (attachments = new Map())

@deepcodeg
Copy link
Contributor

@mschlitz-trux 👋, just checked with the AI team, this should be fixed, could you please check on your end if this is the case?

@mschlitz-trux
Copy link
Author

Thanks, I'm still trying to check. The extension constantly crashing for me in VSCode the past few days, so I cannot confirm this yet.

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

No branches or pull requests

2 participants