Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class TestClustersPluginFuncTest extends AbstractGradleFuncTest {
}

boolean assertNoCustomDistro(String clusterName) {
assert !customDistroFolder(clusterName).exists()
assert customDistroFolder(clusterName).exists() == false
true
}

Expand Down
18 changes: 9 additions & 9 deletions buildSrc/src/main/resources/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,17 @@
</module>

<!-- Forbid using '!' for logical negations in favour of checking against 'false' explicitly. -->
<!-- This is disabled for now because there are many violations, hence the rule is reporting at the "warning" severity. -->
<!--
<!-- This is only reported in the IDE for now because there are many violations -->
<module name="DescendantToken">
<property name="id" value="BooleanNegation" />
<property name="tokens" value="EXPR"/>
<property name="limitedTokens" value="LNOT"/>
<property name="maximumNumber" value="0"/>
<property name="maximumDepth" value="1"/>
<message key="descendant.token.max" value="Do not negate boolean expressions with '!', but check explicitly with '== false' as it is more explicit"/>
<property name="id" value="BooleanNegation" />
<property name="tokens" value="EXPR"/>
<property name="limitedTokens" value="LNOT"/>
<property name="maximumNumber" value="0"/>
<property name="maximumDepth" value="2"/>
<message
key="descendant.token.max"
value="Do not negate boolean expressions with '!', but check explicitly with '== false' as it is more explicit"/>
</module>
-->

</module>
</module>
12 changes: 0 additions & 12 deletions buildSrc/src/main/resources/checkstyle_ide_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@
<!-- Checkstyle config by the `:configureIdeCheckstyle` task. -->

<module name="IdeFragment">
<!-- Forbid using '!' for logical negations in favour of checking against 'false' explicitly. -->
<!-- This is only reported in the IDE for now because there are many violations -->
<module name="DescendantToken">
<property name="id" value="BooleanNegation" />
<property name="tokens" value="EXPR"/>
<property name="limitedTokens" value="LNOT"/>
<property name="maximumNumber" value="0"/>
<property name="maximumDepth" value="2"/>
<message
key="descendant.token.max"
value="Do not negate boolean expressions with '!', but check explicitly with '== false' as it is more explicit"/>
</module>

<!-- See CONTRIBUTING.md for our guidelines on Javadoc -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public boolean bulkIndex(List<String> bulkData) {
} catch (ExecutionException e) {
throw new ElasticsearchException(e);
}
return !bulkResponse.hasFailures();
return bulkResponse.hasFailures() == false;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private static void assertEqualInstances(GetMappingsResponse expected, GetMappin
}

private Predicate<String> randomFieldsExcludeFilter() {
return field -> !field.equals(MAPPINGS.getPreferredName());
return field -> field.equals(MAPPINGS.getPreferredName()) == false;
}

