Skip to content

Commit 1aa467c

Browse files
walterscarboroughAndrew Keesler
authored andcommitted
Add checkstyle and fix all Java linting errors
- Checkstyle config based on spring-javaformat project Signed-off-by: Andrew Keesler <[email protected]>
1 parent 7abb85a commit 1aa467c

File tree

433 files changed

+9199
-8587
lines changed

Some content is hidden

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

433 files changed

+9199
-8587
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ apply from: "kotlin.gradle"
4444
apply from: "spring-cloud-contract-config.gradle"
4545
apply from: "spring-rest-docs-config.gradle"
4646
apply from: "ktlint.gradle"
47+
apply from: "checkstyle-config.gradle"
4748

4849
jar {
4950
baseName = "credhub"

checkstyle-config.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apply plugin: "checkstyle"
2+
3+
checkstyleTest.source = "src/test/java"
4+
5+
[checkstyleMain, checkstyleTest].each() {
6+
it.exclude '**/grpc/**.java'
7+
}

config/checkstyle/checkstyle.xml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
3+
<module name="com.puppycrawl.tools.checkstyle.Checker">
4+
<!-- Root Checks -->
5+
<module name="com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck">
6+
<property name="lineSeparator" value="lf"/>
7+
</module>
8+
9+
<!-- TreeWalker Checks -->
10+
<module name="com.puppycrawl.tools.checkstyle.TreeWalker">
11+
<!-- Annotations -->
12+
<module name="com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck">
13+
<property name="elementStyle" value="compact" />
14+
</module>
15+
<module name="com.puppycrawl.tools.checkstyle.checks.annotation.MissingOverrideCheck" />
16+
<module name="com.puppycrawl.tools.checkstyle.checks.annotation.PackageAnnotationCheck" />
17+
<module name="com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck">
18+
<property name="allowSamelineSingleParameterlessAnnotation"
19+
value="false" />
20+
</module>
21+
22+
<!-- Block Checks -->
23+
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck">
24+
<property name="option" value="text" />
25+
</module>
26+
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck" />
27+
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck" />
28+
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck" />
29+
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.AvoidNestedBlocksCheck" />
30+
31+
<!-- Class Design -->
32+
<module name="com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck" />
33+
<module name="com.puppycrawl.tools.checkstyle.checks.design.InterfaceIsTypeCheck" />
34+
<module name="com.puppycrawl.tools.checkstyle.checks.design.HideUtilityClassConstructorCheck" />
35+
<module name="com.puppycrawl.tools.checkstyle.checks.design.MutableExceptionCheck" />
36+
<module name="com.puppycrawl.tools.checkstyle.checks.design.InnerTypeLastCheck" />
37+
<module name="com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck" />
38+
39+
<!-- Coding -->
40+
<module name="com.puppycrawl.tools.checkstyle.checks.coding.CovariantEqualsCheck" />
41+
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck" />
42+
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsHashCodeCheck" />
43+
<module name="com.puppycrawl.tools.checkstyle.checks.coding.InnerAssignmentCheck" />
44+
<module name="com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanExpressionCheck" />
45+
<module name="com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanReturnCheck" />
46+
<module name="com.puppycrawl.tools.checkstyle.checks.coding.StringLiteralEqualityCheck" />
47+
<module name="com.puppycrawl.tools.checkstyle.checks.coding.NestedForDepthCheck">
48+
<property name="max" value="3" />
49+
</module>
50+
<module name="com.puppycrawl.tools.checkstyle.checks.coding.NestedIfDepthCheck">
51+
<property name="max" value="3" />
52+
</module>
53+
<module name="com.puppycrawl.tools.checkstyle.checks.coding.NestedTryDepthCheck">
54+
<property name="max" value="3" />
55+
</module>
56+
<module name="com.puppycrawl.tools.checkstyle.checks.coding.MultipleVariableDeclarationsCheck" />
57+
<module name="com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck">
58+
<property name="checkMethods" value="false" />
59+
<property name="checkFields" value="false" />
60+
<property name="validateOnlyOverlapping" value="false" />
61+
</module>
62+
<module name="com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck" />
63+
64+
<!-- Imports -->
65+
<module name="com.puppycrawl.tools.checkstyle.checks.imports.AvoidStarImportCheck" />
66+
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck" />
67+
<module name="com.puppycrawl.tools.checkstyle.checks.imports.RedundantImportCheck" />
68+
<module name="com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck">
69+
<property name="processJavadoc" value="true" />
70+
</module>
71+
<module name="com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck">
72+
<property name="groups" value="java,/^javax?\./,org.springframework,*" />
73+
<property name="ordered" value="true" />
74+
<property name="separated" value="true" />
75+
<property name="option" value="bottom" />
76+
<property name="sortStaticImportsAlphabetically" value="true" />
77+
</module>
78+
79+
<!-- Miscellaneous -->
80+
<module name="com.puppycrawl.tools.checkstyle.checks.indentation.CommentsIndentationCheck">
81+
<property name="tokens" value="BLOCK_COMMENT_BEGIN"/>
82+
</module>
83+
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck" />
84+
<module name="com.puppycrawl.tools.checkstyle.checks.ArrayTypeStyleCheck" />
85+
<module name="com.puppycrawl.tools.checkstyle.checks.OuterTypeFilenameCheck" />
86+
87+
<!-- Modifiers -->
88+
<module name="com.puppycrawl.tools.checkstyle.checks.modifier.RedundantModifierCheck" />
89+
90+
<!-- Regexp -->
91+
<!--<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">-->
92+
<!--<property name="maximum" value="0"/>-->
93+
<!--<property name="format" value="org\.junit\.Assert\.assert" />-->
94+
<!--<property name="message"-->
95+
<!--value="Please use AssertJ imports." />-->
96+
<!--<property name="ignoreComments" value="true" />-->
97+
<!--</module>-->
98+
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpCheck">
99+
<property name="format" value="[ \t]+$" />
100+
<property name="illegalPattern" value="true" />
101+
<property name="message" value="Trailing whitespace" />
102+
</module>
103+
104+
<!-- Whitespace -->
105+
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck" />
106+
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck" />
107+
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceAfterCheck" >
108+
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS, ARRAY_DECLARATOR"/>
109+
</module>
110+
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCheck" />
111+
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck" />
112+
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheck" />
113+
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck" />
114+
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck" />
115+
</module>
116+
</module>

scripts/lint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ function lint_scripts() {
1414
shellcheck scripts/*
1515
}
1616

17+
function lint_java() {
18+
./gradlew checkstyleMain checkstyleTest
19+
}
20+
1721
function lint_kotlin() {
1822
./gradlew ktlint
1923
}
@@ -23,6 +27,7 @@ function main() {
2327
go_to_project_root_directory
2428
lint_scripts
2529
lint_kotlin
30+
lint_java
2631
}
2732

28-
main "$@"
33+
main "$@"

src/main/java/db/migration/common/V11_1__set_uuid_in_named_certificate_authority_where_null.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
import java.util.List;
44
import java.util.UUID;
5-
import org.flywaydb.core.api.migration.spring.SpringJdbcMigration;
5+
66
import org.springframework.jdbc.core.JdbcTemplate;
77

8+
import org.flywaydb.core.api.migration.spring.SpringJdbcMigration;
9+
810
public class V11_1__set_uuid_in_named_certificate_authority_where_null implements
911
SpringJdbcMigration {
1012

src/main/java/db/migration/common/V20_1__set_uuid_in_encryption_key_canary.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package db.migration.common;
22

3-
import org.cloudfoundry.credhub.util.UuidUtil;
43
import java.sql.Types;
54
import java.util.List;
65
import java.util.UUID;
7-
import org.flywaydb.core.api.migration.spring.SpringJdbcMigration;
6+
87
import org.springframework.jdbc.core.JdbcTemplate;
98

9+
import org.cloudfoundry.credhub.util.UuidUtil;
10+
import org.flywaydb.core.api.migration.spring.SpringJdbcMigration;
11+
1012
public class V20_1__set_uuid_in_encryption_key_canary implements SpringJdbcMigration {
1113

1214
public void migrate(JdbcTemplate jdbcTemplate) throws Exception {

src/main/java/db/migration/common/V25_1__add_secret_name_relation.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package db.migration.common;
22

3-
import org.flywaydb.core.api.migration.spring.SpringJdbcMigration;
4-
import org.springframework.jdbc.core.JdbcTemplate;
5-
63
import java.sql.Types;
74
import java.util.List;
85

6+
import org.springframework.jdbc.core.JdbcTemplate;
7+
8+
import org.flywaydb.core.api.migration.spring.SpringJdbcMigration;
9+
910
import static org.cloudfoundry.credhub.util.UuidUtil.makeUuid;
1011

1112
public class V25_1__add_secret_name_relation implements SpringJdbcMigration {

src/main/java/db/migration/common/V35_1__migrate_operation_audit_record_table.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package db.migration.common;
22

3-
import org.flywaydb.core.api.migration.spring.SpringJdbcMigration;
4-
import org.springframework.jdbc.core.JdbcTemplate;
5-
63
import java.sql.Types;
74
import java.util.List;
85

6+
import org.springframework.jdbc.core.JdbcTemplate;
7+
8+
import org.flywaydb.core.api.migration.spring.SpringJdbcMigration;
9+
910
import static org.cloudfoundry.credhub.util.UuidUtil.makeUuid;
1011

1112
@SuppressWarnings("unused")

src/main/java/db/migration/common/V41_1__set_salt_in_existing_user_credentials.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package db.migration.common;
22

3-
import org.cloudfoundry.credhub.credential.CryptSaltFactory;
4-
import org.cloudfoundry.credhub.util.UuidUtil;
5-
import org.flywaydb.core.api.migration.spring.SpringJdbcMigration;
6-
import org.springframework.jdbc.core.JdbcTemplate;
7-
83
import java.nio.ByteBuffer;
94
import java.util.List;
105
import java.util.UUID;
116

7+
import org.springframework.jdbc.core.JdbcTemplate;
8+
9+
import org.cloudfoundry.credhub.credential.CryptSaltFactory;
10+
import org.cloudfoundry.credhub.util.UuidUtil;
11+
import org.flywaydb.core.api.migration.spring.SpringJdbcMigration;
12+
1213
@SuppressWarnings("unused")
1314
public class V41_1__set_salt_in_existing_user_credentials implements SpringJdbcMigration {
1415
@Override

src/main/java/db/migration/common/V44_2__migrate_encypted_values_to_encryped_value_table.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package db.migration.common;
22

3-
import org.flywaydb.core.api.migration.spring.SpringJdbcMigration;
4-
import org.springframework.jdbc.core.JdbcTemplate;
5-
63
import java.sql.Types;
74
import java.util.List;
85

6+
import org.springframework.jdbc.core.JdbcTemplate;
7+
8+
import org.flywaydb.core.api.migration.spring.SpringJdbcMigration;
9+
910
import static org.cloudfoundry.credhub.util.UuidUtil.makeUuid;
1011

1112
public class V44_2__migrate_encypted_values_to_encryped_value_table implements

0 commit comments

Comments
 (0)