Мы используем куки, чтобы пользоваться сайтом было удобно.
Хорошо
to the top
close form

Заполните форму в два простых шага ниже:

Ваши контактные данные:

Шаг 1
Поздравляем! У вас есть промокод!

Тип желаемой лицензии:

Шаг 2
Team license
Enterprise license
** Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности
close form
Запросите информацию о ценах
Новая лицензия
Продление лицензии
--Выберите валюту--
USD
EUR
RUB
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
Бесплатная лицензия PVS‑Studio для специалистов Microsoft MVP
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
Для получения лицензии для вашего открытого
проекта заполните, пожалуйста, эту форму
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
Мне интересно попробовать плагин на:
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
check circle
Ваше сообщение отправлено.

Мы ответим вам на


Если вы так и не получили ответ, пожалуйста, проверьте, отфильтровано ли письмо в одну из следующих стандартных папок:

  • Промоакции
  • Оповещения
  • Спам

Вебинар: Парсим С++ - 25.10

>
>
>
Примеры ошибок, обнаруженных с помощью …

Примеры ошибок, обнаруженных с помощью диагностики V6007

V6007. Expression is always true/false.


IntelliJ IDEA Community Edition

V6007 [CWE-571] Expression 'i < endOffset' is always true. EnterAfterJavadocTagHandler.java 183


static Context parse(....) {
  ....
  for (int i = offset; i < endOffset; i++) {
    char c = text.charAt(i);
    if (c == '<' && i < endOffset && text.charAt(i + 1) == '/'
        && startTag != null
        && CharArrayUtil.regionMatches(text, i + 2, endOffset, startTag))
    {
      endTagStartOffset = i;
      break;
    }
  }
  ....
}

IntelliJ IDEA Community Edition

V6007 [CWE-570] Expression 'i == exampleUsages.length' is always false. IntentionDescriptionPanel.java 192


private static void showUsages(....)
{
  ....
  for (int i = 0; i < exampleUsages.length; i++) {
    final TextDescriptor exampleUsage = exampleUsages[i];
    final String name = exampleUsage.getFileName();
    final FileTypeManagerEx fileTypeManager = FileTypeManagerEx.getInstanceEx();
    final String extension = fileTypeManager.getExtension(name);
    final FileType fileType = fileTypeManager.getFileTypeByExtension(extension);

    IntentionUsagePanel usagePanel;
    if (reuse) {
      usagePanel = (IntentionUsagePanel)panel.getComponent(i);
    }
    else {
      usagePanel = new IntentionUsagePanel();
      usagePanels.add(usagePanel);
    }
    usagePanel.reset(exampleUsage.getText(), fileType);

    if (!reuse) {
      if (i == exampleUsages.length) {                        // <=
        gb.gridwidth = GridBagConstraints.REMAINDER;
      }
      panel.add(usagePanel, gb);
      gb.gridx++;
    }
  }
  ....
}

IntelliJ IDEA Community Edition

V6007 [CWE-571] Expression 'buffer.length() > 0' is always true. DeleteUtil.java 62


public static String generateWarningMessage(....)
{
  ....
  if (buffer.length() > 0) {
    if (buffer.length() > 0) {
      buffer.append(" ").append(
        IdeBundle.message("prompt.delete.and")).append(" ");
    }
  }
  ....
}

IntelliJ IDEA Community Edition

V6007 [CWE-571] Expression 'index >= 0' is always true. Updater.java 184