public static MappingMetadata randomMappingMetadata() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected boolean supportsUnknownFields() {
@Override
protected Predicate<String> getRandomFieldsExcludeFilter() {
// allow unknown fields in root only
return field -> !field.isEmpty();
return field -> field.isEmpty() == false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public StandardHtmlStripAnalyzer() {
protected TokenStreamComponents createComponents(final String fieldName) {
final Tokenizer src = new StandardTokenizer();
TokenStream tok = new LowerCaseFilter(src);
if (!stopwords.isEmpty()) {
if (stopwords.isEmpty() == false) {
tok = new StopFilter(tok, stopwords);
}
return new TokenStreamComponents(src, tok);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public static MethodSignature fromDeclaration(MethodDeclaration declaration) {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof MethodSignature)) return false;
if ((o instanceof MethodSignature) == false) return false;
MethodSignature that = (MethodSignature) o;
return Objects.equals(name, that.name) &&
Objects.equals(parameterTypes, that.parameterTypes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private static char[] transcodeRemaining(final char prev, final char curr, final
}

// 5. H -> If previous or next is a non vowel, previous.
if (curr == 'H' && (!isVowel(prev) || !isVowel(next))) {
if (curr == 'H' && (isVowel(prev) == false || isVowel(next) == false)) {
return new char[]{prev};
}

Expand Down Expand Up @@ -192,7 +192,7 @@ public Nysiis(final boolean strict) {
*/
@Override
public Object encode(Object obj) throws EncoderException {
if (!(obj instanceof String)) {
if ((obj instanceof String) == false) {
throw new EncoderException("Parameter supplied to Nysiis encode is not of type java.lang.String");
}
return this.nysiis((String) obj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private void assertGetRequestsContainHeaders(String index) {
assertThat(getRequests, hasSize(greaterThan(0)));

for (RequestAndHeaders request : getRequests) {
if (!((GetRequest)request.request).index().equals(index)) {
if (((GetRequest)request.request).index().equals(index) == false) {
continue;
}
assertRequestContainsHeader(request.request, request.headers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1249,13 +1249,13 @@ public void testPredictWithNonEmptyBuckets() throws Exception {
}

private void assertValidIterators(Iterator expectedBucketIter, Iterator expectedCountsIter, Iterator expectedValuesIter) {
if (!expectedBucketIter.hasNext()) {
if (expectedBucketIter.hasNext() == false) {
fail("`expectedBucketIter` iterator ended before `actual` iterator, size mismatch");
}
if (!expectedCountsIter.hasNext()) {
if (expectedCountsIter.hasNext() == false) {
fail("`expectedCountsIter` iterator ended before `actual` iterator, size mismatch");
}
if (!expectedValuesIter.hasNext()) {
if (expectedValuesIter.hasNext() == false) {
fail("`expectedValuesIter` iterator ended before `actual` iterator, size mismatch");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ public CreateSnapshotRequest source(Map<String, Object> source) {
} else if (name.equals("partial")) {
partial(nodeBooleanValue(entry.getValue(), "partial"));
} else if (name.equals("settings")) {
if (!(entry.getValue() instanceof Map)) {
if ((entry.getValue() instanceof Map) == false) {
throw new IllegalArgumentException("malformed settings section, should indices an inner object");
}
settings((Map<String, Object>) entry.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ public RestoreSnapshotRequest source(Map<String, Object> source) {
} else if (name.equals("partial")) {
partial(nodeBooleanValue(entry.getValue(), "partial"));
} else if (name.equals("settings")) {
if (!(entry.getValue() instanceof Map)) {
if ((entry.getValue() instanceof Map) == false) {
throw new IllegalArgumentException("malformed settings section");
}
DEPRECATION_LOGGER.deprecate(DeprecationCategory.API, "RestoreSnapshotRequest#settings",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public CreateIndexRequest mapping(String type, Map<String, ?> source) {
throw new IllegalStateException("mappings for type \"" + type + "\" were already defined");
}
// wrap it in a type map if its not
if (source.size() != 1 || !source.containsKey(type)) {
if (source.size() != 1 || source.containsKey(type) == false) {
source = MapBuilder.<String, Object>newMapBuilder().put(type, source).map();
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected void masterOperation(final TypesExistsRequest request, final ClusterSt
}

for (String concreteIndex : concreteIndices) {
if (!state.metadata().hasConcreteIndex(concreteIndex)) {
if (state.metadata().hasConcreteIndex(concreteIndex) == false) {
listener.onResponse(new TypesExistsResponse(false));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public static GetIndexResponse fromXContent(XContentParser parser) throws IOExce
ensureExpectedToken(Token.START_OBJECT, parser.currentToken(), parser);
parser.nextToken();

while (!parser.isClosed()) {
while (parser.isClosed() == false) {
if (parser.currentToken() == Token.START_OBJECT) {
// we assume this is an index entry
String indexName = parser.currentName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected GetFieldMappingsResponse shardOperation(final GetFieldMappingsIndexReq
for (String type : typeIntersection) {
DocumentMapper documentMapper = indexService.mapperService().documentMapper(type);
Map<String, FieldMappingMetadata> fieldMapping = findFieldMappingsByType(fieldPredicate, documentMapper, request);
if (!fieldMapping.isEmpty()) {
if (fieldMapping.isEmpty() == false) {
typeMappings.put(type, fieldMapping);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public PutIndexTemplateRequest mapping(String type, BytesReference source, XCont
*/
public PutIndexTemplateRequest mapping(String type, Map<String, Object> source) {
// wrap it in a type map if its not
if (source.size() != 1 || !source.containsKey(type)) {
if (source.size() != 1 || source.containsKey(type) == false) {
source = MapBuilder.<String, Object>newMapBuilder().put(type, source).map();
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public AutoCreateIndex(Settings settings,
IndexNameExpressionResolver resolver,
SystemIndices systemIndices) {
this.resolver = resolver;
dynamicMappingDisabled = !MapperService.INDEX_MAPPER_DYNAMIC_SETTING.get(settings);
dynamicMappingDisabled = MapperService.INDEX_MAPPER_DYNAMIC_SETTING.get(settings) == false;
this.systemIndices = systemIndices;
this.autoCreate = AUTO_CREATE_INDEX_SETTING.get(settings);
clusterSettings.addSettingsUpdateConsumer(AUTO_CREATE_INDEX_SETTING, this::setAutoCreate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public TransportClientNodesService addTransportAddresses(TransportAddress... tra
break;
}
}
if (!found) {
if (found == false) {
filtered.add(transportAddress);
}
}
Expand All @@ -199,7 +199,7 @@ public TransportClientNodesService removeTransportAddress(TransportAddress trans
}
List<DiscoveryNode> listNodesBuilder = new ArrayList<>();
for (DiscoveryNode otherNode : listedNodes) {
if (!otherNode.getAddress().equals(transportAddress)) {
if (otherNode.getAddress().equals(transportAddress) == false) {
listNodesBuilder.add(otherNode);
} else {
logger.debug("removing address [{}] from listed nodes", otherNode);
Expand All @@ -208,7 +208,7 @@ public TransportClientNodesService removeTransportAddress(TransportAddress trans
listedNodes = Collections.unmodifiableList(listNodesBuilder);
List<DiscoveryNode> nodesBuilder = new ArrayList<>();
for (DiscoveryNode otherNode : nodes) {
if (!otherNode.getAddress().equals(transportAddress)) {
if (otherNode.getAddress().equals(transportAddress) == false) {
nodesBuilder.add(otherNode);
} else {
logger.debug("disconnecting from node with address [{}]", otherNode);
Expand Down Expand Up @@ -359,7 +359,7 @@ public void sample() {
List<DiscoveryNode> establishNodeConnections(Set<DiscoveryNode> nodes) {
for (Iterator<DiscoveryNode> it = nodes.iterator(); it.hasNext(); ) {
DiscoveryNode node = it.next();
if (!transportService.nodeConnected(node)) {
if (transportService.nodeConnected(node) == false) {
try {
logger.trace("connecting to node [{}]", node);
transportService.connectToNode(node);
Expand All @@ -379,7 +379,7 @@ class ScheduledNodeSampler implements Runnable {
public void run() {
try {
nodesSampler.sample();
if (!closed) {
if (closed == false) {
nodesSamplerCancellable = threadPool.schedule(this, nodesSamplerInterval, ThreadPool.Names.GENERIC);
}
} catch (Exception e) {
Expand Down Expand Up @@ -407,7 +407,7 @@ public LivenessResponse read(StreamInput in) throws IOException {
TransportRequestOptions.of(pingTimeout, TransportRequestOptions.Type.STATE),
handler);
final LivenessResponse livenessResponse = handler.txGet();
if (!ignoreClusterName && !clusterName.equals(livenessResponse.getClusterName())) {
if (ignoreClusterName == false && clusterName.equals(livenessResponse.getClusterName()) == false) {
logger.warn("node {} not part of the cluster {}, ignoring...", listedNode, clusterName);
newFilteredNodes.add(listedNode);
} else {
Expand Down Expand Up @@ -536,7 +536,7 @@ public void handleException(TransportException e) {
HashSet<DiscoveryNode> newNodes = new HashSet<>();
HashSet<DiscoveryNode> newFilteredNodes = new HashSet<>();
for (Map.Entry<DiscoveryNode, ClusterStateResponse> entry : clusterStateResponses.entrySet()) {
if (!ignoreClusterName && !clusterName.equals(entry.getValue().getClusterName())) {
if (ignoreClusterName == false && clusterName.equals(entry.getValue().getClusterName()) == false) {
logger.warn("node {} not part of the cluster {}, ignoring...",
entry.getValue().getState().nodes().getLocalNode(), clusterName);
newFilteredNodes.add(entry.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ private static void toInnerXContent(IndexTemplateMetadata indexTemplateMetadata,
if (includeTypeName == false) {
Map<String, Object> documentMapping = null;
for (ObjectObjectCursor<String, CompressedXContent> cursor : indexTemplateMetadata.mappings()) {
if (!cursor.key.equals(MapperService.DEFAULT_MAPPING)) {
if (cursor.key.equals(MapperService.DEFAULT_MAPPING) == false) {
assert documentMapping == null;
Map<String, Object> mapping = XContentHelper.convertToMap(cursor.value.uncompressed(), true).v2();
documentMapping = reduceMapping(cursor.key, mapping);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public boolean hasAliases(final String[] aliases, String[] concreteIndices) {
filteredValues.add(value);
}
}
if (!filteredValues.isEmpty()) {
if (filteredValues.isEmpty() == false) {
return true;
}
}
Expand Down Expand Up @@ -435,7 +435,7 @@ public ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetadata>> findM
filteredMappings.put(cursor.key, filterFields(cursor.value, fieldPredicate));
}
}
if (!filteredMappings.isEmpty()) {
if (filteredMappings.isEmpty() == false) {
indexMapBuilder.put(index, filteredMappings.build());
}
}
Expand Down Expand Up @@ -616,7 +616,7 @@ public String resolveWriteIndexRouting(@Nullable String routing, String aliasOrI
+ aliasMd.getIndexRouting() + "] that resolved to several routing values, rejecting operation");
}
if (routing != null) {
if (!routing.equals(aliasMd.indexRouting())) {
if (routing.equals(aliasMd.indexRouting()) == false) {
throw new IllegalArgumentException("Alias [" + aliasOrIndex + "] has index routing associated with it ["
+ aliasMd.indexRouting() + "], and was provided with routing value [" + routing + "], rejecting operation");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private boolean refreshIndexMapping(IndexService indexService, IndexMetadata.Bui
mapperService.documentMapper(MapperService.DEFAULT_MAPPING))) {
if (mapper != null) {
final String type = mapper.type();
if (!mapper.mappingSource().equals(builder.mapping(type).source())) {
if (mapper.mappingSource().equals(builder.mapping(type).source()) == false) {
updatedTypes.add(type);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public T retrieve(String[] path, int index, Map<String, String> params, TrieMatc
}

T nodeValue = node.retrieve(path, index + 1, params, trieMatchingMode);
if (nodeValue == null && !usedWildcard && trieMatchingMode != TrieMatchingMode.EXPLICIT_NODES_ONLY) {
if (nodeValue == null && usedWildcard == false && trieMatchingMode != TrieMatchingMode.EXPLICIT_NODES_ONLY) {
node = children.get(wildcard);
if (node != null) {
put(params, node, token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static <T> Set<T> difference(Set<T> left, Set<T> right) {
public static <T> SortedSet<T> sortedDifference(Set<T> left, Set<T> right) {
Objects.requireNonNull(left);
Objects.requireNonNull(right);
return left.stream().filter(k -> !right.contains(k)).collect(new SortedSetCollector<>());
return left.stream().filter(k -> right.contains(k) == false).collect(new SortedSetCollector<>());
}

private static class SortedSetCollector<T> implements Collector<T, SortedSet<T>, SortedSet<T>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,17 @@ private List<DiscoveryNode> sortedMasterNodes(Iterable<DiscoveryNode> nodes) {
return null;
}
// clean non master nodes
possibleNodes.removeIf(node -> !node.isMasterNode());
possibleNodes.removeIf(node -> node.isMasterNode() == false);
CollectionUtil.introSort(possibleNodes, ElectMasterService::compareNodes);
return possibleNodes;
}

/** master nodes go before other nodes, with a secondary sort by id **/
private static int compareNodes(DiscoveryNode o1, DiscoveryNode o2) {
if (o1.isMasterNode() && !o2.isMasterNode()) {
if (o1.isMasterNode() && o2.isMasterNode() == false) {
return -1;
}
if (!o1.isMasterNode() && o2.isMasterNode()) {
if (o1.isMasterNode() == false && o2.isMasterNode()) {
return 1;
}
return o1.getId().compareTo(o2.getId());
Expand Down
Loading