Skip to content

Commit

Permalink
Update Checkstyle rules and apply them.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Dec 4, 2024
1 parent 72a8a77 commit eb24bb0
Show file tree
Hide file tree
Showing 16 changed files with 114 additions and 101 deletions.
16 changes: 13 additions & 3 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="SuppressionFilter">
<property name="file" value="${config_loc}/suppressions.xml"/>
</module>

<module name="SuppressWithPlainTextCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE\:OFF\:(\w+)"/>
<property name="onCommentFormat" value="CHECKSTYLE\:ON\:(\w+)"/>
<property name="checkFormat" value="$1"/>
</module>

<module name="SuppressWarningsFilter"/>

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

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

Expand All @@ -33,9 +39,13 @@

<module name="SuppressWarningsHolder"/>

<module name="JavadocStyle"/>
<module name="JavadocType"/>
<module name="JavadocMethod"/>
<module name="JavadocVariable">
<property name="scope" value="public"/>
</module>

<module name="MissingJavadocType"/>
<module name="MissingJavadocMethod"/>
<module name="MissingJavadocPackage"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public Representation representation()
}

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

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

/**
* Parse constant value string and set representation based on type, length, and characterEncoding
* Parse constant value string and set representation based on type, length, and characterEncoding.
*
* @param value expressed as a String.
* @param length of the type.
Expand Down Expand Up @@ -469,7 +469,7 @@ public byte[] byteArrayValue()
}

/**
* Return byte array value for this PrimitiveValue given a particular type
* Return byte array value for this PrimitiveValue given a particular type.
*
* @param type of this value.
* @return value expressed as a byte array.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.regex.Pattern;

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

/**
* C# keywords.
* <a href="https://docs.microsoft.com/en-gb/dotnet/articles/csharp/language-reference/keywords/index">
* C# keywords</a>
* Note this does not include the contextual keywords
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ public static String formatScopedName(final CharSequence[] scope, final String v
}

/**
* Return the C99 formatted byte order encoding string to use for a given byte order and primitiveType
* Return the C99 formatted byte order encoding string to use for a given byte order and primitiveType.
*
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}
* @return the string formatted as the byte ordering encoding
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}.
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}.
* @return the string formatted as the byte ordering encoding.
*/
public static String formatByteOrderEncoding(final ByteOrder byteOrder, final PrimitiveType primitiveType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ public static String formatClassName(final String value)
}

/**
* Return the Cpp98 formatted byte order encoding string to use for a given byte order and primitiveType
* Return the Cpp98 formatted byte order encoding string to use for a given byte order and primitiveType.
*
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}
* @return the string formatted as the byte ordering encoding
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}.
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}.
* @return the string formatted as the byte ordering encoding.
*/
public static String formatByteOrderEncoding(final ByteOrder byteOrder, final PrimitiveType primitiveType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,11 @@ public static String formatGetterName(final String propertyName)
}

/**
* Shortcut to append a line of generated code
* Shortcut to append a line of generated code.
*
* @param builder string builder to which to append the line
* @param indent current text indentation
* @param line line to be appended
* @param builder string builder to which to append the line.
* @param indent current text indentation.
* @param line line to be appended.
*/
public static void append(final StringBuilder builder, final String indent, final String line)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static String formatClassName(final String value)
}

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

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

