Skip to content

Commit eb24bb0

Browse files
committed
Update Checkstyle rules and apply them.
1 parent 72a8a77 commit eb24bb0

File tree

16 files changed

+114
-101
lines changed

16 files changed

+114
-101
lines changed

config/checkstyle/checkstyle.xml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
<?xml version="1.0"?>
22
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
3-
"https://checkstyle.org/dtds/configuration_1_3.dtd">
3+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
44
<module name="Checker">
55
<module name="SuppressionFilter">
66
<property name="file" value="${config_loc}/suppressions.xml"/>
77
</module>
88

9+
<module name="SuppressWithPlainTextCommentFilter">
10+
<property name="offCommentFormat" value="CHECKSTYLE\:OFF\:(\w+)"/>
11+
<property name="onCommentFormat" value="CHECKSTYLE\:ON\:(\w+)"/>
12+
<property name="checkFormat" value="$1"/>
13+
</module>
14+
915
<module name="SuppressWarningsFilter"/>
1016

1117
<module name="SeverityMatchFilter">
@@ -22,8 +28,8 @@
2228
<property name="ignorePattern" value="^[ \t]*\*.*@.*$"/>
2329
</module>
2430

25-
<module name="Header">
26-
<property name="header" value="/*\n * Copyright 2013-2024 Real Logic Limited."/>
31+
<module name="RegexpHeader">
32+
<property name="header" value="/*\n * Copyright \d{4}(-\d{4})? (Real Logic|Adaptive Financial Consulting) Limited."/>
2733
<property name="fileExtensions" value="java"/>
2834
</module>
2935

@@ -33,9 +39,13 @@
3339

3440
<module name="SuppressWarningsHolder"/>
3541

42+
<module name="JavadocStyle"/>
43+
<module name="JavadocType"/>
44+
<module name="JavadocMethod"/>
3645
<module name="JavadocVariable">
3746
<property name="scope" value="public"/>
3847
</module>
48+
3949
<module name="MissingJavadocType"/>
4050
<module name="MissingJavadocMethod"/>
4151
<module name="MissingJavadocPackage"/>

sbe-tool/src/main/java/uk/co/real_logic/sbe/PrimitiveValue.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ public Representation representation()
308308
}
309309

310310
/**
311-
* Parse constant value string and set representation based on type
311+
* Parse constant value string and set representation based on type.
312312
*
313313
* @param value expressed as a String.
314314
* @param primitiveType that this is supposed to be.
@@ -367,7 +367,7 @@ public static PrimitiveValue parse(final String value, final PrimitiveType primi
367367
}
368368

369369
/**
370-
* Parse constant value string and set representation based on type
370+
* Parse constant value string and set representation based on type.
371371
*
372372
* @param value expressed as a String.
373373
* @param primitiveType that this is supposed to be.
@@ -392,7 +392,7 @@ public static PrimitiveValue parse(
392392
}
393393

394394
/**
395-
* Parse constant value string and set representation based on type, length, and characterEncoding
395+
* Parse constant value string and set representation based on type, length, and characterEncoding.
396396
*
397397
* @param value expressed as a String.
398398
* @param length of the type.
@@ -469,7 +469,7 @@ public byte[] byteArrayValue()
469469
}
470470

471471
/**
472-
* Return byte array value for this PrimitiveValue given a particular type
472+
* Return byte array value for this PrimitiveValue given a particular type.
473473
*
474474
* @param type of this value.
475475
* @return value expressed as a byte array.

sbe-tool/src/main/java/uk/co/real_logic/sbe/ValidationUtil.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.util.regex.Pattern;
2020

2121
/**
22-
* Various validation utilities used across parser, IR, and generator
22+
* Various validation utilities used across parser, IR, and generator.
2323
*/
2424
public class ValidationUtil
2525
{
@@ -228,7 +228,7 @@ private static boolean isSbeCppIdentifierPart(final char c)
228228
* <p>
229229
* <a href="http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.9">Java JLS</a>
230230
*
231-
* @param value to check
231+
* @param value to check.
232232
* @return true for validity as a Java name. false if not.
233233
*/
234234
public static boolean isSbeJavaName(final String value)
@@ -391,6 +391,7 @@ private static boolean isSbeGolangIdentifierPart(final char c)
391391
}
392392

