Skip to content

Commit

Permalink
Enable experimental checks and fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
connorworley committed Nov 3, 2024
1 parent 82df9d8 commit d64e4d9
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 18 deletions.
148 changes: 142 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,155 @@ subprojects {

tasks.withType(JavaCompile).configureEach {
dependencies {
errorprone "com.uber.nullaway:nullaway:latest.release"
errorprone "com.google.errorprone:error_prone_core:latest.release"
errorprone "com.uber.nullaway:nullaway:0.12.1"
errorprone "com.google.errorprone:error_prone_core:2.35.1"
}

options.errorprone {
check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.WARN)
option("NullAway:AnnotatedPackages", "com.netflix.zuul")
// Uncomment to automatically apply fixes for a check:
//
// errorproneArgs.addAll(
errorproneArgs.addAll(
// Uncomment to automatically apply fixes for a check.
// N.B: disables all other checks while enabled.
// "-XepPatchChecks:UnnecessaryParentheses",
// "-XepPatchLocation:IN_PLACE",
// )
"-Xep:AutoFactoryAtInject",
"-Xep:BanClassLoader",
"-Xep:BanSerializableRead",
"-Xep:ClassName",
"-Xep:ComparisonContractViolated",
"-Xep:DeduplicateConstants",
"-Xep:DepAnn",
"-Xep:EmptyIf",
"-Xep:ExtendsAutoValue",
"-Xep:InjectMoreThanOneQualifier",
"-Xep:InsecureCryptoUsage",
"-Xep:IterablePathParameter",
"-Xep:LongLiteralLowerCaseSuffix",
"-Xep:MissingRuntimeRetention",
"-Xep:NoAllocation",
"-Xep:RefersToDaggerCodegen",
"-Xep:StaticOrDefaultInterfaceMethod",
"-Xep:StaticQualifiedUsingExpression",
"-Xep:SystemExitOutsideMain",
"-Xep:UseCorrectAssertInTests",
"-Xep:AnnotationPosition",
"-Xep:AssertFalse",
"-Xep:AssistedInjectAndInjectOnConstructors",
"-Xep:AvoidObjectArrays",
"-Xep:BinderIdentityRestoredDangerously",
"-Xep:BindingToUnqualifiedCommonType",
"-Xep:BuilderReturnThis",
"-Xep:CanIgnoreReturnValueSuggester",
"-Xep:CannotMockFinalClass",
"-Xep:CannotMockMethod",
"-Xep:CatchingUnchecked",
"-Xep:CheckedExceptionNotThrown",
"-Xep:ConstantPatternCompile",
"-Xep:DefaultLocale",
"-Xep:DifferentNameButSame",
"-Xep:EqualsBrokenForNull",
"-Xep:ExpectedExceptionChecker",
"-Xep:FloggerLogWithCause",
"-Xep:FloggerMessageFormat",
"-Xep:FloggerRedundantIsEnabled",
"-Xep:FloggerRequiredModifiers",
"-Xep:FloggerWithCause",
"-Xep:FloggerWithoutCause",
"-Xep:FunctionalInterfaceClash",
"-Xep:HardCodedSdCardPath",
"-Xep:IdentifierName",
"-Xep:InconsistentOverloads",
"-Xep:InitializeInline",
"-Xep:InterfaceWithOnlyStatics",
"-Xep:InterruptedExceptionSwallowed",
"-Xep:Interruption",
"-Xep:MissingDefault",
"-Xep:MockitoDoSetup",
"-Xep:MutableGuiceModule",
"-Xep:NonCanonicalStaticMemberImport",
"-Xep:NonFinalStaticField",
"-Xep:PreferJavaTimeOverload",
"-Xep:PreferredInterfaceType",
"-Xep:PrimitiveArrayPassedToVarargsMethod",
"-Xep:QualifierWithTypeUse",
"-Xep:RedundantOverride",
"-Xep:RedundantThrows",
"-Xep:StringFormatWithLiteral",
"-Xep:StronglyTypeByteString",
"-Xep:StronglyTypeTime",
"-Xep:SunApi",
"-Xep:SuppressWarningsWithoutExplanation",
"-Xep:SystemOut",
"-Xep:TestExceptionChecker",
"-Xep:ThrowSpecificExceptions",
"-Xep:TimeUnitMismatch",
"-Xep:TooManyParameters",
"-Xep:TransientMisuse",
"-Xep:TruthContainsExactlyElementsInUsage",
"-Xep:TryWithResourcesVariable",
"-Xep:UnescapedEntity",
"-Xep:UnnecessarilyFullyQualified",
"-Xep:UnnecessarilyUsedValue",
"-Xep:UnnecessarilyVisible",
"-Xep:UnnecessaryAnonymousClass",
"-Xep:UnnecessaryDefaultInEnumSwitch",
"-Xep:UnnecessaryFinal",
"-Xep:UnnecessaryOptionalGet",
"-Xep:UnnecessaryTestMethodPrefix",
"-Xep:UnsafeLocaleUsage",
"-Xep:UnusedException",
"-Xep:UrlInSee",
"-Xep:UsingJsr305CheckReturnValue",
"-Xep:Var",
"-Xep:Varifier",
"-Xep:YodaCondition",
"-Xep:AnnotationMirrorToString",
"-Xep:AnnotationValueToString",
"-Xep:BooleanParameter",
"-Xep:ClassNamedLikeTypeParameter",
"-Xep:ConstantField",
"-Xep:EqualsMissingNullable",
"-Xep:FieldCanBeFinal",
"-Xep:FieldCanBeLocal",
"-Xep:FieldCanBeStatic",
"-Xep:FieldMissingNullable",
"-Xep:ForEachIterable",
"-Xep:ImmutableMemberCollection",
"-Xep:ImmutableRefactoring",
"-Xep:ImmutableSetForContains",
"-Xep:ImplementAssertionWithChaining",
"-Xep:LambdaFunctionalInterface",
"-Xep:MethodCanBeStatic",
"-Xep:MissingBraces",
"-Xep:MixedArrayDimensions",
"-Xep:MultiVariableDeclaration",
"-Xep:MultipleTopLevelClasses",
"-Xep:PackageLocation",
"-Xep:ParameterComment",
"-Xep:ParameterMissingNullable",
"-Xep:PrivateConstructorForNoninstantiableModule",
"-Xep:PrivateConstructorForUtilityClass",
"-Xep:PublicApiNamedStreamShouldReturnStream",
"-Xep:RemoveUnusedImports",
"-Xep:ReturnMissingNullable",
"-Xep:ReturnsNullCollection",
"-Xep:ScopeOnModule",
"-Xep:SwitchDefault",
"-Xep:SymbolToString",
"-Xep:ThrowsUncheckedException",
"-Xep:TryFailRefactoring",
"-Xep:TypeParameterNaming",
"-Xep:TypeToString",
"-Xep:UngroupedOverloads",
"-Xep:UnnecessaryBoxedAssignment",
"-Xep:UnnecessaryBoxedVariable",
"-Xep:UnnecessarySetDefault",
"-Xep:UnnecessaryStaticImport",
"-Xep:UseEnumSwitch",
"-Xep:VoidMissingNullable",
"-Xep:WildcardImport",
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final class AssertReasonHandler extends ChannelInboundHandlerAdapter {

@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
assert evt instanceof CompleteEvent;
Truth.assertThat(evt).isInstanceOf(CompleteEvent.class);
this.completeEvent = (CompleteEvent) evt;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@

package com.netflix.zuul.message;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.netflix.zuul.context.SessionContext;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.http.DefaultHttpContent;
import io.netty.handler.codec.http.DefaultLastHttpContent;
import io.netty.handler.codec.http.HttpContent;
import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;

import java.nio.charset.StandardCharsets;

import static org.junit.jupiter.api.Assertions.*;

@ExtendWith(MockitoExtension.class)
class ZuulMessageImplTest {
private static final String TEXT1 = "Hello World!";
Expand Down Expand Up @@ -66,7 +64,7 @@ void testBufferBody2GetBody() {
final String body = new String(msg.getBody());
assertTrue(msg.hasBody());
assertTrue(msg.hasCompleteBody());
assertEquals("Hello World!", body);
assertEquals(TEXT1, body);
assertEquals(0, msg.getHeaders().getAll("Content-Length").size());
}

Expand All @@ -79,7 +77,7 @@ void testBufferBody3GetBody() {
final String body = new String(msg.getBody());
assertTrue(msg.hasBody());
assertTrue(msg.hasCompleteBody());
assertEquals("Hello World!", body);
assertEquals(TEXT1, body);
assertEquals(0, msg.getHeaders().getAll("Content-Length").size());
}

Expand All @@ -92,7 +90,7 @@ void testBufferBody3GetBodyAsText() {
final String body = msg.getBodyAsText();
assertTrue(msg.hasBody());
assertTrue(msg.hasCompleteBody());
assertEquals("Hello World!", body);
assertEquals(TEXT1, body);
assertEquals(0, msg.getHeaders().getAll("Content-Length").size());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

import com.netflix.zuul.DynamicCodeCompiler;
import groovy.lang.GroovyClassLoader;
import java.io.File;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;

/**
* Groovy code compiler
* User: mcohen
Expand All @@ -48,6 +49,7 @@ public Class<?> compile(String sCode, String sName) {
/**
* @return a new GroovyClassLoader
*/
@SuppressWarnings("BanClassLoader")
GroovyClassLoader getGroovyClassLoader() {
return new GroovyClassLoader();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void checkZuulFilterInstance(Object zuulFilter) throws InstantiationException {
* compiles the Groovy source code
*
*/
@SuppressWarnings("BanClassLoader")
public Class<?> compileGroovy(String sFilterCode) throws CompilationFailedException {
GroovyClassLoader loader = new GroovyClassLoader();
return loader.parseClass(sFilterCode);
Expand Down

0 comments on commit d64e4d9

Please sign in to comment.