Skip to content

Enable & fix inspection: equals() called on enum value #2819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 3, 2021
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
1 change: 1 addition & 0 deletions .idea/inspectionProfiles/AWS_Java_SDK_2_0.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class AddOperations {
}

private static boolean isAuthenticated(Operation op) {
return op.getAuthtype() == null || !op.getAuthtype().equals(AuthType.NONE);
return op.getAuthtype() == null || op.getAuthtype() != AuthType.NONE;
}

private static String getOperationDocumentation(final Output output, final Shape outputShape) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,6 @@ private String protocolFactoryLiteral(IntermediateModel model, OperationModel op
}

private boolean isRestJson(IntermediateModel model) {
return Protocol.REST_JSON.equals(model.getMetadata().getProtocol());
return model.getMetadata().getProtocol() == Protocol.REST_JSON;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ default CodeBlock streamingMarshallerCode(IntermediateModel model, OperationMode
builder.add(".requiresLength(true)");
}

if (AuthType.V4_UNSIGNED_BODY.equals(opModel.getAuthType())) {
if (opModel.getAuthType() == AuthType.V4_UNSIGNED_BODY) {
builder.add(".transferEncoding(true)");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ private String addUserAgentSuffix(StringBuilder userAgent, SdkClientConfiguratio
}

private String clientName(ClientType clientType) {
if (clientType.equals(ClientType.SYNC)) {
if (clientType == ClientType.SYNC) {
return clientConfig.option(SdkClientOption.SYNC_HTTP_CLIENT).clientName();
}

if (clientType.equals(ClientType.ASYNC)) {
if (clientType == ClientType.ASYNC) {
return clientConfig.option(SdkClientOption.ASYNC_HTTP_CLIENT).clientName();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private boolean tryConfigurePipeline() {
}

pipeline.addLast(LastHttpContentHandler.create());
if (Protocol.HTTP2.equals(protocol)) {
if (protocol == Protocol.HTTP2) {
pipeline.addLast(FlushOnReadHandler.getInstance());
}
pipeline.addLast(new HttpStreamsClientHandler());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void onSubscribe(Subscription subscription) {

private Subscription resolveSubscription(Subscription subscription) {
// For HTTP2 we send a RST_STREAM frame on cancel to stop the service from sending more data
if (Protocol.HTTP2.equals(ChannelAttributeKey.getProtocolNow(channelContext.channel()))) {
if (ChannelAttributeKey.getProtocolNow(channelContext.channel()) == Protocol.HTTP2) {
return new Http2ResetSendingSubscription(channelContext, subscription);
} else {
return subscription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public SslContext sslContext() {
* /SslUtils.java
*/
private List<String> getCiphers() {
return protocol.equals(Protocol.HTTP2) ? Http2SecurityUtil.CIPHERS : null;
return protocol == Protocol.HTTP2 ? Http2SecurityUtil.CIPHERS : null;
}

private TrustManagerFactory getTrustManager(NettyConfiguration configuration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private static class VersionAttribute implements StaticAttributeTag {
@Override
public Consumer<StaticTableMetadata.Builder> modifyMetadata(String attributeName,
AttributeValueType attributeValueType) {
if (!AttributeValueType.N.equals(attributeValueType)) {
if (attributeValueType != AttributeValueType.N) {
throw new IllegalArgumentException(String.format(
"Attribute '%s' of type %s is not a suitable type to be used as a version attribute. Only type 'N' " +
"is supported.", attributeName, attributeValueType.name()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public Builder addIndexSortKey(String indexName, String attributeName, Attribute
public Builder markAttributeAsKey(String attributeName, AttributeValueType attributeValueType) {
KeyAttributeMetadata existing = keyAttributes.get(attributeName);

if (existing != null && !existing.attributeValueType().equals(attributeValueType)) {
if (existing != null && existing.attributeValueType() != attributeValueType) {
throw new IllegalArgumentException("Attempt to mark an attribute as a key with a different "
+ "AttributeValueType than one that has already been recorded.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ public void deliverData(ByteBuffer byteBuffer) {

private void notifyErrorIfNeeded(Subscriber<? super ByteBuffer> subscriber) {
Event event = buffer.peek();
if (event != null && event.type().equals(EventType.ERROR)) {
if (event != null && event.type() == EventType.ERROR) {
isDone = true;
subscriber.onError(((ErrorEvent) event).error());
}
}

private boolean isTerminalEvent(Event event) {
return event.type().equals(EventType.ERROR) ||
event.type().equals(EventType.COMPLETE) ||
event.type().equals(EventType.CANCEL);
return event.type() == EventType.ERROR ||
event.type() == EventType.COMPLETE ||
event.type() == EventType.CANCEL;
}

private void handleTerminalEvent(Event event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static boolean shouldRecordChecksum(SdkRequest sdkRequest,

ClientType actualClientType = executionAttributes.getAttribute(SdkExecutionAttribute.CLIENT_TYPE);

if (!expectedClientType.equals(actualClientType)) {
if (expectedClientType != actualClientType) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class PayloadSigningInterceptor implements ExecutionInterceptor {
public Optional<RequestBody> modifyHttpContent(Context.ModifyHttpRequest context,
ExecutionAttributes executionAttributes) {
executionAttributes.putAttribute(S3SignerExecutionAttribute.ENABLE_PAYLOAD_SIGNING, true);
if (!context.requestBody().isPresent() && context.httpRequest().method().equals(SdkHttpMethod.POST)) {
if (!context.requestBody().isPresent() && context.httpRequest().method() == SdkHttpMethod.POST) {
return Optional.of(RequestBody.fromBytes(new byte[0]));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private boolean validateBenchmarkParams(SdkBenchmarkParams current, SdkBenchmark
return true;
}

return Objects.equals(current.getMode(), baseline.getMode());
return current.getMode() == baseline.getMode();
}

private String serializeResult(List<SdkBenchmarkResult> currentData) {
Expand Down