393393
/**
394+
* C# keywords.
394395
* <a href="https://docs.microsoft.com/en-gb/dotnet/articles/csharp/language-reference/keywords/index">
395396
* C# keywords</a>
396397
* Note this does not include the contextual keywords

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/c/CUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ public static String formatScopedName(final CharSequence[] scope, final String v
108108
}
109109

110110
/**
111-
* Return the C99 formatted byte order encoding string to use for a given byte order and primitiveType
111+
* Return the C99 formatted byte order encoding string to use for a given byte order and primitiveType.
112112
*
113-
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}
114-
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}
115-
* @return the string formatted as the byte ordering encoding
113+
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}.
114+
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}.
115+
* @return the string formatted as the byte ordering encoding.
116116
*/
117117
public static String formatByteOrderEncoding(final ByteOrder byteOrder, final PrimitiveType primitiveType)
118118
{

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/cpp/CppUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ public static String formatClassName(final String value)
106106
}
107107

108108
/**
109-
* Return the Cpp98 formatted byte order encoding string to use for a given byte order and primitiveType
109+
* Return the Cpp98 formatted byte order encoding string to use for a given byte order and primitiveType.
110110
*
111-
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}
112-
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}
113-
* @return the string formatted as the byte ordering encoding
111+
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}.
112+
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}.
113+
* @return the string formatted as the byte ordering encoding.
114114
*/
115115
public static String formatByteOrderEncoding(final ByteOrder byteOrder, final PrimitiveType primitiveType)
116116
{

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/csharp/CSharpUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,11 @@ public static String formatGetterName(final String propertyName)
322322
}
323323

324324
/**
325-
* Shortcut to append a line of generated code
325+
* Shortcut to append a line of generated code.
326326
*
327-
* @param builder string builder to which to append the line
328-
* @param indent current text indentation
329-
* @param line line to be appended
327+
* @param builder string builder to which to append the line.
328+
* @param indent current text indentation.
329+
* @param line line to be appended.
330330
*/
331331
public static void append(final StringBuilder builder, final String indent, final String line)
332332
{

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/golang/flyweight/GolangFlyweightUtil.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static String formatClassName(final String value)
8787
}
8888

8989
/**
90-
* Map the name of a {@link uk.co.real_logic.sbe.PrimitiveType} to a Golang marhsalling function name.
90+
* Map the name of a {@link uk.co.real_logic.sbe.PrimitiveType} to a Golang marshalling function name.
9191
*
9292
* @param primitiveType to map.
9393
* @return the name of the Java primitive that most closely maps.
@@ -114,8 +114,8 @@ public static String formatPropertyName(final String value)
114114
{
115115
throw new IllegalStateException(
116116
"Invalid property name='" + formattedValue +
117-
"' please correct the schema or consider setting system property: " +
118-
SbeTool.KEYWORD_APPEND_TOKEN);
117+
"' please correct the schema or consider setting system property: " +
118+
SbeTool.KEYWORD_APPEND_TOKEN);
119119
}
120120

121121
formattedValue += keywordAppendToken;
@@ -142,16 +142,15 @@ public static String closingBraces(final int count)
142142
}
143143

144144
/**
145-
* Return the Golang formatted byte order encoding string to use to read for a given byte order and primitiveType
145+
* Return the Golang formatted byte order encoding string to use to read for a given byte order and primitiveType.
146146
*
147-
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}
148-
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}
149-
* @return the string formatted as the byte ordering encoding
147+
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}.
148+
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}.
149+
* @return the string formatted as the byte ordering encoding.
150150
*/
151151
public static String formatReadBytes(final ByteOrder byteOrder, final PrimitiveType primitiveType)
152152
{
153-
final String suffix = (byteOrder == ByteOrder.BIG_ENDIAN ?
154-
"BigEndian" : "LittleEndian");
153+
final String suffix = byteOrder == ByteOrder.BIG_ENDIAN ? "BigEndian" : "LittleEndian";
155154

156155
switch (primitiveType)
157156
{
@@ -182,16 +181,15 @@ public static String formatReadBytes(final ByteOrder byteOrder, final PrimitiveT
182181
}
183182

184183
/**
185-
* Return the Golang formatted byte order encoding string to use to write for a given byte order and primitiveType
184+
* Return the Golang formatted byte order encoding string to use to write for a given byte order and primitiveType.
186185
*
187-
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}
188-
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}
189-
* @return the string formatted as the byte ordering encoding
186+
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}.
187+
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}.
188+
* @return the string formatted as the byte ordering encoding.
190189
*/
191190
public static String formatWriteBytes(final ByteOrder byteOrder, final PrimitiveType primitiveType)
192191
{
193-
final String suffix = (byteOrder == ByteOrder.BIG_ENDIAN ?
194-
"BigEndian" : "LittleEndian");
192+
final String suffix = byteOrder == ByteOrder.BIG_ENDIAN ? "BigEndian" : "LittleEndian";
195193

196194
switch (primitiveType)
197195
{
@@ -220,5 +218,4 @@ public static String formatWriteBytes(final ByteOrder byteOrder, final Primitive
220218
}
221219
return "";
222220
}
223-
224221
}

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaUtil.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ public static String formatClassName(final String className)
208208
}
209209

210210
/**
211-
* Shortcut to append a line of generated code
211+
* Shortcut to append a line of generated code.
212212
*
213-
* @param builder string builder to which to append the line
214-
* @param indent current text indentation
215-
* @param line line to be appended
213+
* @param builder string builder to which to append the line.
214+
* @param indent current text indentation.
215+
* @param line line to be appended.
216216
*/
217217
public static void append(final StringBuilder builder, final String indent, final String line)
218218
{
@@ -533,5 +533,4 @@ private static void escapeJavadoc(final StringBuilder sb, final String doc)
533533
}
534534
}
535535
}
536-
537536
}

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/rust/LibRsDef.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package uk.co.real_logic.sbe.generation.rust;
1717

