Examples of errors detected by the V6001 diagnostic
V6001. There are identical sub-expressions to the left and to the right of the 'foo' operator.
LanguageTool
V6001 There are identical sub-expressions 'inflectionCase.equals("jar")' to the left and to the right of the '||' operator. ArabicNumbersWords.java 215
private static String getDigitHundredJarStatus( int digit, String inflectionCase ) { if (inflectionCase.equals("jar") || inflectionCase.equals("jar")) { // <= return ArabicNumbersWordsConstants .arabicJarHundreds.get(digit); } return ArabicNumbersWordsConstants .arabicHundreds.get(digit); } WorldWind Java
V6001 There are identical sub-expressions 'MGRS.getLatitude().degrees != 0' to the left and to the right of the '||' operator. GoToCoordinatePanel.java 185
private static LatLon computeLatLonFromString(String coordString, Globe globe) { .... MGRSCoord MGRS = MGRSCoord.fromString(coordString, globe); if (MGRS.getLatitude().degrees != 0 || MGRS.getLatitude().degrees != 0) // <= { lat = MGRS.getLatitude(); lon = MGRS.getLongitude(); } else return null; .... } Elasticsearch
V6001 There are identical sub-expressions 'commitAfter' to the left and to the right of the '%' operator. SecurityIndexReaderWrapperIntegrationTests.java 157
public void testDLS() throws Exception { .... int numDocs = scaledRandomIntBetween(32, 128); int commitAfter = scaledRandomIntBetween(1, numDocs); .... for (int doc = 1; doc <= numDocs; doc++) { .... if (doc % 11 == 0) { iw.deleteDocuments(new Term("id", id)); } else { if (commitAfter % commitAfter == 0) { // <= iw.commit(); } valuesHitCount[valueIndex]++; } } .... } Elasticsearch
V6001 There are identical sub-expressions 'stallTimeSeconds' to the left and to the right of the '==' operator. IndexError.java 147
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; IndexError that = (IndexError) o; return indexName.equals(that.indexName) && Arrays.equals(shardIds, that.shardIds) && errorType == that.errorType && message.equals(that.message) && stallTimeSeconds == stallTimeSeconds; // <= } Elasticsearch
V6001 There are identical sub-expressions 'isMissingEventFilter' to the left and to the right of the '==' operator. KeyedFilter.java 116
@Override public boolean equals(Object obj) { .... KeyedFilter other = (KeyedFilter) obj; return Objects.equals(keys, other.keys) && Objects.equals(timestamp, other.timestamp) && Objects.equals(tiebreaker, other.tiebreaker) && Objects.equals(child(), other.child()) && isMissingEventFilter == isMissingEventFilter; // <= } CustomNPC+
V6001 There are identical sub-expressions 'startIndex' to the left and to the right of the '==' operator. ScriptDBCPlayer.java 289
public String bonusAttribute(....) { .... int startIndex = -1; boolean number = false; try { startIndex = Integer.parseInt(bonusID); number = true; } catch (Exception var34) { number = false; } for (startIndex = 0; startIndex < bonuses.length; ++startIndex) { .... if (number && startIndex == startIndex || // <= !number && bonusValues[startIndex][0].equals(bonusID) ) { noNBTText = bonusValues[startIndex][0] + ";" + bonusValueString; bonuses[startIndex] = ""; bonuses[startIndex] = noNBTText; .... break; } } .... } CustomNPC+
V6001 There are identical sub-expressions 'npc.posX == 0' to the left and to the right of the '&&' operator. LinkedNpcController.java 123
public void loadNpcData(EntityNPCInterface npc) { if (npc.linkedName.isEmpty()) return; LinkedData data = getData(npc.linkedName); if (data == null) { npc.linkedLast = 0; npc.linkedName = ""; npc.linkedData = null; } else { npc.linkedData = data; if(npc.posX == 0 && npc.posY == 0 && npc.posX == 0) // <= return; npc.linkedLast = data.time; List<int[]> points = npc.ai.getMovingPath(); NBTTagCompound compound = NBTTags.NBTMerge(readNpcData(npc), data.data); npc.display.readToNBT(compound); .... } } Apache Kafka
V6001 There are identical sub-expressions 'keyFrom == null' to the left and to the right of the '&&' operator. ReadOnlyWindowStoreStub.java 271, ReadOnlyWindowStoreStub.java 271
public KeyValueIterator<Windowed<K>, V> fetch( K keyFrom, K keyTo, Instant timeFrom, Instant timeTo) { .... NavigableMap<K, V> kvMap = data.get(now); if (kvMap != null) { NavigableMap<K, V> kvSubMap; if (keyFrom == null && keyFrom == null) { // <= kvSubMap = kvMap; } else if (keyFrom == null) { kvSubMap = kvMap.headMap(keyTo, true); } else if (keyTo == null) { kvSubMap = kvMap.tailMap(keyFrom, true); } else { // keyFrom != null and KeyTo != null kvSubMap = kvMap.subMap(keyFrom, true, keyTo, true); } } .... } Apache Kafka
V6001 There are identical sub-expressions 'keyFrom == null' to the left and to the right of the '&&' operator. ReadOnlyWindowStoreStub.java 327, ReadOnlyWindowStoreStub.java 327
@Override public KeyValueIterator<Windowed<K>, V> backwardFetch( K keyFrom, K keyTo, Instant timeFrom, Instant timeTo) { .... if (keyFrom == null && keyFrom == null) { // <= kvSubMap = kvMap; } else if (keyFrom == null) { kvSubMap = kvMap.headMap(keyTo, true); } else if (keyTo == null) { kvSubMap = kvMap.tailMap(keyFrom, true); } else { // keyFrom != null and KeyTo != null kvSubMap = kvMap.subMap(keyFrom, true, keyTo, true); } .... } NetBeans 21
V6001 There are identical sub-expressions 'i' to the left and to the right of the '^' operator. LayoutFeeder.java(3897)
private void mergeParallelInclusions(List<IncludeDesc> inclusions, IncludeDesc original, boolean preserveOriginal) { .... if (unifyGaps != null) { // unify resizability of the border gaps collected for individual inclusions for (LayoutInterval[] gaps : unifyGaps) { int preferredFixedSide = fixedSideGaps[LEADING] >= fixedSideGaps[TRAILING] ? LEADING : TRAILING; for (int i=LEADING; i <= TRAILING; i++) { if (LayoutInterval.canResize(gaps[i]) && !anyResizingNeighbor[i] && (anyResizingNeighbor[i^1] || preferredFixedSide == i)) { operations.setIntervalResizing(gaps[i], false); if (!LayoutInterval.canResize(gaps[i^1])) { operations.setIntervalResizing(gaps[i^i], true); // <= } break; } } } } } NetBeans 21
V6001 There are identical sub-expressions 'iDesc.index' to the left and to the right of the '==' operator. LayoutFeeder.java(3660)
private void mergeParallelInclusions(List<IncludeDesc> inclusions, IncludeDesc original, boolean preserveOriginal) { IncludeDesc best = null; .... // 2nd remove incompatible inclusions, move compatible ones to same level for (Iterator it=inclusions.iterator(); it.hasNext(); ) { IncludeDesc iDesc = (IncludeDesc) it.next(); if (iDesc != best) { if (!compatibleInclusions(iDesc, best, dimension)) { it.remove(); } else if (iDesc.parent == best.parent && iDesc.neighbor == best.neighbor && (iDesc.neighbor != null || iDesc.index == iDesc.index)) { // <= it.remove(); // same inclusion twice (detect for better robustness) } .... } .... } .... } NetBeans 21
V6001 There are identical sub-expressions 'myMaxIndex' to the left and to the right of the '>=' operator. FilteredListModel.java(319)
public Object getElementAt(int index) { .... int myMinIndex = getExternal (minIndex) + 1; // one after the index of the first non-1 index int myMaxIndex = getExternal (maxIndex); assert myMaxIndex >= myMaxIndex : "Must be greater"; // NOI18N .... } NetBeans 21
V6001 There are identical sub-expressions 'revision1.equals(SVNRevision.HEAD)' to the left and to the right of the '&&' operator. RevertModifications.java(387), RevertModifications.java(387)
private RevisionInterval getResortedRevisionInterval(SVNRevision revision1, SVNRevision revision2) { RevisionInterval ret; if(revision1.equals(SVNRevision.HEAD) && revision1.equals(SVNRevision.HEAD)) { .... } return ret; } NetBeans 21
V6001 There are identical sub-expressions 'entry1.getDateTime().getTime()' to the left and to the right of the '>' operator. HistoryDiffView.java(130)
private void refresh(Node[] newSelection) { .... if(entry1 != null && entry2 != null && file1 != null && file2 != null) { if(entry1.getDateTime().getTime() > entry1.getDateTime().getTime()) { refreshRevisionDiffPanel(entry1, entry2, file1, file2); } else { refreshRevisionDiffPanel(entry2, entry1, file2, file1); } return; } .... } IntelliJ IDEA Community Edition
V6001 There are identical sub-expressions 'StringUtil.isOctalDigit(myBuffer.charAt(i + 1))' to the left and to the right of the '&&' operator. JavaStringLiteralLexer.java(64), JavaStringLiteralLexer.java(64)
protected int locateUnicodeEscapeSequence(int start, int i) { .... if (StringUtil.isOctalDigit(c)) { if (i + 2 < myBufferEnd && StringUtil.isOctalDigit(myBuffer.charAt(i + 1)) && StringUtil.isOctalDigit(myBuffer.charAt(i + 1))) { return i + 3; } } .... } IntelliJ IDEA Community Edition
V6001 There are identical sub-expressions 'e1.isPopupTrigger()' to the left and to the right of the '==' operator. JBCefOsrComponent.java(459)
private boolean areHomogenous(MouseWheelEvent e1, MouseWheelEvent e2) { if (e1 == null || e2 == null) return false; double distance = ....; return e1.getComponent() == e2.getComponent() && e1.getID() == e2.getID() && e1.getModifiersEx() == e2.getModifiersEx() && e1.isPopupTrigger() == e1.isPopupTrigger() && // <= e1.getScrollType() == e2.getScrollType() && distance < TOLERANCE; } Rhino
V6001 There are identical sub-expressions 't2Docked' to the left and to the right of the '&&' operator. SwingGui.java(2718), SwingGui.java(2718)
class ContextWindow extends JPanel implements ActionListener { .... public ContextWindow(final SwingGui debugGui) { .... ComponentListener clistener = new ComponentListener() { boolean t2Docked = true; void check(Component comp) { .... if (leftDocked && t2Docked && rightDocked && t2Docked) { // <= // no change return; } t2Docked = rightDocked; // Further t2Docked is not used .... } .... }; .... } .... } ELKI
V6001 There are identical sub-expressions 'bounds[j + 1]' to the left and to the right of the '!=' operator. CLIQUEUnit.java(252)
private boolean checkDimensions(CLIQUEUnit other, int e) { for(int i = 0, j = 0; i < e; i++, j += 2) { if (dims[i] != other.dims[i] || bounds[j] != other.bounds[j] || bounds[j + 1] != bounds[j + 1]) { return false; } } return true; } Apache Flink
V6001 There are identical sub-expressions 'processedData' to the left and to the right of the '==' operator. CheckpointStatistics.java(229)
@Override public boolean equals(Object o) { .... CheckpointStatistics that = (CheckpointStatistics) o; return id == that.id && savepoint == that.savepoint && triggerTimestamp == that.triggerTimestamp && latestAckTimestamp == that.latestAckTimestamp && stateSize == that.stateSize && duration == that.duration && alignmentBuffered == that.alignmentBuffered && processedData == processedData && // <= persistedData == that.persistedData && numSubtasks == that.numSubtasks && numAckSubtasks == that.numAckSubtasks && status == that.status && Objects.equals(checkpointType, that.checkpointType) && Objects.equals( checkpointStatisticsPerTask, that.checkpointStatisticsPerTask); } Bouncy Castle
V6001 There are identical sub-expressions 'tag == PacketTags.SECRET_KEY' to the left and to the right of the '||' operator. PGPUtil.java(212), PGPUtil.java(212)
public static boolean isKeyRing(byte[] blob) throws IOException { BCPGInputStream bIn = new BCPGInputStream(new ByteArrayInputStream(blob)); int tag = bIn.nextPacketTag(); return tag == PacketTags.PUBLIC_KEY || tag == PacketTags.PUBLIC_SUBKEY || tag == PacketTags.SECRET_KEY || tag == PacketTags.SECRET_KEY; } Ghidra
V6001 There are identical sub-expressions 'newDataType.getLength()' to the left and to the right of the '>' operator. DataTypeSelectionEditor.java(366)
private boolean parseDataTypeTextEntry() throws InvalidDataTypeException { .... try { newDataType = parser.parse(selectionField.getText(), getDataTypeRootForCurrentText()); } catch (CancelledException e) { return false; } if (newDataType != null) { if (maxSize >= 0 && newDataType.getLength() > newDataType.getLength()) { // <= throw new InvalidDataTypeException("data-type larger than " + maxSize + " bytes"); } selectionField.setSelectedValue(newDataType); return true; } return false; } Apache Hadoop
V6001 There are identical sub-expressions 'this.bucketSize' to the left and to the right of the '%' operator. RollingWindow.java(79)
RollingWindow(int windowLenMs, int numBuckets) { buckets = new Bucket[numBuckets]; for (int i = 0; i < numBuckets; i++) { buckets[i] = new Bucket(); } this.windowLenMs = windowLenMs; this.bucketSize = windowLenMs / numBuckets; if (this.bucketSize % bucketSize != 0) { throw new IllegalArgumentException( "The bucket size in the rolling window is not integer: windowLenMs= " + windowLenMs + " numBuckets= " + numBuckets); } } Elasticsearch
V6001 There are identical sub-expressions 'tookInMillis' to the left and to the right of the '==' operator. TermVectorsResponse.java(152)
@Override public boolean equals(Object obj) { .... return index.equals(other.index) && type.equals(other.type) && Objects.equals(id, other.id) && docVersion == other.docVersion && found == other.found && tookInMillis == tookInMillis // <= && Objects.equals(termVectorList, other.termVectorList); } IntelliJ IDEA Community Edition
V6001 [CWE-570] There are identical sub-expressions 'LoadingOrder.BEFORE_STR_OLD.equalsIgnoreCase(str)' to the left and to the right of the '||' operator. Check lines: 127, 128. ExtensionOrderConverter.java 127
@NonNls public static final String BEFORE_STR_OLD = "before:"; @NonNls public static final String AFTER_STR_OLD = "after:"; private static boolean isBeforeOrAfterKeyword(String str, boolean trimKeyword) { return (trimKeyword ? LoadingOrder.BEFORE_STR.trim() : LoadingOrder.BEFORE_STR).equalsIgnoreCase(str) || (trimKeyword ? LoadingOrder.AFTER_STR.trim() : LoadingOrder.AFTER_STR).equalsIgnoreCase(str) || LoadingOrder.BEFORE_STR_OLD.equalsIgnoreCase(str) || // <= LoadingOrder.BEFORE_STR_OLD.equalsIgnoreCase(str); // <= } IntelliJ IDEA Community Edition
V6001 [CWE-571] There are identical sub-expressions '!StringUtil.endsWithChar(name,'"')' to the left and to the right of the '&&' operator. JsonNamesValidator.java 27
public synchronized boolean isIdentifier(@NotNull String name, final Project project) { if (!StringUtil.startsWithChar(name,'\'') && !StringUtil.startsWithChar(name,'\"')) { name = "\"" + name; } if (!StringUtil.endsWithChar(name,'"') && !StringUtil.endsWithChar(name,'\"')) { name += "\""; } .... }