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 V7001 diagnostic

V7001. Operands of a binary operator are equivalent.


Visual Studio Code

V7001 The operands of the '&&' operator are equivalent. diagnostic.ts 99


static isEqual(a: Diagnostic | undefined, b: Diagnostic | undefined): boolean {
  if (a === b) {
    return true;
  }
  if (!a || !b) {
    return false;
  }
  return a.message === b.message
    && a.severity === b.severity         // <=
    && a.code === b.code
    && a.severity === b.severity         // <=
    && a.source === b.source
    && a.range.isEqual(b.range)
    && equals(a.tags, b.tags)
    && equals(a.relatedInformation,
              b.relatedInformation,
              DiagnosticRelatedInformation.isEqual);
}

Visual Studio Code

V7001 The operands of the '||' operator are equivalent. copilotcliPromptResolver.ts 136


....
// Notebooks are not supported yet.
if (URI.isUri(variableRef.value)) {
  if (await this.ignoreService.isCopilotIgnored(variableRef.value)) {
    return;
  }
  if (
    variableRef.value.scheme === Schemas.vscodeNotebookCellOutput
    || variableRef.value.scheme === Schemas.vscodeNotebookCellOutput      // <=
  ) {
    return;
  }
  ....
  validReferences.push(variableRef);
  fileFolderReferences.push(variableRef);
  return;
}
....

Visual Studio Code

V7001 The operands of the '||' operator in the 'response.statusText || response.statusText' expression are equivalent. chatMLFetcher.ts 1641


....
if (   response.status === 401
    && text.includes('authorize_url')
    && jsonData?.authorize_url
) {
  return {
    type: FetchResponseKind.Failed,
    modelRequestId: modelRequestIdObj,
    failKind: ChatFailKind.AgentUnauthorized,
    reason: response.statusText || response.statusText,         // <=
    data: jsonData
  };
}
....

Visual Studio Code

V7001 The operands of the '&&' operator are equivalent. renameSymbolProcessor.ts 141


....
if (gapOriginalLength > 0) {
  const gapStartOffset =
    nesOffset + lastChange.originalStart + lastChange.originalLength;
  const gapStartPos = textModel.getPositionAt(gapStartOffset);
  const wordRange = textModel.getWordAtPosition(gapStartPos);
  if (wordRange) {
    const wordStartOffset =
      textModel.getOffsetAt(
        new Position(gapStartPos.lineNumber, wordRange.startColumn));
    const wordEndOffset =
      textModel.getOffsetAt(
        new Position(gapStartPos.lineNumber, wordRange.endColumn));
    const gapEndOffset = gapStartOffset + gapOriginalLength;
    if (wordStartOffset <= gapStartOffset && gapEndOffset <= wordEndOffset
        && wordStartOffset <= gapEndOffset
        && gapEndOffset <= wordEndOffset) {                              // <=
      lastChange.originalLength =
          (change.originalStart + change.originalLength)
            - lastChange.originalStart;
      lastChange.modifiedLength =
          (change.modifiedStart + change.modifiedLength)
            - lastChange.modifiedStart;
      continue;
    }
  }
}
....

Visual Studio Code

V7001 The operands of the '&&' operator in the 'lastValueAtPosition !== undefined && lastValueAtPosition !== undefined' expression are equivalent. editorTextPropertySignalsContribution.ts 152


....
let lastValueAtPosition: boolean | undefined = undefined;
let lastValueOnLine: boolean | undefined = undefined;
timeouts.add(autorun(reader => {
  const newValueAtPosition =
          s.source.isPresentAtPosition(args.position, reader);
  const newValueOnLine =
          s.source.isPresentOnLine(args.position.lineNumber, reader);
  if (   lastValueAtPosition !== undefined
      && lastValueAtPosition !== undefined) {                            // <=
    if (!lastValueAtPosition && newValueAtPosition) {
      trigger(s.property, s.source, 'positional');
    }
    if (!lastValueOnLine && newValueOnLine) {
      trigger(s.property, s.source, 'line');
    }
  }
  lastValueAtPosition = newValueAtPosition;
  lastValueOnLine = newValueOnLine;
}));
....

jQuery

V7001 The operands of the '||' operator are equivalent. gh-1764-fullscreen.js 13


var fullscreenSupported = document.exitFullscreen ||   // <=
  document.exitFullscreen ||                           // <=
  document.msExitFullscreen ||
  document.mozCancelFullScreen ||
  document.webkitExitFullscreen;

ESLint

V7001 The operands of the '&&' operator are equivalent. space-unary-ops.js 109


/**
* Check if the node is the first "!" in a "!!" convert to Boolean expression
* @param {ASTnode} node AST node
* @returns {boolean} Whether or not the node is first "!" in "!!"
*/
function isFirstBangInBangBangExpression(node) {
  return (
    node &&
    node.type === "UnaryExpression" &&
    node.argument.operator === "!" &&            // <=
    node.argument &&
    node.argument.type === "UnaryExpression" &&
    node.argument.operator === "!"               // <=
  );
}

Visual Studio Code

V7001 The operands of the '===' operator are equivalent. uriIdentityService.ts 63


const oldIgnorePathCasingValue = schemeIgnoresPathCasingCache.get(e.scheme);
if (oldIgnorePathCasingValue === undefined) {
  return;
}
schemeIgnoresPathCasingCache.delete(e.scheme);
const newIgnorePathCasingValue = ignorePathCasing(URI.from(....);
if (newIgnorePathCasingValue === newIgnorePathCasingValue) {        // <=
  return;
}
....