public int findPreviousIndex(int current) {
  int count = myPainter.getErrorStripeCount();
  int foundIndex = -1;
  int foundLayer = 0;
  if (0 <= current && current < count) {
    current--;
    for (int index = count - 1; index >= 0; index++) {        // <=
      int layer = getLayer(index);
      if (layer > foundLayer) {
        foundIndex = index;
        foundLayer = layer;
      }
    }
  ....
}

IntelliJ IDEA Community Edition

V6007 [CWE-570] Expression '"0".equals(text)' is always false. ConvertIntegerToDecimalPredicate.java 46


public boolean satisfiedBy(@NotNull PsiElement element) {
  ....
  @NonNls final String text = expression.getText().replaceAll("_", "");
  if (text == null || text.length() < 2) {
    return false;
  }
  if ("0".equals(text) || "0L".equals(text) || "0l".equals(text)) {
    return false;
  }
  return text.charAt(0) == '0';
}

SpotBugs

V6007 [CWE-571] Expression 'count < 4' is always true. Util.java 394


public static String getXMLType(@WillNotClose InputStream in) throws IOException
{
  ....
  String s;
  int count = 0;
  while (count < 4) {
    s = r.readLine();
    if (s == null) {
      break;
    }
    Matcher m = tag.matcher(s);
    if (m.find()) {
      return m.group(1);
    }
  }
  throw new IOException("Didn't find xml tag");
  ....
}

SpotBugs

V6007 [CWE-570] Expression '"remove".equals(invokedMethodName)' is always false. FindUnrelatedTypesInGenericContainer.java 618


private void analyzeMethod(....) throws .... {
  ....
  if (invokedMethodName.startsWith("contains") ||
      "remove".equals(invokedMethodName)) {
  ....
  } else if ("get".equals(invokedMethodName) ||
             "remove".equals(invokedMethodName)) {
  ....
}

Bouncy Castle

V6007 [CWE-570] Expression 'c == '\r'' is always false. PEMUtil.java 38


private String readLine(InputStream in)
  throws IOException
{
  ....
  do
  {
    while (((c = in.read()) != '\r') && c != '\n' && (c >= 0))
    {
      if (c == '\r')
      {
        continue;
      }

      l.append((char)c);
    }
  }
  while (c >= 0 && l.length() == 0);
  ....
}

Bouncy Castle

V6007 [CWE-570] Expression '(b1 | b2) < 0' is always false. ArmoredInputStream.java 76


private static final byte[] decodingTable;

private int decode(
  int      in0,
  int      in1,
  int      in2,
  int      in3,
  int[]    out)
  throws IOException
{
  int    b1, b2, b3, b4;
  ....
  b1 = decodingTable[in0] & 0xff;
  b2 = decodingTable[in1] & 0xff;

  if ((b1 | b2) < 0)
  {
    throw new IOException("invalid armor");
  }
}

Bouncy Castle

V6007 [CWE-570] Expression 'j < numPassesKPG' is always false. McElieceKobaraImaiCipherTest.java 36


public void performTest()
  throws Exception
{
  int numPassesKPG = 0;   // TODO: this algorithm is broken
  int numPassesEncDec = 10;
  Random rand = new Random();
  byte[] mBytes;
  for (int j = 0; j < numPassesKPG; j++)
  ....
}

Elasticsearch

V6007 Expression 's.charAt(i) != '\t'' is always true. Cron.java(1223)


private static int findNextWhiteSpace(int i, String s) {
  for (; i < s.length() && (s.charAt(i) != ' ' || s.charAt(i) != '\t'); i++)
  {
      // intentionally empty
  }
  return i;
}

Elasticsearch

V6007 Expression 'remaining == 0' is always false. PemUtils.java(439)


private static byte[]
generateOpenSslKey(char[] password, byte[] salt, int keyLength)
{
  ....
  int copied = 0;
  int remaining;
  while (copied < keyLength) {
    remaining = keyLength - copied;
    ....
    copied += bytesToCopy;
    if (remaining == 0) {      // <=
        break;
    }
    ....
  }
  ....
}

Elasticsearch

V6007 Expression 'healthCheckDn.indexOf('=') > 0' is always false. ActiveDirectorySessionFactory.java(73)


ActiveDirectorySessionFactory(RealmConfig config,
                              SSLService sslService,
                              ThreadPool threadPool)
                              throws LDAPException
{
  super(....,
        () -> {
          if (....) {
              final String healthCheckDn = ....;
              if (healthCheckDn.isEmpty() &&
                  healthCheckDn.indexOf('=') > 0)
              {
                  return healthCheckDn;
              }
          }
          return ....;
        },
        ....);
  ....
}

Elasticsearch

V6007 Expression '(int)x < 0' is always false. BCrypt.java(429)


private static byte char64(char x) {
  if ((int)x < 0 || (int)x > index_64.length)
    return -1;
  return index_64[(int)x];
}

CUBA Platform

V6007 Expression 'StringUtils.isNotEmpty("handleTabKey")' is always true. SourceCodeEditorLoader.java(60)


@Override
public void loadComponent() {
  ....
  String handleTabKey = element.attributeValue("handleTabKey");
  if (StringUtils.isNotEmpty("handleTabKey")) {
    resultComponent.setHandleTabKey(Boolean.parseBoolean(handleTabKey));
  }
  ....
}

Similar errors can be found in some other places:

  • V6007 Expression 'StringUtils.isNotEmpty("editable")' is always true. AbstractTableLoader.java(596)

CUBA Platform

V6007 Expression 'previousMenuItemFlatIndex >= 0' is always true. CubaSideMenuWidget.java(328)


protected MenuItemWidget findNextMenuItem(MenuItemWidget currentItem) {
  List<MenuTreeNode> menuTree = buildVisibleTree(this);
  List<MenuItemWidget> menuItemWidgets = menuTreeToList(menuTree);

  int menuItemFlatIndex = menuItemWidgets.indexOf(currentItem);
  int previousMenuItemFlatIndex = menuItemFlatIndex + 1;
  if (previousMenuItemFlatIndex >= 0) {
      return menuItemWidgets.get(previousMenuItemFlatIndex);
  }
  return null;
}

CUBA Platform

V6007 Expression 'mask.charAt(i + offset) != placeHolder' is always true. DatePickerDocument.java(238)


private String calculateFormattedString(int offset, String text) .... {
  ....
  if ((mask.charAt(i + offset) == placeHolder)) {         // <=
    ....
  } else if ((mask.charAt(i + offset) != placeHolder) &&  // <=
             (Character.isDigit(text.charAt(i)))) {
    ....
  }
  ....
}

CUBA Platform

V6007 Expression 'connector == null' is always false. HTML5Support.java(169)


private boolean validate(NativeEvent event) {
  ....
  while (connector == null) {
    widget = widget.getParent();
    connector = Util.findConnectorFor(widget);
  }

  if (this.connector == connector) {
      return true;
  } else if (connector == null) {             // <=
      return false;
  } else if (connector.getWidget() instanceof VDDHasDropHandler) {
      return false;
  }
  return true;
}

Similar errors can be found in some other places:

  • V6007 Expression 'StringUtils.isBlank(strValue)' is always true. Param.java(818)

CUBA Platform

V6007 Expression 'needReload' is always false. WebAbstractTable.java(2702)


protected boolean handleSpecificVariables(Map<String, Object> variables) {
  boolean needReload = false;

  if (isUsePresentations() && presentations != null) {
    Presentations p = getPresentations();

    if (p.getCurrent() != null && p.isAutoSave(p.getCurrent())
        && needUpdatePresentation(variables)) {
      Element e = p.getSettings(p.getCurrent());
      saveSettings(e);
      p.setSettings(p.getCurrent(), e);
    }
  }
  return needReload;
}

Apache Hive

V6007 Expression 'key.startsWith("hplsql.")' is always true. Exec.java(675)


void initOptions()
{
  ....
  if (key == null || value == null || !key.startsWith("hplsql.")) { // <=
    continue;
  }
  else if (key.compareToIgnoreCase(Conf.CONN_DEFAULT) == 0) {
    ....
  }
  else if (key.startsWith("hplsql.conn.init.")) {
    ....
  }
  else if (key.startsWith(Conf.CONN_CONVERT)) {
    ....
  }
  else if (key.startsWith("hplsql.conn.")) {
   ....
  }
  else if (key.startsWith("hplsql.")) {                            // <=
   ....
  }
}

Apache Hive

V6007 Expression 'columnNameProperty.length() == 0' is always false. OrcRecordUpdater.java(238)


private static
TypeDescription getTypeDescriptionFromTableProperties(....)
{
  ....
  if (tableProperties != null) {
    final String columnNameProperty = ....;
    final String columnTypeProperty = ....;

    if (   !Strings.isNullOrEmpty(columnNameProperty)
        && !Strings.isNullOrEmpty(columnTypeProperty))
    {
      List<String> columnNames = columnNameProperty.length() == 0
                                 ? new ArrayList<String>()
                                 : ....;

      List<TypeInfo> columnTypes = columnTypeProperty.length() == 0
                                   ? new ArrayList<TypeInfo>()
                                   : ....;
      ....
      }
    }
  }
  ....
}

Apache Hive

V6007 Expression 'colOrScalar1.equals("Column")' is always false. GenVectorCode.java(3469)


private void
generateDateTimeArithmeticIntervalYearMonth(String[] tdesc) throws Exception
{
  ....
  String colOrScalar1 = tdesc[4];
  ....
  String colOrScalar2 = tdesc[6];
  ....
  if (colOrScalar1.equals("Col") && colOrScalar1.equals("Column"))    // <=
  {
    ....
  } else if (colOrScalar1.equals("Col") && colOrScalar1.equals("Scalar"))
  {
    ....
  } else if (colOrScalar1.equals("Scalar") && colOrScalar1.equals("Column"))
  {
    ....
  }
}

Similar errors can be found in some other places:

  • V6007 Expression 'colOrScalar1.equals("Scalar")' is always false. GenVectorCode.java(3475)
  • V6007 Expression 'colOrScalar1.equals("Column")' is always false. GenVectorCode.java(3486)
  • V6007 Expression 'characters == null' is always false. RandomTypeUtil.java(43)
  • And 4 additional diagnostic messages.

Apache Dubbo

V6007 Expression 'endKey[i] < 0xff' is always true. OptionUtil.java(32)


public static final ByteSequence prefixEndOf(ByteSequence prefix) {
  byte[] endKey = prefix.getBytes().clone();
  for (int i = endKey.length - 1; i >= 0; i--) {          // <=
    if (endKey[i] < 0xff) {
      endKey[i] = (byte) (endKey[i] + 1);
      return ByteSequence.from(Arrays.copyOf(endKey, i + 1));
    }
  }
  return ByteSequence.from(NO_PREFIX_END);
}

Apache Dubbo

V6007 Expression 'isPreferIPV6Address()' is always false. NetUtils.java(236)


private static Optional<InetAddress> toValidAddress(InetAddress address) {
  if (address instanceof Inet6Address) {
    Inet6Address v6Address = (Inet6Address) address;
    if (isPreferIPV6Address()) {
      return Optional.ofNullable(normalizeV6Address(v6Address));
    }
  }
  if (isValidV4Address(address)) {
    return Optional.of(address);
  }
  return Optional.empty();
}

static boolean isPreferIPV6Address() {
  boolean preferIpv6 = Boolean.getBoolean("java.net.preferIPv6Addresses");
  if (!preferIpv6) {
    return false;     // <=
  }
  return false;       // <=
}

Apache Dubbo

V6007 Expression '!mask[i].equals(ipAddress[i])' is always true. NetUtils.java(476)


public static boolean matchIpRange(....) throws UnknownHostException {
  ....
  for (int i = 0; i < mask.length; i++) {
    if ("*".equals(mask[i]) || mask[i].equals(ipAddress[i])) {   // <=
      continue;
    } else if (mask[i].contains("-")) {
       ....
    } else if (....) {
      continue;
    } else if (!mask[i].equals(ipAddress[i])) {      // <=
      return false;
    }
  }
  return true;
}

Apache Dubbo

V6007 Expression 'message.length > 0' is always true. DeprecatedTelnetCodec.java(302)


protected Object decode(.... , byte[] message) throws IOException {
  ....
  if (message == null || message.length == 0) {         // <=
    return NEED_MORE_INPUT;
  }
  ....
  // Here the variable message doesn't change!
  ....
  if (....) {
    String value = history.get(index);
    if (value != null) {
      byte[] b1 = value.getBytes();
      if (message != null && message.length > 0) {              // <=
        byte[] b2 = new byte[b1.length + message.length];
        System.arraycopy(b1, 0, b2, 0, b1.length);
        System.arraycopy(message, 0, b2, b1.length, message.length);
        message = b2;
      } else {
        message = b1;
      }
    }
  }
  ....
}

Similar errors can be found in some other places:

  • V6007 Expression 'message != null' is always true. DeprecatedTelnetCodec.java(302)

Apache Dubbo

V6007 Expression '!shouldExport()' is always false. ServiceConfig.java(371)


public synchronized void export() {
  checkAndUpdateSubConfigs();

  if (!shouldExport()) {                                     // <=
    return;
  }

  if (shouldDelay()) {
    ....
  } else {
    doExport();
}

private boolean shouldExport() {
  Boolean export = getExport();
  // default value is true
  return export == null ? true : export;
}
....
@Override
public Boolean getExport() {
  return (export == null && provider != null) ? provider.getExport() : export;
}

protected Boolean export;
....
public Boolean getExport() {
  return export;
}
....
public void setExport(Boolean export) {
  this.export = export;
}

@Override
public void build(T instance) {
....
  if (export != null) {
    instance.setExport(export);
  }
....
}

because of the uninitialized 'export' field, the setExport method is never executed, as a result getExport always returns null, which is why !shouldExport() is always false


Huawei Cloud

V6007 Expression 'firewallPolicyId == null' is always false. FirewallPolicyServiceImpl.java(125)


public FirewallPolicy
removeFirewallRuleFromPolicy(String firewallPolicyId,
                             String firewallRuleId)
{
  checkNotNull(firewallPolicyId);
  checkNotNull(firewallRuleId);
  checkState(!(firewallPolicyId == null && firewallRuleId == null),
  "Either a Firewall Policy or Firewall Rule identifier must be set");
  ....
}

Similar errors can be found in some other places:

  • V6007 Expression 'firewallRuleId == null' is always false. FirewallPolicyServiceImpl.java(125)

Huawei Cloud

V6007 Expression 'filteringParams != null' is always true. NetworkPolicyServiceImpl.java(60)


private Invocation<NetworkServicePolicies> buildInvocation(Map<String,
String> filteringParams)
{
  ....
  if (filteringParams == null) {
    return servicePoliciesInvocation;
  }
  if (filteringParams != null) {       // <=
    ....
  }
  return servicePoliciesInvocation;
}

Similar errors can be found in some other places:

  • V6007 Expression 'filteringParams != null' is always true. PolicyRuleServiceImpl.java(58)
  • V6007 Expression 'filteringParams != null' is always true. GroupServiceImpl.java(58)
  • V6007 Expression 'filteringParams != null' is always true. ExternalSegmentServiceImpl.java(57)
  • And 2 additional diagnostic messages.

Apache Hadoop

V6007 Expression 'byteAm < 0' is always false. DataWriter.java(322)


test
GenerateOutput writeSegment(long byteAm, OutputStream out)
    throws IOException {
  long headerLen = getHeaderLength();
  if (byteAm < headerLen) {
    // not enough bytes to write even the header
    return new GenerateOutput(0, 0);
  }
  // adjust for header length
  byteAm -= headerLen;
  if (byteAm < 0) {
    byteAm = 0;
  }
  WriteInfo header = writeHeader(out, byteAm);
  DataHasher hasher = new DataHasher(header.getHashValue());
  GenerateOutput pRes = writePieces(byteAm, 0, hasher, out);
  long bytesWritten = pRes.getBytesWritten() + header.getBytesWritten();
  long timeTaken = header.getTimeTaken() + pRes.getTimeTaken();
  return new GenerateOutput(bytesWritten, timeTaken);
}

Apache Hadoop

V6007 Expression 'children.size() > 0' is always true. Queue.java(347)


boolean isHierarchySameAs(Queue newState) {
  ....
  if (children == null || children.size() == 0) {
    ....
  }
  else if(children.size() > 0)
  {
    ....
  }
  ....
}

Ghidra

V6007 Expression 'data[i] != 0xFFFFFFFFL' is always true. GuidUtil.java(200)


public class GuidUtil {
  ....
  public static GuidInfo parseLine(...) {
    ....
    long[] data = new long[4];
    ....
    if (isOK(data)) {
      if (!hasVersion) {
        return new GuidInfo(guidString, name, guidType);
      }
      return new VersionedGuidInfo(guidString, version, name, guidType);
    }
    return null;
  }
  ....
  private static boolean isOK(long[] data) {
    for (int i = 0; i < data.length; i++) {
      if ((data[i] != 0) || (data[i] != 0xFFFFFFFFL)) { // <=
        return true;
      }
    }
    return false;
  }
  ....
}

Ghidra

V6007 Expression 'zeroLengthArray' is always false. PdbDataTypeParser.java(278)


private String parseArrayDimensions(String datatype,
                                    List<Integer> arrayDimensions) {
  String dataTypeName = datatype;
  boolean zeroLengthArray = false;
  while (dataTypeName.endsWith("]")) {
    if (zeroLengthArray) {                   // <=
      return null; // only last dimension may be 0
    }
    int rBracketPos = dataTypeName.lastIndexOf(']');
    int lBracketPos = dataTypeName.lastIndexOf('[');
    if (lBracketPos < 0) {
      return null;
    }
    int dimension;
    try {
      dimension = Integer.parseInt(dataTypeName.substring(lBracketPos + 1,
                                                          rBracketPos));
      if (dimension < 0) {
        return null; // invalid dimension
      }
    }
    catch (NumberFormatException e) {
      return null;
    }
    dataTypeName = dataTypeName.substring(0, lBracketPos).trim();
    arrayDimensions.add(dimension);
  }
  return dataTypeName;
}

Ghidra

V6007 Expression '((i + 1) % defaultGroupSizeSpace) == 0' is always true. ByteViewerLayoutModel.java(66)


void setFactorys(FieldFactory[] fieldFactorys,
                 DataFormatModel dataModel, int margin) {
  factorys = new FieldFactory[fieldFactorys.length];

  int x = margin;
  int defaultGroupSizeSpace = 1;
  for (int i = 0; i < factorys.length; i++) {
    factorys[i] = fieldFactorys[i];
    factorys[i].setStartX(x);
    x += factorys[i].getWidth();
    // add in space between groups
    if (((i + 1) % defaultGroupSizeSpace) == 0) { // <=
      x += margin * dataModel.getUnitDelimiterSize();
    }
  }
  width = x - margin * dataModel.getUnitDelimiterSize() + margin;
  layoutChanged();
}

Ghidra

V6007 Expression 'index >= 0' is always true. ExternalNamesTableModel.java(105)


public void setValueAt(Object aValue, int row, int column) {
  ....
  int index = indexOf(newName);
  if (index >= 0) {                  // <=
    Window window = tool.getActiveWindow();
    Msg.showInfo(getClass(), window, "Duplicate Name",
                 "Name already exists: " + newName);
    return;
  }

  ExternalPath path = paths.get(row);
  ....
}
private int indexOf(String name) {
  for (int i = 0; i < paths.size(); i++) {
    ExternalPath path = paths.get(i);
    if (path.getName().equals(name)) {
      return i;
    }
  }
  return 0;
}

XMage

V6007 Expression 'filter.getMessage().toLowerCase(Locale.ENGLISH).startsWith("Each ")' is always false. SetPowerToughnessAllEffect.java(107)


@Override
public String getText(Mode mode) {
  StringBuilder sb = new StringBuilder();
  ....
  if (filter.getMessage().toLowerCase(Locale.ENGLISH).startsWith("Each ")) {
    sb.append(" has base power and toughness ");
  } else {
    sb.append(" have base power and toughness ");
  }
  ....
  return sb.toString();
}

Similar errors can be found in some other places:

  • V6007 Expression 't.startsWith("-")' is always false. BoostSourceEffect.java(103)
  • V6007 Expression 'setNames.isEmpty()' is always false. DownloadPicturesService.java(300)
  • V6007 Expression 'existingBucketName == null' is always false. S3Uploader.java(23)
  • And 3 additional diagnostic messages.

WildFly

V6007 Expression 'poolStatsSize > 0' is always true. PooledConnectionFactoryStatisticsService.java(85)


@Override
public void start(StartContext context) throws StartException {
  ....
  if (poolStatsSize > 0) {
    if (registration != null) {
      if (poolStatsSize > 0) {
        ....
      }
    }
  }
}

Similar errors can be found in some other places:

  • V6007 Expression 'referralMode == null' is always false. DirContext.java(93)
  • V6007 Expression 'mBeanServer == null' is always true. WildFlyServerPlatform.java(82)
  • V6007 Expression 'result != null' is always true. New returns not-null reference. JarCheck.java(84)
  • And 1 additional diagnostic messages.

Bouncy Castle

V6007 Expression '!(nGroups < 8)' is always false. CBZip2OutputStream.java(753)


private void sendMTFValues() throws IOException {
    ....
    int nGroups;
    ....
    if (nMTF < 200) {
        nGroups = 2;
    } else if (nMTF < 600) {
        nGroups = 3;
    } else if (nMTF < 1200) {
        nGroups = 4;
    } else if (nMTF < 2400) {
        nGroups = 5;
    } else {
        nGroups = 6;
    }
    ....
    if (!(nGroups < 8)) {
        panic();
    }
}

Apache Flink

V6007 Expression 'input2.length > 0' is always true. Operator.java(283)


public static <T> Operator<T> createUnionCascade(Operator<T> input1,
                                                 Operator<T>... input2)
{
  if (input2 == null || input2.length == 0)
  {
    return input1;                                // <=
  }
  else if (input2.length == 1 && input1 == null)
  {
    return input2[0];
  }
  ....
  if (input1 != null)
  {
    ....
  }
  else if (input2.length > 0 && input2[0] != null) // <=
  {
    ....
  }
  else
  {
    ....
  }
}

Apache Flink

V6007 Expression 'slotSharingGroup == null' is always false. StreamGraphGenerator.java(510)


private <T> Collection<Integer> transformFeedback(...)
{
  ....
  String slotSharingGroup = determineSlotSharingGroup(null, allFeedbackIds);
  if (slotSharingGroup == null)
  {
    slotSharingGroup = "SlotSharingGroup-" + iterate.getId();
  }
  ....
}

public class StreamGraphGenerator
{
  ....
  public static final String DEFAULT_SLOT_SHARING_GROUP = "default";
  ....
  private String determineSlotSharingGroup(String specifiedGroup,
                                           Collection<Integer> inputIds)
  {
    if (specifiedGroup != null)
    {
      return specifiedGroup; // <= 1
    }
    else
    {
      String inputGroup = null;
      for (int id: inputIds)
      {
        String inputGroupCandidate = streamGraph.getSlotSharingGroup(id);
        if (inputGroup == null)
        {
          inputGroup = inputGroupCandidate;
        }
        else if (!inputGroup.equals(inputGroupCandidate))
        {
          return DEFAULT_SLOT_SHARING_GROUP; // <= 2
        }
      }
      return inputGroup == null
             ? DEFAULT_SLOT_SHARING_GROUP
             : inputGroup; // <= 3
    }
  }
  ....
}

Apache Flink

V6007 Expression 'currentCount <= lastEnd' is always true. CountSlidingWindowAssigner.java(75)


@Override
public Collection<CountWindow> assignWindows(....) throws IOException
{
  Long countValue = count.value();
  long currentCount = countValue == null ? 0L : countValue;
  count.update(currentCount + 1);
  long lastId = currentCount / windowSlide;
  long lastStart = lastId * windowSlide;
  long lastEnd = lastStart + windowSize - 1;
  List<CountWindow> windows = new ArrayList<>();
  while (lastId >= 0 &&
         lastStart <= currentCount &&
         currentCount <= lastEnd)
  {
    if (lastStart <= currentCount && currentCount <= lastEnd) // <=
    {
      windows.add(new CountWindow(lastId));
    }
    lastId--;
    lastStart -= windowSlide;
    lastEnd -= windowSlide;
  }
  return windows;
}

Similar errors can be found in some other places:

  • V6007 Expression 'lastStart <= currentCount' is always true. CountSlidingWindowAssigner.java(75)

Rhino

V6007 Expression 'power < 2' is always false. UintMap.java(39)


public class UintMap implements Serializable {
  ....
  // If true, enables consitency checks
  private static final boolean check = false;
  ....
  public UintMap(int initialCapacity) {
    if (initialCapacity < 0) Kit.codeBug();
    // Table grow when number of stored keys >= 3/4 of max capacity
    int minimalCapacity = initialCapacity * 4 / 3;
    int i;
    for (i = 2; (1 << i) < minimalCapacity; ++i) {}
    power = i;
    if (check && power < 2) Kit.codeBug();      // <=
  }
  ....
}

Rhino

V6007 Expression 'power < 2' is always false. ObjToIntMap.java(102)


public class ObjToIntMap implements Serializable {
  ....
  // If true, enables consitency checks
  private static final boolean check = false;
  ....
  public ObjToIntMap(int initialCapacity) {
    if (initialCapacity < 0) Kit.codeBug();
    // Table grow when number of stored keys >= 3/4 of max capacity
    int minimalCapacity = initialCapacity * 4 / 3;
    int i;
    for (i = 2; (1 << i) < minimalCapacity; ++i) {}
    power = i;
    if (check && power < 2) Kit.codeBug();      // <=
  }
  ....
}

Rhino

V6007 Expression '!BUG_369394_IS_VALID' is always true. XmlProcessor.java(288)


class XmlProcessor implements Serializable {
  ....
  private void addTextNodesToRemoveAndTrim(List<Node> toRemove, Node node) {
    if (node instanceof Text) {
      Text text = (Text) node;
      boolean BUG_369394_IS_VALID = false;
      if (!BUG_369394_IS_VALID) {                 // <=
        text.setData(text.getData().trim());
      } else {
        if (text.getData().trim().length() == 0) {
          text.setData("");
        }
      }
      if (text.getData().length() == 0) {
        toRemove.add(node);
      }
    }
    ....
  }
  ....
}

Rhino

V6007 Expression 'i < indentLevel' is always false. XmlProcessor.java(454)


class XmlProcessor implements Serializable {
  ....
  private boolean prettyPrint;
  ....
  private int prettyIndent;
  ....
  final String ecmaToXmlString(Node node) {
    // See ECMA 357 Section 10.2.1
    StringBuilder s = new StringBuilder();
    int indentLevel = 0;
    if (prettyPrint) {
      for (int i = 0; i < indentLevel; i++) { // <=
        s.append(' ');
      }
    }
    ....
  }
  ....
}

IntelliJ IDEA Community Edition

V6007 Expression '!nextStepButtonSelected' is always true. PopupListElementRenderer.java(330)


@Override
protected void customizeComponent(JList list, E value, boolean isSelected) {
    ....
    boolean nextStepButtonSelected = false; // <=
    ....
    myMnemonicLabel.setForeground(isSelected &&
                                  isSelectable &&
                                  !nextStepButtonSelected
                                  ? getSelectionForeground()
                                  : foreground);
    ....
    myShortcutLabel.setForeground(
      isSelected &&
      isSelectable &&
      !nextStepButtonSelected
      ? UIManager.getColor("MenuItem.acceleratorSelectionForeground")
      : UIManager.getColor("MenuItem.acceleratorForeground"));
    ....
    boolean selected = isSelected && isSelectable && !nextStepButtonSelected;

    setForegroundSelected(myValueLabel, selected);
    ....
}

Similar errors can be found in some other places:

  • V6007 Expression '!nextStepButtonSelected' is always true. PopupListElementRenderer.java(384)
  • V6007 Expression '!nextStepButtonSelected' is always true. PopupListElementRenderer.java(373)

NetBeans 21

V6007 Expression 'FoldUtilitiesImpl.PREF_CONTENT_PREVIEW.equals(FoldUtilitiesImpl.PREF_CONTENT_PREVIEW)' is always true. FoldOptionsPanel.java(177)


public void preferenceChange(PreferenceChangeEvent evt) {
  String k = evt == null ? null : evt.getKey();
  ....
  try {
    ....
    if (k == null || FoldUtilitiesImpl.PREF_CONTENT_PREVIEW.equals
                              (FoldUtilitiesImpl.PREF_CONTENT_PREVIEW)) {
      ....
    }
    ....
  }
  ....
}

NetBeans 21

V6007 Expression 'FoldUtilitiesImpl.PREF_CONTENT_SUMMARY.equals(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY)' is always true. FoldOptionsPanel.java(180)


public void preferenceChange(PreferenceChangeEvent evt) {
  String k = evt == null ? null : evt.getKey();
  ....
  try {
    ....
    if (k == null || FoldUtilitiesImpl.PREF_CONTENT_SUMMARY.equals
                              (FoldUtilitiesImpl.PREF_CONTENT_SUMMARY)) {
      ....
    }
    ....
  }
  ....
}

GeoServer

V6007 Expression 'cm == null' is always false. CatalogBuilder.java 1242


private GridSampleDimension[] getCoverageSampleDimensions(
    GridCoverage2DReader reader, Map<String, Serializable> customParameters)
    throws TransformException, IOException, Exception {
  ....
  ColorModel cm = imageLayout.getColorModel(null);
  if (cm == null) {                                                  // <=
    throw new Exception(
        "Unable to acquire test coverage and color model for format:"
            + format.getName());
  }
  SampleModel sm = imageLayout.getSampleModel(null);
  if (cm == null) {                                                  // <=
    throw new Exception(
        "Unable to acquire test coverage and sample model for format:"
            + format.getName());
  }
  ....
}

GeoServer

V6007 Expression 'sortOrder != null' is always true. DefaultCatalogFacade.java 1138


@Override
public <T extends CatalogInfo> CloseableIterator<T> list(
    final Class<T> of,
    final Filter filter,
    @Nullable Integer offset,
    @Nullable Integer count,
    @Nullable SortBy... sortOrder) {

  if (sortOrder != null) {                                // <=
    for (SortBy so : sortOrder) {
      if (sortOrder != null &&                            // <=
          !canSort(of, so.getPropertyName().getPropertyName())) {
        throw new IllegalArgumentException(
            "Can't sort objects of type "
                + of.getName()
                + " by "
                + so.getPropertyName());
      }
    }
  }
  ....
}

GeoServer

V6007 Expression '"Not a GetCapabilitiesType: " + o != null' is always true. WCS20GetCapabilitiesTransformer.java 183


@Override
public void encode(Object o) throws IllegalArgumentException {
  if (!(o instanceof GetCapabilitiesType)) {
    throw new IllegalArgumentException(
        "Not a GetCapabilitiesType: " + o != null ? o.toString() : "null");
  }
  ....
}

The result of "Not a GetCapabilitiesType: " + o will be compared to null, since != will evaluate expressions to the left and to the right before the comparison.