Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit 2d7b024

Browse files
bestbeforetodayandrew-coleman
authored andcommitted
FGJ-54: Add Checkstyle to build (#4)
* FGJ-54: Add Checkstyle to build Signed-off-by: Mark S. Lewis <[email protected]> * FGJ-54: Add Checkstyle to build Run Checkstyle in the compile rather than validate phase so local Javadoc class references can be resolved after `mvn clean`. Signed-off-by: Mark S. Lewis <[email protected]>
1 parent 1e79a8e commit 2d7b024

Some content is hidden

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

51 files changed

+1273
-966
lines changed

checkstyle.xml

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
6+
<module name="Checker">
7+
<property name="basedir" value="${basedir}"/>
8+
<property name="severity" value="error"/>
9+
10+
<property name="fileExtensions" value="java, properties, xml"/>
11+
12+
<!-- Excludes all 'module-info.java' files -->
13+
<!-- See https://checkstyle.org/config_filefilters.html -->
14+
<module name="BeforeExecutionExclusionFileFilter">
15+
<property name="fileNamePattern" value="module\-info\.java$"/>
16+
</module>
17+
18+
<!-- Only public (API, SPI) classes must have Javadoc -->
19+
<module name="SuppressionSingleFilter">
20+
<property name="checks" value=".*Javadoc.*"/>
21+
<property name="files" value="src/main/java/org/hyperledger/fabric/gateway/impl/"/>
22+
</module>
23+
24+
<!-- Checks that a package-info.java file exists for each package. -->
25+
<!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage -->
26+
<module name="JavadocPackage"/>
27+
28+
<!-- Checks whether files end with a new line. -->
29+
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
30+
<module name="NewlineAtEndOfFile"/>
31+
32+
<!-- Checks that property files contain the same keys. -->
33+
<!-- See https://checkstyle.org/config_misc.html#Translation -->
34+
<module name="Translation"/>
35+
36+
<!-- Checks for Size Violations. -->
37+
<!-- See https://checkstyle.org/config_sizes.html -->
38+
<module name="FileLength"/>
39+
<module name="LineLength">
40+
<property name="fileExtensions" value="java"/>
41+
<property name="ignorePattern" value="^ +\* +"/>
42+
<property name="max" value="160"/>
43+
</module>
44+
45+
<!-- Checks for whitespace -->
46+
<!-- See https://checkstyle.org/config_whitespace.html -->
47+
<module name="FileTabCharacter"/>
48+
49+
<!-- Miscellaneous other checks. -->
50+
<!-- See https://checkstyle.org/config_misc.html -->
51+
<module name="RegexpSingleline">
52+
<property name="format" value="\s+$"/>
53+
<property name="minimum" value="0"/>
54+
<property name="maximum" value="0"/>
55+
<property name="message" value="Line has trailing spaces."/>
56+
</module>
57+
58+
<!-- Checks for Headers -->
59+
<!-- See https://checkstyle.org/config_header.html -->
60+
<module name="RegexpHeader">
61+
<property name="headerFile" value="java-copyright-header.txt"/>
62+
<property name="fileExtensions" value="java"/>
63+
</module>
64+
65+
<module name="TreeWalker">
66+
67+
<!-- Checkstyle ignore current line with a comment: // checkstyle:ignore-line:RuleName1|RuleName2 -->
68+
<module name="SuppressWithNearbyCommentFilter">
69+
<property name="commentFormat" value="checkstyle:ignore-line:(\w+(\|\w+)*)"/>
70+
<property name="checkFormat" value="$1"/>
71+
</module>
72+
73+
<!-- Checkstyle ignore next line with a comment: // checkstyle:ignore-next-line:RuleName1|RuleName2 -->
74+
<module name="SuppressWithNearbyCommentFilter">
75+
<property name="commentFormat" value="checkstyle:ignore-next-line:(\w+(\|\w+)*)"/>
76+
<property name="checkFormat" value="$1"/>
77+
<property name="influenceFormat" value="1"/>
78+
</module>
79+
80+
<!-- Checks for Javadoc comments. -->
81+
<!-- See https://checkstyle.org/config_javadoc.html -->
82+
<module name="InvalidJavadocPosition"/>
83+
<module name="JavadocMethod"/>
84+
<module name="JavadocType"/>
85+
<module name="JavadocVariable">
86+
<property name="scope" value="protected"/>
87+
</module>
88+
<module name="JavadocStyle"/>
89+
<module name="MissingJavadocMethod"/>
90+
91+
<!-- Checks for Naming Conventions. -->
92+
<!-- See https://checkstyle.org/config_naming.html -->
93+
<module name="ConstantName"/>
94+
<module name="LocalFinalVariableName"/>
95+
<module name="LocalVariableName"/>
96+
<module name="MemberName"/>
97+
<module name="MethodName"/>
98+
<module name="PackageName"/>
99+
<module name="ParameterName"/>
100+
<module name="StaticVariableName"/>
101+
<module name="TypeName"/>
102+
103+
<!-- Checks for imports -->
104+
<!-- See https://checkstyle.org/config_import.html -->
105+
<module name="AvoidStarImport"/>
106+
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
107+
<module name="RedundantImport"/>
108+
<module name="UnusedImports">
109+
<property name="processJavadoc" value="false"/>
110+
</module>
111+
112+
<!-- Checks for Size Violations. -->
113+
<!-- See https://checkstyle.org/config_sizes.html -->
114+
<module name="MethodLength"/>
115+
<module name="ParameterNumber"/>
116+
117+
<!-- Checks for whitespace -->
118+
<!-- See https://checkstyle.org/config_whitespace.html -->
119+
<module name="GenericWhitespace"/>
120+
<module name="MethodParamPad"/>
121+
<module name="NoWhitespaceAfter"/>
122+
<module name="NoWhitespaceBefore"/>
123+
<module name="OperatorWrap"/>
124+
<module name="ParenPad"/>
125+
<module name="TypecastParenPad"/>
126+
<module name="WhitespaceAfter"/>
127+
<module name="WhitespaceAround"/>
128+
129+
<!-- Modifier Checks -->
130+
<!-- See https://checkstyle.org/config_modifiers.html -->
131+
<module name="ModifierOrder"/>
132+
<module name="RedundantModifier"/>
133+
134+
<!-- Checks for blocks. You know, those {}'s -->
135+
<!-- See https://checkstyle.org/config_blocks.html -->
136+
<module name="AvoidNestedBlocks"/>
137+
<module name="EmptyBlock"/>
138+
<module name="LeftCurly"/>
139+
<module name="NeedBraces"/>
140+
<module name="RightCurly"/>
141+
142+
<!-- Checks for common coding problems -->
143+
<!-- See https://checkstyle.org/config_coding.html -->
144+
<module name="EmptyStatement"/>
145+
<module name="EqualsHashCode"/>
146+
<module name="IllegalInstantiation"/>
147+
<module name="InnerAssignment"/>
148+
<module name="MagicNumber"/>
149+
<module name="MissingSwitchDefault"/>
150+
<module name="MultipleVariableDeclarations"/>
151+
<module name="SimplifyBooleanExpression"/>
152+
<module name="SimplifyBooleanReturn"/>
153+
154+
<!-- Checks for class design -->
155+
<!-- See https://checkstyle.org/config_design.html -->
156+
<module name="DesignForExtension"/>
157+
<module name="FinalClass"/>
158+
<module name="HideUtilityClassConstructor"/>
159+
<module name="InterfaceIsType"/>
160+
<module name="VisibilityModifier"/>
161+
162+
<!-- Checks for metrics -->
163+
<!-- See https://checkstyle.org/config_metrics.html -->
164+
<module name="CyclomaticComplexity">
165+
<property name="max" value="10"/>
166+
</module>
167+
168+
<!-- Miscellaneous other checks. -->
169+
<!-- See https://checkstyle.org/config_misc.html -->
170+
<module name="ArrayTypeStyle"/>
171+
<module name="FinalParameters"/>
172+
<module name="TodoComment"/>
173+
<module name="UpperEll"/>
174+
175+
</module>
176+
177+
</module>

java-copyright-header.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
^/\*$
2+
^ \* Copyright \d\d\d\d IBM All Rights Reserved\.$
3+
^ \*$
4+
^ \* SPDX-License-Identifier: Apache-2\.0$
5+
^ \*/$

0 commit comments

Comments
 (0)