18+
import uk.co.real_logic.sbe.ir.Ir;
19+
1820
import java.io.IOException;
1921
import java.io.Writer;
2022
import java.nio.ByteOrder;
@@ -23,11 +25,15 @@
2325
import java.util.ArrayList;
2426
import java.util.LinkedHashSet;
2527
import java.util.stream.Stream;
26-
import uk.co.real_logic.sbe.ir.Ir;
2728

2829
import static java.nio.ByteOrder.LITTLE_ENDIAN;
29-
import static uk.co.real_logic.sbe.generation.rust.RustGenerator.*;
30-
import static uk.co.real_logic.sbe.generation.rust.RustUtil.*;
30+
import static uk.co.real_logic.sbe.generation.rust.RustGenerator.BUF_LIFETIME;
31+
import static uk.co.real_logic.sbe.generation.rust.RustGenerator.READ_BUF_TYPE;
32+
import static uk.co.real_logic.sbe.generation.rust.RustGenerator.WRITE_BUF_TYPE;
33+
import static uk.co.real_logic.sbe.generation.rust.RustUtil.TYPE_NAME_BY_PRIMITIVE_TYPE_MAP;
34+
import static uk.co.real_logic.sbe.generation.rust.RustUtil.indent;
35+
import static uk.co.real_logic.sbe.generation.rust.RustUtil.rustTypeName;
36+
import static uk.co.real_logic.sbe.generation.rust.RustUtil.toLowerSnakeCase;
3137

3238
/**
3339
* Generates `lib.rs` specific code.
@@ -39,11 +45,11 @@ class LibRsDef
3945
private final String schemaVersionType;
4046

4147
/**
42-
* Create a new 'lib.rs' for the library being generated
48+
* Create a new 'lib.rs' for the library being generated.
4349
*
4450
* @param outputManager for generating the codecs to.
4551
* @param byteOrder for the Encoding.
46-
* @param schemaVersionType for acting_version type
52+
* @param schemaVersionType for acting_version type.
4753
*/
4854
LibRsDef(
4955
final RustOutputManager outputManager,

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/rust/RustUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static String generateRustLiteral(final PrimitiveType type, final String value)
7070
Verify.notNull(type, "type");
7171
Verify.notNull(value, "value");
7272
final String typeName = rustTypeName(type);
73-
if (typeName == null)
73+
if (null == typeName)
7474
{
7575
throw new IllegalArgumentException("Unknown Rust type name found for primitive " + type.primitiveName());
7676
}
@@ -178,7 +178,7 @@ static String characterEncoding(final Encoding encoding)
178178

179179
/**
180180
* Converts to 'snake_case' but will also handle when there are multiple
181-
* upper case characters in a row 'UPPERCase' => 'upper_case'
181+
* upper case characters in a row 'UPPERCase' => 'upper_case'.
182182
*
183183
* @param value to be formatted
184184
* @return the string formatted to 'lower_snake_case'

0 commit comments

Comments
 (0)