Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
Examples of errors detected by the...

Examples of errors detected by the V7004 diagnostic

V7004. The 'then' statement is equivalent to the 'else' statement.


Visual Studio Code

V7004 [CWE-691] The 'then' statement is equivalent to the 'else' statement. bulkEditTree.ts 595


set(element: TextEditElement) {
  this._localDisposables.clear();

  this._localDisposables.add(
    dom.addDisposableListener(this._checkbox, 'change', e => {
    element.setChecked(this._checkbox.checked);
    e.preventDefault();
  }));
  if (element.parent.isChecked()) {
    this._checkbox.checked = element.isChecked();
    this._checkbox.disabled = element.isDisabled();
  } else {
    this._checkbox.checked = element.isChecked();
    this._checkbox.disabled = element.isDisabled();
  }
  ....
}

React

V7004. The 'then' statement is equivalent to the 'else' statement. InferMutationAliasingEffects.ts 1771


for (const property of value.properties) {
  if (property.kind === 'ObjectProperty') {
    effects.push({
      kind: 'Capture',
      from: property.place,
      into: lvalue,
    });
  } else {
    effects.push({
      kind: 'Capture',
      from: property.place,
      into: lvalue,
    });
  }
}

Visual Studio Code

V7004 The 'then' statement is equivalent to the 'else' statement. chatUsageWidget.ts 102


private renderQuotaItem(
    container: HTMLElement,
    label: string,
    quota: IQuotaSnapshot,
    overageEnabled: boolean = false
    ): void {
  ....
  const quotaItemValue = DOM.append(quotaItemHeader, $('.quota-item-value'));
  if (quota.unlimited) {
    quotaItemValue.textContent = localize('plan.included', 'Included');
  } else {
    quotaItemValue.textContent = localize('plan.included', 'Included');
  }
  ....
}

Overleaf

V7004. The 'then' statement is equivalent to the 'else' statement. index.js 39


if (change.isIntersecting) {
  videoIsVisible = true
  if (videoEl.readyState >= videoEl.HAVE_FUTURE_DATA) {
    if (!videoEl.ended) {
      videoEl
        .play()
        .catch(error =>
          debugConsole.error('Video autoplay failed:', error)
        )
    } else {
      videoEl
        .play()
        .catch(error =>
          debugConsole.error('Video autoplay failed:', error)
        )
    }
  }
}