Skip to content

Commit

Permalink
misc: add linter (#497)
Browse files Browse the repository at this point in the history
* misc: add linter

* misc: add linter
  • Loading branch information
maxday authored Jul 30, 2024
1 parent bf708ee commit ff5d9e0
Show file tree
Hide file tree
Showing 46 changed files with 1,031 additions and 816 deletions.
115 changes: 115 additions & 0 deletions aws-lambda-java-runtime-interface-client/build-tools/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">

<module name="Checker">
<module name="NewlineAtEndOfFile" />
<module name="OrderedProperties" />
<module name="FileTabCharacter" />
<module name="Header">
<property name="header"
value="/*\nCopyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: Apache-2.0\n*/\n"/>
</module>
<module name="FileTabCharacter"/>
<module name="TreeWalker">
<module name="UnusedImports"/>
<module name="NeedBraces"/>
<module name="EqualsHashCode"/>
<module name="EmptyStatement"/>
<module name="EqualsAvoidNull"/>
<module name="MissingSwitchDefault"/>
<module name="MultipleVariableDeclarations"/>
<module name="OneStatementPerLine"/>
<module name="RedundantImport"/>
<module name="AvoidStarImport"/>
<module name="DefaultComesLast"/>
<module name="SuppressWarningsHolder" />
<module name="EmptyForInitializerPad" />
<module name="GenericWhitespace" />
<module name="MethodParamPad" />
<module name="NoLineWrap" />
<module name="NoWhitespaceAfter" />
<module name="NoWhitespaceBefore" />
<module name="NoWhitespaceBeforeCaseDefaultColon" />
<module name="OperatorWrap" />
<module name="ParenPad" />
<module name="SeparatorWrap" />
<module name="SingleSpaceSeparator" />
<module name="TypecastParenPad" />
<module name="WhitespaceAfter" />
<module name="WhitespaceAround" />
<module name="AvoidNestedBlocks" />
<module name="EmptyBlock" />
<module name="EmptyCatchBlock" />
<module name="LeftCurly" />
<module name="NeedBraces" />
<module name="RightCurly" />
<module name="InnerTypeLast" />
<module name="MutableException" />
<module name="OneTopLevelClass" />
<module name="ThrowsCount" />

<module name="AvoidNoArgumentSuperConstructorCall" />
<module name="CovariantEquals" />
<module name="DeclarationOrder" />
<module name="DefaultComesLast" />
<module name="EmptyStatement" />
<module name="EqualsAvoidNull" />
<module name="EqualsHashCode" />
<module name="FallThrough" />
<module name="IllegalInstantiation" />
<module name="IllegalToken" />
<module name="IllegalTokenText" />
<module name="IllegalType" />
<module name="InnerAssignment" />
<module name="MatchXpath" />
<module name="MissingSwitchDefault" />
<module name="ModifiedControlVariable" />
<module name="MultipleVariableDeclarations" />
<module name="NestedForDepth" />
<module name="NestedTryDepth" />
<module name="NoArrayTrailingComma" />
<module name="NoClone" />
<module name="NoEnumTrailingComma" />
<module name="NoFinalizer" />
<module name="OneStatementPerLine" />
<module name="OverloadMethodsDeclarationOrder" />
<module name="PackageDeclaration" />
<module name="ParameterAssignment" />
<module name="RequireThis" />
<module name="SimplifyBooleanExpression" />
<module name="SimplifyBooleanReturn" />
<module name="StringLiteralEquality" />
<module name="SuperClone" />
<module name="SuperFinalize" />
<module name="UnnecessarySemicolonAfterOuterTypeDeclaration" />
<module name="UnnecessarySemicolonAfterTypeMemberDeclaration" />
<module name="UnnecessarySemicolonInEnumeration" />
<module name="UnnecessarySemicolonInTryWithResources" />
<module name="VariableDeclarationUsageDistance" />

<module name="ImportOrder" />
<module name="RedundantImport" />
<module name="UnusedImports" />

<module name="ArrayTypeStyle" />
<module name="AvoidEscapedUnicodeCharacters" />
<module name="CommentsIndentation" />
<module name="DescendantToken" />
<module name="Indentation" />
<module name="NoCodeInFile" />
<module name="OuterTypeFilename" />
<module name="TodoComment" />
<module name="TrailingComment" />
<module name="UpperEll" />

<module name="LambdaBodyLength" />
<module name="MethodCount" />
<module name="MethodLength" />
<module name="OuterTypeNumber" />
<module name="RecordComponentNumber" />
</module>

<module name="SuppressWarningsFilter" />
</module>
21 changes: 21 additions & 0 deletions aws-lambda-java-runtime-interface-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<maven-install-plugin.version>2.4</maven-install-plugin.version>
<maven-deploy-plugin.version>3.1.1</maven-deploy-plugin.version>
<junit-jupiter.version>5.9.2</junit-jupiter.version>
<maven-checkstyle-plugin.version>3.4.0</maven-checkstyle-plugin.version>
<!--
The test/integration/codebuild/buildspec.*.yml files will set -DmultiArch=false
as a workaround for executing within Github Actions. At time of writing (2022-04-08) the
Expand Down Expand Up @@ -238,6 +239,26 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<configuration>
<configLocation>build-tools/checkstyle.xml</configLocation>
<failOnViolation>true</failOnViolation>
<consoleOutput>true</consoleOutput>
<logViolationsToConsole>true</logViolationsToConsole>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*/
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package com.amazonaws.services.lambda.crac;

public class CheckpointException extends Exception {
private static final long serialVersionUID = -4956873658083157585L;
public CheckpointException() {
super();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*/
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package com.amazonaws.services.lambda.crac;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*/
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package com.amazonaws.services.lambda.crac;

Expand Down Expand Up @@ -57,19 +58,19 @@ public synchronized void register(Resource resource) {
}

private List<Resource> getCheckpointQueueReverseOrderOfRegistration() {
return checkpointQueue.entrySet()
.stream()
.sorted((r1, r2) -> (int) (r2.getValue() - r1.getValue()))
.map(Map.Entry::getKey)
.collect(Collectors.toList());
return checkpointQueue.entrySet().
stream().
sorted((r1, r2) -> (int) (r2.getValue() - r1.getValue())).
map(Map.Entry::getKey).
collect(Collectors.toList());
}

private List<Resource> getCheckpointQueueForwardOrderOfRegistration() {
return checkpointQueue.entrySet()
.stream()
.sorted((r1, r2) -> (int) (r1.getValue() - r2.getValue()))
.map(Map.Entry::getKey)
.collect(Collectors.toList());
return checkpointQueue.entrySet().
stream().
sorted((r1, r2) -> (int) (r1.getValue() - r2.getValue())).
map(Map.Entry::getKey).
collect(Collectors.toList());
}

private void executeBeforeCheckpointHooks() throws CheckpointException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*/
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package com.amazonaws.services.lambda.crac;

Expand All @@ -9,11 +10,11 @@
*/
public final class Core {

private static Context<Resource> globalContext = new ContextImpl();

private Core() {
}

private static Context<Resource> globalContext = new ContextImpl();

public static Context<Resource> getGlobalContext() {
return globalContext;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

class DNSManager {
static native void clearCache();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*/
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package com.amazonaws.services.lambda.crac;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*/
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package com.amazonaws.services.lambda.crac;

public class RestoreException extends Exception {
private static final long serialVersionUID = -823900409868237860L;

public RestoreException() {
super();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.amazonaws.services.lambda.runtime.logging.LogFormat;
import com.amazonaws.services.lambda.runtime.logging.LogLevel;
import com.amazonaws.services.lambda.runtime.serialization.util.ReflectUtil;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileDescriptor;
Expand All @@ -50,6 +49,8 @@
*/
public class AWSLambda {

protected static URLClassLoader customerClassLoader;

private static final String TRUST_STORE_PROPERTY = "javax.net.ssl.trustStore";

private static final String JAVA_SECURITY_PROPERTIES = "java.security.properties";
Expand All @@ -68,8 +69,6 @@ public class AWSLambda {

private static final String AWS_LAMBDA_INITIALIZATION_TYPE = System.getenv(ReservedRuntimeEnvironmentVariables.AWS_LAMBDA_INITIALIZATION_TYPE);

protected static URLClassLoader customerClassLoader;

private static LambdaRuntimeApiClient runtimeClient;

static {
Expand Down Expand Up @@ -238,7 +237,8 @@ private static void startRuntime(String handler, LambdaContextLogger lambdaLogge
try {
payload = requestHandler.call(request);
runtimeClient.reportInvocationSuccess(request.getId(), payload.toByteArray());
boolean ignored = Thread.interrupted(); // clear interrupted flag in case if it was set by user's code
// clear interrupted flag in case if it was set by user's code
boolean ignored = Thread.interrupted();
} catch (UserFault f) {
shouldExit = f.fatal;
userFault = f;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
/*
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package com.amazonaws.services.lambda.runtime.api.client;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
/*
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package com.amazonaws.services.lambda.runtime.api.client;

Expand All @@ -24,7 +27,8 @@ class CustomerClassLoader extends URLClassLoader {
@Override
public boolean accept(File dir, String name) {
int offset = name.length() - 4;
if (offset <= 0) { /* must be at least A.jar */
// must be at least A.jar
if (offset <= 0) {
return false;
} else {
return name.startsWith(".jar", offset);
Expand Down
Loading

0 comments on commit ff5d9e0

Please sign in to comment.