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

V7018. The expression 'A || (A && B)' is redundant and always evaluates to 'A'.


Visual Studio Code

V7018 The expression 'prevLineEmptyOrIndented || (prevLineEmptyOrIndented && ...)' is redundant and always evaluates to 'prevLineEmptyOrIndented'. lightBulbWidget.ts 373


....
const lineCount = model.getLineCount();
const endLine = lineNumber === lineCount;
const prevLineEmptyOrIndented =
        lineNumber > 1 && isLineEmptyOrIndented(lineNumber - 1);
const nextLineEmptyOrIndented =
        !endLine && isLineEmptyOrIndented(lineNumber + 1);
const currLineEmptyOrIndented = isLineEmptyOrIndented(lineNumber);
const notEmpty = !nextLineEmptyOrIndented && !prevLineEmptyOrIndented;
// check above and below. if both are blocked, display lightbulb in the gutter.
if (!nextLineEmptyOrIndented && !prevLineEmptyOrIndented && !hasDecoration) {
  this._gutterState.set(....);
  this.renderGutterLightbub();
  return this.hide();
} else if (prevLineEmptyOrIndented || endLine ||
          (prevLineEmptyOrIndented && !currLineEmptyOrIndented)) {        // <=
    effectiveLineNumber -= 1;
}
....