Skip to content

Commit 511b4af

Browse files
authored
Merge pull request #389 from metafacture/addAndApplyCheckstyleConfig
Add and apply Checkstyle config.
2 parents 57fd430 + 85f3e2d commit 511b4af

File tree

498 files changed

+4487
-3323
lines changed

Some content is hidden

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

498 files changed

+4487
-3323
lines changed

build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ subprojects {
5555
apply plugin: 'signing'
5656
apply plugin: 'maven'
5757
apply plugin: 'jacoco'
58+
apply plugin: 'checkstyle'
5859

5960
check.dependsOn(editorconfigCheck)
6061

@@ -85,6 +86,11 @@ subprojects {
8586
archives javadocJar
8687
}
8788

89+
checkstyle {
90+
toolVersion '8.30'
91+
checkstyleTest.enabled = false
92+
}
93+
8894
signing {
8995
required {
9096
scmInfo.isRelease() && gradle.taskGraph.hasTask(tasks.uploadArchives)

config/checkstyle/checkstyle.xml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
<module name="Checker">
6+
<module name="SuppressWarningsFilter" />
7+
<module name="SuppressionSingleFilter">
8+
<property name="checks" value=".*"/>
9+
<property name="files" value="generated-src"/>
10+
</module>
11+
<module name="TreeWalker">
12+
<module name="AbstractClassName"/>
13+
<module name="AnnotationUseStyle"/>
14+
<module name="AnonInnerLength"/>
15+
<module name="ArrayTypeStyle"/>
16+
<module name="AvoidNestedBlocks"/>
17+
<module name="AvoidNoArgumentSuperConstructorCall"/>
18+
<module name="AvoidStarImport"/>
19+
<module name="AvoidStaticImport"/>
20+
<module name="BooleanExpressionComplexity"/>
21+
<module name="CatchParameterName">
22+
<property name="format" value="^e$"/>
23+
</module>
24+
<module name="ClassDataAbstractionCoupling"/>
25+
<module name="ClassFanOutComplexity"/>
26+
<module name="ClassTypeParameterName"/>
27+
<module name="ConstantName"/>
28+
<module name="CovariantEquals"/>
29+
<module name="CustomImportOrder">
30+
<property name="customImportOrderRules" value="SAME_PACKAGE(2)###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS###STATIC"/>
31+
<property name="separateLineBetweenGroups" value="true"/>
32+
</module>
33+
<module name="CyclomaticComplexity"/>
34+
<module name="DeclarationOrder"/>
35+
<module name="DefaultComesLast"/>
36+
<module name="EmptyLineSeparator">
37+
<property name="allowMultipleEmptyLines" value="false"/>
38+
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
39+
<property name="allowNoEmptyLineBetweenFields" value="true"/>
40+
</module>
41+
<module name="EmptyStatement"/>
42+
<module name="EqualsAvoidNull"/>
43+
<module name="EqualsHashCode"/>
44+
<module name="ExecutableStatementCount"/>
45+
<module name="ExplicitInitialization"/>
46+
<module name="FallThrough"/>
47+
<module name="FinalLocalVariable">
48+
<property name="validateEnhancedForLoopVariable" value="true"/>
49+
</module>
50+
<module name="FinalParameters">
51+
<property name="tokens" value="CTOR_DEF,LITERAL_CATCH,METHOD_DEF"/>
52+
</module>
53+
<module name="GenericWhitespace"/>
54+
<module name="HiddenField">
55+
<property name="ignoreConstructorParameter" value="true"/>
56+
<property name="ignoreSetter" value="true"/>
57+
</module>
58+
<module name="HideUtilityClassConstructor"/>
59+
<module name="IllegalCatch"/>
60+
<module name="IllegalThrows"/>
61+
<module name="IllegalToken">
62+
<property name="tokens" value="POST_INC,POST_DEC"/>
63+
</module>
64+
<module name="IllegalType"/>
65+
<module name="Indentation"/>
66+
<module name="InnerAssignment"/>
67+
<module name="InnerTypeLast"/>
68+
<module name="InterfaceIsType"/>
69+
<module name="InterfaceTypeParameterName"/>
70+
<module name="JavaNCSS"/>
71+
<module name="JavadocType"/>
72+
<module name="LambdaParameterName"/>
73+
<module name="LeftCurly"/>
74+
<module name="LocalFinalVariableName"/>
75+
<module name="LocalVariableName"/>
76+
<module name="MagicNumber"/>
77+
<module name="MemberName"/>
78+
<module name="MethodLength"/>
79+
<module name="MethodName"/>
80+
<module name="MethodParamPad"/>
81+
<module name="MethodTypeParameterName"/>
82+
<module name="MissingCtor"/>
83+
<module name="MissingDeprecated"/>
84+
<module name="MissingOverride"/>
85+
<module name="MissingSwitchDefault"/>
86+
<module name="ModifiedControlVariable"/>
87+
<module name="ModifierOrder"/>
88+
<module name="MultipleStringLiterals">
89+
<property name="allowedDuplicates" value="2"/>
90+
<property name="ignoreStringsRegexp" value="^&quot;.?.?&quot;$"/>
91+
</module>
92+
<module name="MultipleVariableDeclarations"/>
93+
<module name="MutableException"/>
94+
<module name="NeedBraces"/>
95+
<module name="NPathComplexity"/>
96+
<module name="NoArrayTrailingComma"/>
97+
<module name="NoClone"/>
98+
<module name="NoEnumTrailingComma"/>
99+
<module name="NoFinalizer"/>
100+
<module name="NoWhitespaceAfter"/>
101+
<module name="NoWhitespaceBefore"/>
102+
<module name="OneStatementPerLine">
103+
<property name="treatTryResourcesAsStatement" value="true"/>
104+
</module>
105+
<module name="OneTopLevelClass"/>
106+
<module name="OperatorWrap">
107+
<property name="option" value="eol"/>
108+
</module>
109+
<module name="OuterTypeFilename"/>
110+
<module name="OuterTypeNumber"/>
111+
<module name="OverloadMethodsDeclarationOrder"/>
112+
<module name="PackageDeclaration"/>
113+
<module name="PackageName"/>
114+
<module name="ParameterAssignment"/>
115+
<module name="ParameterName"/>
116+
<module name="ParameterNumber">
117+
<property name="max" value="5"/>
118+
</module>
119+
<module name="ParenPad"/>
120+
<module name="RedundantImport"/>
121+
<module name="RedundantModifier"/>
122+
<module name="RequireThis"/>
123+
<module name="ReturnCount"/>
124+
<module name="RightCurly">
125+
<property name="option" value="alone"/>
126+
</module>
127+
<module name="SeparatorWrap">
128+
<property name="tokens" value="COMMA,SEMI,ELLIPSIS,ARRAY_DECLARATOR"/>
129+
<property name="option" value="eol"/>
130+
</module>
131+
<module name="SeparatorWrap">
132+
<property name="tokens" value="DOT,AT,METHOD_REF"/>
133+
<property name="option" value="nl"/>
134+
</module>
135+
<module name="SimplifyBooleanExpression"/>
136+
<module name="SimplifyBooleanReturn"/>
137+
<module name="StaticVariableName"/>
138+
<module name="StringLiteralEquality"/>
139+
<module name="SuperClone"/>
140+
<module name="SuperFinalize"/>
141+
<module name="SuppressWarnings">
142+
<!-- allow: fallthrough, unchecked (cf. https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javac.html#BHCJBHDF) -->
143+
<property name="format" value="^\s*(?:all|cast|classfile|deprecation|dep-ann|divzero|empty|finally|options|overrides|path|processing|rawtypes|Serial|static|try|varargs)\s*$"/>
144+
</module>
145+
<module name="SuppressWithNearbyCommentFilter">
146+
<property name="checkFormat" value="$1"/>
147+
<property name="commentFormat" value="checkstyle-disable-line (\w+(?:\|\w+)?)"/>
148+
</module>
149+
<module name="SuppressWarningsHolder" />
150+
<module name="ThrowsCount">
151+
<property name="max" value="2"/>
152+
</module>
153+
<module name="TypecastParenPad"/>
154+
<module name="TypeName"/>
155+
<module name="UnnecessaryParentheses"/>
156+
<module name="UnnecessarySemicolonAfterTypeMemberDeclaration"/>
157+
<module name="UnnecessarySemicolonInEnumeration"/>
158+
<module name="UnnecessarySemicolonInTryWithResources">
159+
<property name="allowWhenNoBraceAfterSemicolon" value="false"/>
160+
</module>
161+
<module name="UnusedImports"/>
162+
<module name="UpperEll"/>
163+
<module name="VisibilityModifier"/>
164+
<module name="WhitespaceAfter"/>
165+
<module name="WhitespaceAround"/>
166+
</module>
167+
</module>

metafacture-biblio/src/main/java/org/metafacture/biblio/AlephMabXmlHandler.java

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* See the License for the specific language governing permissions and
1313
* limitations under the License.
1414
*/
15+
1516
package org.metafacture.biblio;
1617

1718
import org.metafacture.framework.FluxCommand;
@@ -21,6 +22,7 @@
2122
import org.metafacture.framework.annotations.In;
2223
import org.metafacture.framework.annotations.Out;
2324
import org.metafacture.framework.helpers.DefaultXmlPipe;
25+
2426
import org.xml.sax.Attributes;
2527
import org.xml.sax.SAXException;
2628

@@ -48,6 +50,9 @@ public final class AlephMabXmlHandler extends DefaultXmlPipe<StreamReceiver> {
4850
private String currentTag = "";
4951
private StringBuilder builder = new StringBuilder();
5052

53+
public AlephMabXmlHandler() {
54+
}
55+
5156
@Override
5257
public void characters(final char[] chars, final int start, final int length)
5358
throws SAXException {
@@ -60,11 +65,14 @@ public void endElement(final String uri, final String localName, final String qN
6065
if (AlephMabXmlHandler.CONTROLLFIELD.equals(localName)) {
6166
getReceiver().literal(this.currentTag, this.builder.toString().trim());
6267
getReceiver().endEntity();
63-
} else if (AlephMabXmlHandler.SUBFIELD.equals(localName)) {
68+
}
69+
else if (AlephMabXmlHandler.SUBFIELD.equals(localName)) {
6470
getReceiver().literal(this.currentTag, this.builder.toString().trim());
65-
} else if (AlephMabXmlHandler.DATAFIELD.equals(localName)) {
71+
}
72+
else if (AlephMabXmlHandler.DATAFIELD.equals(localName)) {
6673
getReceiver().endEntity();
67-
} else if (AlephMabXmlHandler.RECORD.equals(localName)) {
74+
}
75+
else if (AlephMabXmlHandler.RECORD.equals(localName)) {
6876
getReceiver().endRecord();
6977
}
7078
}
@@ -76,16 +84,20 @@ public void startElement(final String uri, final String localName, final String
7684
this.builder = new StringBuilder();
7785
this.currentTag = "";
7886
getReceiver().startEntity(attributes.getValue(AlephMabXmlHandler.DATAFIELD_ATTRIBUTE));
79-
} else if (AlephMabXmlHandler.SUBFIELD.equals(localName)) {
87+
}
88+
else if (AlephMabXmlHandler.SUBFIELD.equals(localName)) {
8089
this.builder = new StringBuilder();
8190
this.currentTag = attributes.getValue(AlephMabXmlHandler.SUBFIELD_ATTRIBUTE);
82-
} else if (AlephMabXmlHandler.DATAFIELD.equals(localName)) {
83-
getReceiver().startEntity(attributes.getValue(AlephMabXmlHandler.DATAFIELD_ATTRIBUTE)
84-
+ attributes.getValue(AlephMabXmlHandler.INDICATOR1)
85-
+ attributes.getValue(AlephMabXmlHandler.INDICATOR2));
86-
} else if (AlephMabXmlHandler.RECORD.equals(localName)) {
91+
}
92+
else if (AlephMabXmlHandler.DATAFIELD.equals(localName)) {
93+
getReceiver().startEntity(attributes.getValue(AlephMabXmlHandler.DATAFIELD_ATTRIBUTE) +
94+
attributes.getValue(AlephMabXmlHandler.INDICATOR1) +
95+
attributes.getValue(AlephMabXmlHandler.INDICATOR2));
96+
}
97+
else if (AlephMabXmlHandler.RECORD.equals(localName)) {
8798
getReceiver().startRecord("");
88-
} else if (AlephMabXmlHandler.LEADER.equals(localName)) {
99+
}
100+
else if (AlephMabXmlHandler.LEADER.equals(localName)) {
89101
this.builder = new StringBuilder();
90102
this.currentTag = AlephMabXmlHandler.LEADER;
91103
}

metafacture-biblio/src/main/java/org/metafacture/biblio/AseqDecoder.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.biblio;
1718

1819
import org.metafacture.framework.FluxCommand;
@@ -31,11 +32,19 @@
3132
@In(String.class)
3233
@Out(StreamReceiver.class)
3334
@FluxCommand("decode-aseq")
34-
public final class AseqDecoder
35-
extends DefaultObjectPipe<String, StreamReceiver> {
35+
public final class AseqDecoder extends DefaultObjectPipe<String, StreamReceiver> {
3636

3737
private static final String FIELD_DELIMITER = "\n";
3838

39+
private static final int CATEGORY_BEGIN = 10;
40+
private static final int CATEGORY_END = 15;
41+
private static final int FIELD_CONTENT_BEGIN = 18;
42+
private static final int RECORD_IDENTIFIER_BEGIN = 0;
43+
private static final int RECORD_IDENTIFIER_END = 9;
44+
45+
public AseqDecoder() {
46+
}
47+
3948
@Override
4049
public void process(final String record) {
4150
assert !isClosed();
@@ -44,16 +53,17 @@ public void process(final String record) {
4453
return;
4554
}
4655
final String[] lines = trimedRecord.split(FIELD_DELIMITER);
47-
for (int i = 0; i < lines.length; i++) {
56+
for (int i = 0; i < lines.length; ++i) {
4857
final String field = lines[i];
4958
if (i == 0) {
50-
getReceiver().startRecord(field.substring(0, 9));
59+
getReceiver().startRecord(field.substring(RECORD_IDENTIFIER_BEGIN, RECORD_IDENTIFIER_END));
5160
}
52-
final String category = field.substring(10, 15).trim();
53-
final String fieldContent = field.substring(18).trim();
61+
final String category = field.substring(CATEGORY_BEGIN, CATEGORY_END).trim();
62+
final String fieldContent = field.substring(FIELD_CONTENT_BEGIN).trim();
5463
if (!fieldContent.startsWith("$$")) {
5564
getReceiver().literal(category, fieldContent);
56-
} else {
65+
}
66+
else {
5767
getReceiver().startEntity(category);
5868
final String[] subfields = fieldContent.split("\\$\\$");
5969
for (final String subfield : subfields) {

0 commit comments

Comments
 (0)