Skip to content

Commit ff5d9e0

Browse files
authored
misc: add linter (#497)
* misc: add linter * misc: add linter
1 parent bf708ee commit ff5d9e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1031
-816
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
4+
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
5+
6+
<module name="Checker">
7+
<module name="NewlineAtEndOfFile" />
8+
<module name="OrderedProperties" />
9+
<module name="FileTabCharacter" />
10+
<module name="Header">
11+
<property name="header"
12+
value="/*\nCopyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: Apache-2.0\n*/\n"/>
13+
</module>
14+
<module name="FileTabCharacter"/>
15+
<module name="TreeWalker">
16+
<module name="UnusedImports"/>
17+
<module name="NeedBraces"/>
18+
<module name="EqualsHashCode"/>
19+
<module name="EmptyStatement"/>
20+
<module name="EqualsAvoidNull"/>
21+
<module name="MissingSwitchDefault"/>
22+
<module name="MultipleVariableDeclarations"/>
23+
<module name="OneStatementPerLine"/>
24+
<module name="RedundantImport"/>
25+
<module name="AvoidStarImport"/>
26+
<module name="DefaultComesLast"/>
27+
<module name="SuppressWarningsHolder" />
28+
<module name="EmptyForInitializerPad" />
29+
<module name="GenericWhitespace" />
30+
<module name="MethodParamPad" />
31+
<module name="NoLineWrap" />
32+
<module name="NoWhitespaceAfter" />
33+
<module name="NoWhitespaceBefore" />
34+
<module name="NoWhitespaceBeforeCaseDefaultColon" />
35+
<module name="OperatorWrap" />
36+
<module name="ParenPad" />
37+
<module name="SeparatorWrap" />
38+
<module name="SingleSpaceSeparator" />
39+
<module name="TypecastParenPad" />
40+
<module name="WhitespaceAfter" />
41+
<module name="WhitespaceAround" />
42+
<module name="AvoidNestedBlocks" />
43+
<module name="EmptyBlock" />
44+
<module name="EmptyCatchBlock" />
45+
<module name="LeftCurly" />
46+
<module name="NeedBraces" />
47+
<module name="RightCurly" />
48+
<module name="InnerTypeLast" />
49+
<module name="MutableException" />
50+
<module name="OneTopLevelClass" />
51+
<module name="ThrowsCount" />
52+
53+
<module name="AvoidNoArgumentSuperConstructorCall" />
54+
<module name="CovariantEquals" />
55+
<module name="DeclarationOrder" />
56+
<module name="DefaultComesLast" />
57+
<module name="EmptyStatement" />
58+
<module name="EqualsAvoidNull" />
59+
<module name="EqualsHashCode" />
60+
<module name="FallThrough" />
61+
<module name="IllegalInstantiation" />
62+
<module name="IllegalToken" />
63+
<module name="IllegalTokenText" />
64+
<module name="IllegalType" />
65+
<module name="InnerAssignment" />
66+
<module name="MatchXpath" />
67+
<module name="MissingSwitchDefault" />
68+
<module name="ModifiedControlVariable" />
69+
<module name="MultipleVariableDeclarations" />
70+
<module name="NestedForDepth" />
71+
<module name="NestedTryDepth" />
72+
<module name="NoArrayTrailingComma" />
73+
<module name="NoClone" />
74+
<module name="NoEnumTrailingComma" />
75+
<module name="NoFinalizer" />
76+
<module name="OneStatementPerLine" />
77+
<module name="OverloadMethodsDeclarationOrder" />
78+
<module name="PackageDeclaration" />
79+
<module name="ParameterAssignment" />
80+
<module name="RequireThis" />
81+
<module name="SimplifyBooleanExpression" />
82+
<module name="SimplifyBooleanReturn" />
83+
<module name="StringLiteralEquality" />
84+
<module name="SuperClone" />
85+
<module name="SuperFinalize" />
86+
<module name="UnnecessarySemicolonAfterOuterTypeDeclaration" />
87+
<module name="UnnecessarySemicolonAfterTypeMemberDeclaration" />
88+
<module name="UnnecessarySemicolonInEnumeration" />
89+
<module name="UnnecessarySemicolonInTryWithResources" />
90+
<module name="VariableDeclarationUsageDistance" />
91+
92+
<module name="ImportOrder" />
93+
<module name="RedundantImport" />
94+
<module name="UnusedImports" />
95+
96+
<module name="ArrayTypeStyle" />
97+
<module name="AvoidEscapedUnicodeCharacters" />
98+
<module name="CommentsIndentation" />
99+
<module name="DescendantToken" />
100+
<module name="Indentation" />
101+
<module name="NoCodeInFile" />
102+
<module name="OuterTypeFilename" />
103+
<module name="TodoComment" />
104+
<module name="TrailingComment" />
105+
<module name="UpperEll" />
106+
107+
<module name="LambdaBodyLength" />
108+
<module name="MethodCount" />
109+
<module name="MethodLength" />
110+
<module name="OuterTypeNumber" />
111+
<module name="RecordComponentNumber" />
112+
</module>
113+
114+
<module name="SuppressWarningsFilter" />
115+
</module>

aws-lambda-java-runtime-interface-client/pom.xml

+21
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<maven-install-plugin.version>2.4</maven-install-plugin.version>
3939
<maven-deploy-plugin.version>3.1.1</maven-deploy-plugin.version>
4040
<junit-jupiter.version>5.9.2</junit-jupiter.version>
41+
<maven-checkstyle-plugin.version>3.4.0</maven-checkstyle-plugin.version>
4142
<!--
4243
The test/integration/codebuild/buildspec.*.yml files will set -DmultiArch=false
4344
as a workaround for executing within Github Actions. At time of writing (2022-04-08) the
@@ -238,6 +239,26 @@
238239
</execution>
239240
</executions>
240241
</plugin>
242+
<plugin>
243+
<groupId>org.apache.maven.plugins</groupId>
244+
<artifactId>maven-checkstyle-plugin</artifactId>
245+
<version>${maven-checkstyle-plugin.version}</version>
246+
<configuration>
247+
<configLocation>build-tools/checkstyle.xml</configLocation>
248+
<failOnViolation>true</failOnViolation>
249+
<consoleOutput>true</consoleOutput>
250+
<logViolationsToConsole>true</logViolationsToConsole>
251+
</configuration>
252+
<executions>
253+
<execution>
254+
<id>validate</id>
255+
<phase>validate</phase>
256+
<goals>
257+
<goal>check</goal>
258+
</goals>
259+
</execution>
260+
</executions>
261+
</plugin>
241262
</plugins>
242263
</build>
243264

Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
2-
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3-
*/
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: Apache-2.0
4+
*/
45

56
package com.amazonaws.services.lambda.crac;
67

78
public class CheckpointException extends Exception {
89
private static final long serialVersionUID = -4956873658083157585L;
910
public CheckpointException() {
10-
super();
1111
}
1212
}

aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/crac/Context.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3-
*/
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: Apache-2.0
4+
*/
45

56
package com.amazonaws.services.lambda.crac;
67

aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/crac/ContextImpl.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3-
*/
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: Apache-2.0
4+
*/
45

56
package com.amazonaws.services.lambda.crac;
67

@@ -57,19 +58,19 @@ public synchronized void register(Resource resource) {
5758
}
5859

5960
private List<Resource> getCheckpointQueueReverseOrderOfRegistration() {
60-
return checkpointQueue.entrySet()
61-
.stream()
62-
.sorted((r1, r2) -> (int) (r2.getValue() - r1.getValue()))
63-
.map(Map.Entry::getKey)
64-
.collect(Collectors.toList());
61+
return checkpointQueue.entrySet().
62+
stream().
63+
sorted((r1, r2) -> (int) (r2.getValue() - r1.getValue())).
64+
map(Map.Entry::getKey).
65+
collect(Collectors.toList());
6566
}
6667

6768
private List<Resource> getCheckpointQueueForwardOrderOfRegistration() {
68-
return checkpointQueue.entrySet()
69-
.stream()
70-
.sorted((r1, r2) -> (int) (r1.getValue() - r2.getValue()))
71-
.map(Map.Entry::getKey)
72-
.collect(Collectors.toList());
69+
return checkpointQueue.entrySet().
70+
stream().
71+
sorted((r1, r2) -> (int) (r1.getValue() - r2.getValue())).
72+
map(Map.Entry::getKey).
73+
collect(Collectors.toList());
7374
}
7475

7576
private void executeBeforeCheckpointHooks() throws CheckpointException {

aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/crac/Core.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3-
*/
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: Apache-2.0
4+
*/
45

56
package com.amazonaws.services.lambda.crac;
67

@@ -9,11 +10,11 @@
910
*/
1011
public final class Core {
1112

13+
private static Context<Resource> globalContext = new ContextImpl();
14+
1215
private Core() {
1316
}
1417

15-
private static Context<Resource> globalContext = new ContextImpl();
16-
1718
public static Context<Resource> getGlobalContext() {
1819
return globalContext;
1920
}

aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/crac/DNSManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77

88
class DNSManager {
99
static native void clearCache();
10-
}
10+
}

aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/crac/Resource.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3-
*/
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: Apache-2.0
4+
*/
45

56
package com.amazonaws.services.lambda.crac;
67

Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*
2-
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3-
*/
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: Apache-2.0
4+
*/
45

56
package com.amazonaws.services.lambda.crac;
67

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

1011
public RestoreException() {
11-
super();
1212
}
1313
}

aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/AWSLambda.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.amazonaws.services.lambda.runtime.logging.LogFormat;
2424
import com.amazonaws.services.lambda.runtime.logging.LogLevel;
2525
import com.amazonaws.services.lambda.runtime.serialization.util.ReflectUtil;
26-
2726
import java.io.ByteArrayOutputStream;
2827
import java.io.File;
2928
import java.io.FileDescriptor;
@@ -50,6 +49,8 @@
5049
*/
5150
public class AWSLambda {
5251

52+
protected static URLClassLoader customerClassLoader;
53+
5354
private static final String TRUST_STORE_PROPERTY = "javax.net.ssl.trustStore";
5455

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

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

71-
protected static URLClassLoader customerClassLoader;
72-
7372
private static LambdaRuntimeApiClient runtimeClient;
7473

7574
static {
@@ -238,7 +237,8 @@ private static void startRuntime(String handler, LambdaContextLogger lambdaLogge
238237
try {
239238
payload = requestHandler.call(request);
240239
runtimeClient.reportInvocationSuccess(request.getId(), payload.toByteArray());
241-
boolean ignored = Thread.interrupted(); // clear interrupted flag in case if it was set by user's code
240+
// clear interrupted flag in case if it was set by user's code
241+
boolean ignored = Thread.interrupted();
242242
} catch (UserFault f) {
243243
shouldExit = f.fatal;
244244
userFault = f;

aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/ClasspathLoader.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
1+
/*
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: Apache-2.0
4+
*/
25

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

aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/CustomerClassLoader.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
1+
/*
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: Apache-2.0
4+
*/
25

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

@@ -24,7 +27,8 @@ class CustomerClassLoader extends URLClassLoader {
2427
@Override
2528
public boolean accept(File dir, String name) {
2629
int offset = name.length() - 4;
27-
if (offset <= 0) { /* must be at least A.jar */
30+
// must be at least A.jar
31+
if (offset <= 0) {
2832
return false;
2933
} else {
3034
return name.startsWith(".jar", offset);

0 commit comments

Comments
 (0)