vscode-extension icon indicating copy to clipboard operation
vscode-extension copied to clipboard

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

Open mschlitz-trux opened this issue 4 years ago • 2 comments

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())

mschlitz-trux avatar Dec 30 '20 06:12 mschlitz-trux

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

deepcodeg avatar Jan 13 '21 12:01 deepcodeg

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.

mschlitz-trux avatar Jan 14 '21 19:01 mschlitz-trux