/**
* Return the Golang formatted byte order encoding string to use to read for a given byte order and primitiveType
* Return the Golang formatted byte order encoding string to use to read for a given byte order and primitiveType.
*
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}
* @return the string formatted as the byte ordering encoding
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}.
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}.
* @return the string formatted as the byte ordering encoding.
*/
public static String formatReadBytes(final ByteOrder byteOrder, final PrimitiveType primitiveType)
{
final String suffix = (byteOrder == ByteOrder.BIG_ENDIAN ?
"BigEndian" : "LittleEndian");
final String suffix = byteOrder == ByteOrder.BIG_ENDIAN ? "BigEndian" : "LittleEndian";

switch (primitiveType)
{
Expand Down Expand Up @@ -182,16 +181,15 @@ public static String formatReadBytes(final ByteOrder byteOrder, final PrimitiveT
}

/**
* Return the Golang formatted byte order encoding string to use to write for a given byte order and primitiveType
* Return the Golang formatted byte order encoding string to use to write for a given byte order and primitiveType.
*
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}
* @return the string formatted as the byte ordering encoding
* @param byteOrder of the {@link uk.co.real_logic.sbe.ir.Token}.
* @param primitiveType of the {@link uk.co.real_logic.sbe.ir.Token}.
* @return the string formatted as the byte ordering encoding.
*/
public static String formatWriteBytes(final ByteOrder byteOrder, final PrimitiveType primitiveType)
{
final String suffix = (byteOrder == ByteOrder.BIG_ENDIAN ?
"BigEndian" : "LittleEndian");
final String suffix = byteOrder == ByteOrder.BIG_ENDIAN ? "BigEndian" : "LittleEndian";

switch (primitiveType)
{
Expand Down Expand Up @@ -220,5 +218,4 @@ public static String formatWriteBytes(final ByteOrder byteOrder, final Primitive
}
return "";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ public static String formatClassName(final String className)
}

/**
* Shortcut to append a line of generated code
* Shortcut to append a line of generated code.
*
* @param builder string builder to which to append the line
* @param indent current text indentation
* @param line line to be appended
* @param builder string builder to which to append the line.
* @param indent current text indentation.
* @param line line to be appended.
*/
public static void append(final StringBuilder builder, final String indent, final String line)
{
Expand Down Expand Up @@ -533,5 +533,4 @@ private static void escapeJavadoc(final StringBuilder sb, final String doc)
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package uk.co.real_logic.sbe.generation.rust;

import uk.co.real_logic.sbe.ir.Ir;

import java.io.IOException;
import java.io.Writer;
import java.nio.ByteOrder;
Expand All @@ -23,11 +25,15 @@
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.stream.Stream;
import uk.co.real_logic.sbe.ir.Ir;

import static java.nio.ByteOrder.LITTLE_ENDIAN;
import static uk.co.real_logic.sbe.generation.rust.RustGenerator.*;
import static uk.co.real_logic.sbe.generation.rust.RustUtil.*;
import static uk.co.real_logic.sbe.generation.rust.RustGenerator.BUF_LIFETIME;
import static uk.co.real_logic.sbe.generation.rust.RustGenerator.READ_BUF_TYPE;
import static uk.co.real_logic.sbe.generation.rust.RustGenerator.WRITE_BUF_TYPE;
import static uk.co.real_logic.sbe.generation.rust.RustUtil.TYPE_NAME_BY_PRIMITIVE_TYPE_MAP;
import static uk.co.real_logic.sbe.generation.rust.RustUtil.indent;
import static uk.co.real_logic.sbe.generation.rust.RustUtil.rustTypeName;
import static uk.co.real_logic.sbe.generation.rust.RustUtil.toLowerSnakeCase;

/**
* Generates `lib.rs` specific code.
Expand All @@ -39,11 +45,11 @@ class LibRsDef
private final String schemaVersionType;

/**
* Create a new 'lib.rs' for the library being generated
* Create a new 'lib.rs' for the library being generated.
*
* @param outputManager for generating the codecs to.
* @param byteOrder for the Encoding.
* @param schemaVersionType for acting_version type
* @param schemaVersionType for acting_version type.
*/
LibRsDef(
final RustOutputManager outputManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static String generateRustLiteral(final PrimitiveType type, final String value)
Verify.notNull(type, "type");
Verify.notNull(value, "value");
final String typeName = rustTypeName(type);
if (typeName == null)
if (null == typeName)
{
throw new IllegalArgumentException("Unknown Rust type name found for primitive " + type.primitiveName());
}
Expand Down Expand Up @@ -178,7 +178,7 @@ static String characterEncoding(final Encoding encoding)

/**
* Converts to 'snake_case' but will also handle when there are multiple
* upper case characters in a row 'UPPERCase' => 'upper_case'
* upper case characters in a row 'UPPERCase' => 'upper_case'.
*
* @param value to be formatted
* @return the string formatted to 'lower_snake_case'
Expand Down
12 changes: 6 additions & 6 deletions sbe-tool/src/main/java/uk/co/real_logic/sbe/ir/Token.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class Token
public static final int INVALID_ID = -1;

/**
* Length not determined
* Length not determined.
*/
public static final int VARIABLE_LENGTH = -1;

Expand Down Expand Up @@ -148,17 +148,17 @@ public Signal signal()
}

/**
* Return the name of the token
* Return the name of the token.
*
* @return name of the token
* @return name of the token.
*/
public String name()
{
return name;
}

/**
* Return the packageName of the token
* Return the packageName of the token.
*
* @return packageName of the token or null, if it was not set explicitly.
*/
Expand Down Expand Up @@ -188,9 +188,9 @@ public String description()
}

/**
* Return the ID of the token assigned by the specification
* Return the ID of the token assigned by the specification.
*
* @return ID of the token assigned by the specification
* @return ID of the token assigned by the specification.
*/
public int id()
{
Expand Down
Loading

0 comments on commit eb24bb0

Please sign in to comment.